Patchwork D5661: unamend: fix unamending of renamed rename

login
register
mail settings
Submitter phabricator
Date Jan. 24, 2019, 5:11 p.m.
Message ID <f0592dfea1364ff83555b34be4c96aac@localhost.localdomain>
Download mbox | patch
Permalink /patch/37982/
State Not Applicable
Headers show

Comments

phabricator - Jan. 24, 2019, 5:11 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG19c590ce8661: unamend: fix unamending of renamed rename (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5661?vs=13373&id=13409

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

AFFECTED FILES
  hgext/uncommit.py
  tests/test-unamend.t

CHANGE DETAILS




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

Patch

diff --git a/tests/test-unamend.t b/tests/test-unamend.t
--- a/tests/test-unamend.t
+++ b/tests/test-unamend.t
@@ -385,9 +385,9 @@ 
   A b
     a
   R a
-BROKEN: should indicate that b was renamed to c
   $ hg st --copies
   A c
+    b
   R b
   $ hg revert -qa
   $ rm c
@@ -405,7 +405,7 @@ 
   A b
     a
   R a
-BROKEN: should indicate that b was renamed to d
   $ hg st --copies
   A d
+    b
   R b
diff --git a/hgext/uncommit.py b/hgext/uncommit.py
--- a/hgext/uncommit.py
+++ b/hgext/uncommit.py
@@ -93,13 +93,13 @@ 
                          extra=ctx.extra())
     return repo.commitctx(new)
 
-def _fixdirstate(repo, oldctx, newctx, status):
+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.
     """
     ds = repo.dirstate
     copies = dict(ds.copies())
-    s = status
+    s = newctx.status(oldctx, match=match)
     for f in s.modified:
         if ds[f] == 'r':
             # modified + removed -> removed
@@ -121,11 +121,7 @@ 
             ds.remove(f)
 
     # Merge old parent and old working dir copies
-    oldcopies = {}
-    for f in (s.modified + s.added):
-        src = oldctx[f].renamed()
-        if src:
-            oldcopies[f] = src[0]
+    oldcopies = copiesmod.pathcopies(newctx, oldctx, match)
     oldcopies.update(copies)
     copies = dict((dst, oldcopies.get(src, src))
                   for dst, src in oldcopies.iteritems())
@@ -181,8 +177,7 @@ 
 
             with repo.dirstate.parentchange():
                 repo.dirstate.setparents(newid, node.nullid)
-                s = old.p1().status(old, match=match)
-                _fixdirstate(repo, old, repo[newid], s)
+                _fixdirstate(repo, old, repo[newid], match)
 
             scmutil.cleanupnodes(repo, mapping, 'uncommit', fixphase=True)
 
@@ -245,8 +240,7 @@ 
 
         with dirstate.parentchange():
             dirstate.setparents(newprednode, node.nullid)
-            s = repo.status(predctx, curctx)
-            _fixdirstate(repo, curctx, newpredctx, s)
+            _fixdirstate(repo, curctx, newpredctx)
 
         mapping = {curctx.node(): (newprednode,)}
         scmutil.cleanupnodes(repo, mapping, 'unamend', fixphase=True)