[PATCH] dirstate: fix filefoldmap incosistency on file delete
Mateusz Kwapich
mitrandir at fb.com
Fri Nov 6 20:30:24 UTC 2015
Durham pointed me that util.safehasattr is not a correct way of checking if the filefoldmap is already computed. I’ll send V2 correcting that issue.
On 11/6/15, 11:11 AM, "Mercurial-devel on behalf of Mateusz Kwapich" <mercurial-devel-bounces at selenic.com on behalf of mitrandir at fb.com> wrote:
># HG changeset patch
># User Mateusz Kwapich <mitrandir at fb.com>
># Date 1446836807 28800
># Fri Nov 06 11:06:47 2015 -0800
># Node ID d1cf6ffa75ab5d35964ad152f237fecc363eb1e0
># Parent f9984f76fd90e439221425d751e29bae17bec995
>dirstate: fix filefoldmap incosistency on file delete
>
>The filefolmap is not updated in when files are deleted from dirstate. In the
>case where the file with the same but differently cased name is added afterwards
>it renders filefoldmap incorrect. Those steps must occur to for a problem to
>reproduce:
> - call status (with listunknown=True),
> - update working rectory to a commit which does a casefolding change (A -> a)
> - call status again (it will show the file "a" as deleted)
>
>Unfortunately I'm unable to write a test for it because I don't know any
>core-mercurial command able to reproduce those steps.
>
>The bug was originally spotted when hgwatchman was enabled. It caused the
>changeset contents change during hg rebase (one file unrelarted to changeset
>was deleted in it after rebase).
>
>The hgwatchman is able to hit it because when hgignore changes the hgwatchmans
>overridestatus is calling original status with listunknown=True.
>
>diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
>--- a/mercurial/dirstate.py
>+++ b/mercurial/dirstate.py
>@@ -536,6 +536,11 @@
> if size == 0 and f in self._copymap:
> del self._copymap[f]
>
>+ if util.safehasattr(self, "_filefoldmap"):
>+ normed = util.normcase(f)
>+ if normed in self._filefoldmap:
>+ del self._filefoldmap[normed]
>+
> def merge(self, f):
> '''Mark a file merged.'''
> if self._pl[1] == nullid:
>@@ -549,6 +554,11 @@
> self._droppath(f)
> del self._map[f]
>
>+ if util.safehasattr(self, "_filefoldmap"):
>+ normed = util.normcase(f)
>+ if normed in self._filefoldmap:
>+ del self._filefoldmap[normed]
>+
> def _discoverpath(self, path, normed, ignoremissing, exists, storemap):
> if exists is None:
> exists = os.path.lexists(os.path.join(self._root, path))
>_______________________________________________
>Mercurial-devel mailing list
>Mercurial-devel at selenic.com
>https://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list