D11131: dirstate-map: factor out the change to _dirs and _alldirs on removing
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Mon Jul 19 10:40:38 UTC 2021
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.
REVISION SUMMARY
This logic is complicated enough to deserves its own function. So it now does.
This will make it easier to reuse that logic in later changeset.
REPOSITORY
rHG Mercurial
BRANCH
default
REVISION DETAIL
https://phab.mercurial-scm.org/D11131
AFFECTED FILES
mercurial/dirstatemap.py
CHANGE DETAILS
diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -153,13 +153,15 @@
if old_entry is None and "_alldirs" in self.__dict__:
self._alldirs.addpath(filename)
- def _dirs_decr(self, filename, old_entry=None):
+ def _dirs_decr(self, filename, old_entry=None, remove_variant=False):
"""decremente the dirstate counter if applicable"""
if old_entry is not None:
if "_dirs" in self.__dict__ and not old_entry.removed:
self._dirs.delpath(filename)
- if "_alldirs" in self.__dict__:
+ if "_alldirs" in self.__dict__ and not remove_variant:
self._alldirs.delpath(filename)
+ elif remove_variant and "_alldirs" in self.__dict__:
+ self._alldirs.addpath(filename)
if "filefoldmap" in self.__dict__:
normed = util.normcase(filename)
self.filefoldmap.pop(normed, None)
@@ -239,14 +241,7 @@
self.otherparentset.add(f)
if entry is not None and not (entry.merged or entry.from_p2):
self.copymap.pop(f, None)
-
- if entry is not None and not entry.removed and "_dirs" in self.__dict__:
- self._dirs.delpath(f)
- if entry is None and "_alldirs" in self.__dict__:
- self._alldirs.addpath(f)
- if "filefoldmap" in self.__dict__:
- normed = util.normcase(f)
- self.filefoldmap.pop(normed, None)
+ self._dirs_decr(f, old_entry=entry, remove_variant=True)
self._map[f] = DirstateItem(b'r', 0, size, 0)
self.nonnormalset.add(f)
To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
More information about the Mercurial-devel
mailing list