changeset 44791:4234c9af515d stable

flags: read flag from dirstate/disk for workingcopyctx (issue5743) In 491855ea9d62, various piece of code are moved from committablectx to workingctx. The reason given is "These read from the dirstate, so they shouldn't be used in other subclasses." At least for `flags` this change introduce a bug, because the value flags end up being read from `_manifest` disregarding the actual state in the working copy (ie: on disk). When merging exec flag change with renames, this means a new files (the local content, renamed) is properly written on disk, with the right flags, but the flags part is later ignored when actually reading flags during merge. It is not clear to me why the `flags` function was moved, because the code does not actually hit the dirstate (the reason given in the changeset description). So I am moving it back to were it comes from and we use a simpler version of that code (that hit the dirstate everytime) in workingcopyctx. This fix the last know bug with merging rename and executable byte changes. Other similar bug might be lurking in 491855ea9d62, but I have not investigated them. Differential Revision: https://phab.mercurial-scm.org/D8534
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 16 May 2020 20:38:31 +0200
parents 84614212ae39
children 9afee647a9f0
files mercurial/context.py tests/test-merge-exec.t
diffstat 2 files changed, 12 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/context.py	Sat May 16 20:38:19 2020 +0200
+++ b/mercurial/context.py	Sat May 16 20:38:31 2020 +0200
@@ -1458,6 +1458,18 @@
     def children(self):
         return []
 
+    def flags(self, path):
+        if '_manifest' in self.__dict__:
+            try:
+                return self._manifest.flags(path)
+            except KeyError:
+                return b''
+
+        try:
+            return self._flagfunc(path)
+        except OSError:
+            return b''
+
     def ancestor(self, c2):
         """return the "best" ancestor context of self and c2"""
         return self._parents[0].ancestor(c2)  # punt on two parents for now
@@ -1594,12 +1606,6 @@
         return self._repo.dirstate.flagfunc(self._buildflagfunc)
 
     def flags(self, path):
-        if '_manifest' in self.__dict__:
-            try:
-                return self._manifest.flags(path)
-            except KeyError:
-                return b''
-
         try:
             return self._flagfunc(path)
         except OSError:
--- a/tests/test-merge-exec.t	Sat May 16 20:38:19 2020 +0200
+++ b/tests/test-merge-exec.t	Sat May 16 20:38:31 2020 +0200
@@ -209,6 +209,5 @@
     a
   R a
   $ [ -x z ] || echo "executable bit lost"
-  executable bit lost
 
   $ cd ..