[PATCH 3 of 3] context: check for differing flags a little earlier

Martin von Zweigbergk martinvonz at google.com
Tue Jan 12 15:43:48 CST 2016


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1452633031 28800
#      Tue Jan 12 13:10:31 2016 -0800
# Node ID 3ab56a252131fc1b7e04d6564ac14c6ad1b896e0
# Parent  228d5d4d70b304ad1afc7dcc5b7c6b366ea5d239
context: check for differing flags a little earlier

This makes it clearer that a unchanged file whose flags have changed
will be reported as a modification. Also test this.

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -140,14 +140,14 @@
                 added.append(fn)
             elif node2 is None:
                 removed.append(fn)
+            elif flag1 != flag2:
+                modified.append(fn)
             elif self.rev() is not None:
                 # When comparing files between two commits, we save time by
                 # not comparing the file contents when the nodeids differ.
                 # Note that this means we incorrectly report a reverted change
                 # to a file as a modification.
                 modified.append(fn)
-            elif flag1 != flag2:
-                modified.append(fn)
             elif self[fn].cmp(other[fn]):
                 modified.append(fn)
             else:
diff --git a/tests/test-status.t b/tests/test-status.t
--- a/tests/test-status.t
+++ b/tests/test-status.t
@@ -386,6 +386,16 @@
   $ hg status -A --rev 0
   M file
 
+reverted and committed file with changed flag should appear modified
+
+  $ hg co -C .
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ chmod +x file
+  $ hg ci -m 'change flag'
+  $ hg status -A --rev 1 --rev 2
+  M file
+  $ hg diff -r 1 -r 2
+
 #endif
 
   $ cd ..


More information about the Mercurial-devel mailing list