# HG changeset patch # User Pierre-Yves David # Date 1589654311 -7200 # Node ID 4234c9af515d61b486043dbf9ea6c65804b4c9d1 # Parent 84614212ae3984666a9754f7c335f7813691fcf1 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 diff -r 84614212ae39 -r 4234c9af515d mercurial/context.py --- 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: diff -r 84614212ae39 -r 4234c9af515d tests/test-merge-exec.t --- 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 ..