changeset 41935:bf72e4c39f0b

uncommit: convert _fixdirstate() into _movedirstate() _fixdirstate() already also updates to the given commit, so let's rename it to _movedirstate(). Also update the documentation and drop the unnecessary "curctx" argument, since that should always be repo['.']. Differential Revision: https://phab.mercurial-scm.org/D6117
author Martin von Zweigbergk <martinvonz@google.com>
date Mon, 11 Mar 2019 09:35:36 -0700
parents 481259af4bdf
children a791623458ef
files hgext/uncommit.py
diffstat 1 files changed, 5 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/uncommit.py	Mon Mar 11 02:34:12 2019 +0100
+++ b/hgext/uncommit.py	Mon Mar 11 09:35:36 2019 -0700
@@ -99,10 +99,9 @@
                          extra=ctx.extra())
     return repo.commitctx(new)
 
-def _fixdirstate(repo, oldctx, newctx, match=None):
-    """ fix the dirstate after switching the working directory from oldctx to
-    newctx which can be result of either unamend or uncommit.
-    """
+def _movedirstate(repo, newctx, match=None):
+    """Move the dirstate to newctx and adjust it as necessary."""
+    oldctx = repo['.']
     ds = repo.dirstate
     ds.setparents(newctx.node(), node.nullid)
     copies = dict(ds.copies())
@@ -194,7 +193,7 @@
                 mapping[old.node()] = ()
 
             with repo.dirstate.parentchange():
-                _fixdirstate(repo, old, repo[newid], match)
+                _movedirstate(repo, repo[newid], match)
 
             scmutil.cleanupnodes(repo, mapping, 'uncommit', fixphase=True)
 
@@ -256,7 +255,7 @@
         dirstate = repo.dirstate
 
         with dirstate.parentchange():
-            _fixdirstate(repo, curctx, newpredctx)
+            _movedirstate(repo, newpredctx)
 
         mapping = {curctx.node(): (newprednode,)}
         scmutil.cleanupnodes(repo, mapping, 'unamend', fixphase=True)