status: change + back out == clean (API)
authorMartin von Zweigbergk <martinvonz@google.com>
Mon, 04 Jan 2016 10:13:29 -0800
changeset 27720 89f49813526c
parent 27719 7ce8a13b8d77
child 27721 e4b512bb6386
status: change + back out == clean (API) After backing out a change, so the file contents is equal to a previous revision of itself, we currently report the status between the two equal revisions as modified. This is because context._buildstatus() reports any file whose new nodeid is not equal to _newnode as modified. That magic nodeid is given only to files added or modified in the working directory, so any file whose nodeid has changed between two revisions will be reported as modified. Fix by simply comparing the file contents for all cases where the nodeid changed, whether they are in the working copy or committed. Marking with (API) as it subtly changes the semantics of the method.
mercurial/context.py
tests/test-status.t
--- a/mercurial/context.py	Sat Jan 09 22:58:10 2016 -0800
+++ b/mercurial/context.py	Mon Jan 04 10:13:29 2016 -0800
@@ -140,15 +140,9 @@
                 added.append(fn)
             elif node2 is None:
                 removed.append(fn)
-            elif node2 != _newnode:
-                # The file was not a new file in mf2, so an entry
-                # from diff is really a difference.
-                modified.append(fn)
             elif flag1 != flag2:
                 modified.append(fn)
             elif self[fn].cmp(other[fn]):
-                # node2 was newnode, but the working file doesn't
-                # match the one in mf1.
                 modified.append(fn)
             else:
                 clean.append(fn)
--- a/tests/test-status.t	Sat Jan 09 22:58:10 2016 -0800
+++ b/tests/test-status.t	Mon Jan 04 10:13:29 2016 -0800
@@ -388,6 +388,14 @@
 
 #endif
 
+reverted and commit change should appear clean
+
+  $ hg revert -r 0 .
+  reverting file
+  $ hg ci -m a
+  $ hg status -A --rev 0 --rev 2
+  C file
+
   $ cd ..
 
 hg status of binary file starting with '\1\n', a separator for metadata: