hgext/shelve.py
changeset 42013 50d5e64ec561
parent 42012 9b78bbb76111
child 42020 00c1ee0f746a
--- a/hgext/shelve.py	Fri Mar 22 13:03:26 2019 -0400
+++ b/hgext/shelve.py	Fri Mar 22 11:26:47 2019 -0400
@@ -499,14 +499,19 @@
             return 1
 
         # Create a matcher so that prefetch doesn't attempt to fetch
-        # the entire repository pointlessly
+        # the entire repository pointlessly, and as an optimisation
+        # for movedirstate, if needed.
         match = scmutil.matchfiles(repo, repo[node].files())
         _shelvecreatedcommit(repo, node, name, match)
 
         if ui.formatted():
             desc = stringutil.ellipsis(desc, ui.termwidth())
         ui.status(_('shelved as %s\n') % name)
-        hg.update(repo, parent.node())
+        if opts['keep']:
+            with repo.dirstate.parentchange():
+                scmutil.movedirstate(repo, parent, match)
+        else:
+            hg.update(repo, parent.node())
         if origbranch != repo['.'].branch() and not _isbareshelve(pats, opts):
             repo.dirstate.setbranch(origbranch)