Patchwork D6117: uncommit: convert _fixdirstate() into _movedirstate()

login
register
mail settings
Submitter phabricator
Date March 11, 2019, 6:19 p.m.
Message ID <differential-rev-PHID-DREV-5mpnz65fibhzgf2varws-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/39220/
State Superseded
Headers show

Comments

phabricator - March 11, 2019, 6:19 p.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  _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['.'].

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6117

AFFECTED FILES
  hgext/uncommit.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel
phabricator - March 11, 2019, 6:55 p.m.
taapas1128 added a comment.


  In the documentation part don't you think there should be information about the matcher as there was before https://phab.mercurial-scm.org/D971

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6117

To: martinvonz, #hg-reviewers
Cc: taapas1128, mercurial-devel
phabricator - March 11, 2019, 7:58 p.m.
martinvonz added a comment.


  In https://phab.mercurial-scm.org/D6117#89132, @taapas1128 wrote:
  
  > In the documentation part don't you think there should be information about the matcher as there was before https://phab.mercurial-scm.org/D971
  
  
  Yeah, we should document that. I'll send another patch.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6117

To: martinvonz, #hg-reviewers
Cc: taapas1128, mercurial-devel

Patch

diff --git a/hgext/uncommit.py b/hgext/uncommit.py
--- a/hgext/uncommit.py
+++ b/hgext/uncommit.py
@@ -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)