[Request] [+ ] D8534: flags: read flag from dirstate/disk for workingcopyctx (issue5743)

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Sat May 16 20:12:25 UTC 2020


marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  In 491855ea9d62 <https://phab.mercurial-scm.org/rHG491855ea9d62b294de3f2c700b11b1d2d6c286c5>, 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 <https://phab.mercurial-scm.org/rHG491855ea9d62b294de3f2c700b11b1d2d6c286c5>, but I have not investigated
  them.

REPOSITORY
  rHG Mercurial

BRANCH
  stable

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

AFFECTED FILES
  mercurial/context.py
  tests/test-merge-exec.t

CHANGE DETAILS

diff --git a/tests/test-merge-exec.t b/tests/test-merge-exec.t
--- a/tests/test-merge-exec.t
+++ b/tests/test-merge-exec.t
@@ -209,6 +209,5 @@
     a
   R a
   $ [ -x z ] || echo "executable bit lost"
-  executable bit lost
 
   $ cd ..
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -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:



To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20200516/53b3e3b3/attachment.html>


More information about the Mercurial-patches mailing list