Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/context.py @ 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 | 7c4b98a4e536 |
children | 61719b9658b1 |
comparison
equal
deleted
inserted
replaced
44790:84614212ae39 | 44791:4234c9af515d |
---|---|
1456 return False | 1456 return False |
1457 | 1457 |
1458 def children(self): | 1458 def children(self): |
1459 return [] | 1459 return [] |
1460 | 1460 |
1461 def flags(self, path): | |
1462 if '_manifest' in self.__dict__: | |
1463 try: | |
1464 return self._manifest.flags(path) | |
1465 except KeyError: | |
1466 return b'' | |
1467 | |
1468 try: | |
1469 return self._flagfunc(path) | |
1470 except OSError: | |
1471 return b'' | |
1472 | |
1461 def ancestor(self, c2): | 1473 def ancestor(self, c2): |
1462 """return the "best" ancestor context of self and c2""" | 1474 """return the "best" ancestor context of self and c2""" |
1463 return self._parents[0].ancestor(c2) # punt on two parents for now | 1475 return self._parents[0].ancestor(c2) # punt on two parents for now |
1464 | 1476 |
1465 def ancestors(self): | 1477 def ancestors(self): |
1592 @propertycache | 1604 @propertycache |
1593 def _flagfunc(self): | 1605 def _flagfunc(self): |
1594 return self._repo.dirstate.flagfunc(self._buildflagfunc) | 1606 return self._repo.dirstate.flagfunc(self._buildflagfunc) |
1595 | 1607 |
1596 def flags(self, path): | 1608 def flags(self, path): |
1597 if '_manifest' in self.__dict__: | |
1598 try: | |
1599 return self._manifest.flags(path) | |
1600 except KeyError: | |
1601 return b'' | |
1602 | |
1603 try: | 1609 try: |
1604 return self._flagfunc(path) | 1610 return self._flagfunc(path) |
1605 except OSError: | 1611 except OSError: |
1606 return b'' | 1612 return b'' |
1607 | 1613 |