revert: look for copy information for all local modifications stable
authorPierre-Yves David <pierre-yves.david@fb.com>
Tue, 25 Nov 2014 19:40:54 -0800
branchstable
changeset 23403 edf29f9c15f0
parent 23402 2963d5c9d90b
child 23404 b913c394386f
child 23409 dc4d2cd3aa3e
child 23423 c6329a0e8f94
revert: look for copy information for all local modifications Renaming a file over an existing one marks the file as modified. So we track rename source in modified file too.
mercurial/cmdutil.py
tests/test-revert.t
--- a/mercurial/cmdutil.py	Mon Nov 24 18:42:56 2014 -0800
+++ b/mercurial/cmdutil.py	Tue Nov 25 19:40:54 2014 -0800
@@ -2531,12 +2531,16 @@
             dsmodified = modified
             dsadded = added
             dsremoved = removed
+            # store all local modifications, useful later for rename detection
+            localchanges = dsmodified | dsadded
             modified, added, removed = set(), set(), set()
         else:
             changes = repo.status(node1=parent, match=m)
             dsmodified = set(changes[0])
             dsadded    = set(changes[1])
             dsremoved  = set(changes[2])
+            # store all local modifications, useful later for rename detection
+            localchanges = dsmodified | dsadded
 
             # only take into account for removes between wc and target
             clean |= dsremoved - removed
@@ -2570,7 +2574,7 @@
 
         # if f is a rename, update `names` to also revert the source
         cwd = repo.getcwd()
-        for f in dsadded:
+        for f in localchanges:
             src = repo.dirstate.copied(f)
             # XXX should we check for rename down to target node?
             if src and src not in names and repo.dirstate[src] == 'r':
--- a/tests/test-revert.t	Mon Nov 24 18:42:56 2014 -0800
+++ b/tests/test-revert.t	Tue Nov 25 19:40:54 2014 -0800
@@ -234,6 +234,12 @@
   $ hg st a newa
   ? newa
 
+Also true for move overwriting an existing file
+
+  $ hg mv --force a b/b
+  $ hg revert b/b
+  $ hg status a b/b
+
   $ cd ..
 
   $ hg init ignored