# HG changeset patch # User Pierre-Yves David # Date 2021-10-01 22:01:56 # Node ID c057d7c97b728bdc54332386630937fb25d56f23 # Parent f903a357ba72011d1399b086edc8776db602787d dirstatemap: add a common `_drop_entry` method for dirstatemap This method is called to remove DirstateItem from the map. Each variant have a different implementation (which is … the point). Differential Revision: https://phab.mercurial-scm.org/D11577 diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py --- a/mercurial/dirstatemap.py +++ b/mercurial/dirstatemap.py @@ -107,6 +107,13 @@ class _dirstatemapcommon(object): The fact it is actually new is the responsability of the caller """ + def _drop_entry(self, f): + """remove any entry for file f + + This should also drop associated copy information + + The fact we actually need to drop it is the responsability of the caller""" + ### method to manipulate the entries def set_possibly_dirty(self, filename): @@ -526,6 +533,10 @@ class dirstatemap(_dirstatemapcommon): ) self._map[filename] = entry + def _drop_entry(self, f): + self._map.pop(f, None) + self._copymap.pop(f, None) + if rustmod is not None: @@ -802,6 +813,9 @@ if rustmod is not None: def _insert_entry(self, f, entry): self._map.addfile(f, entry) + def _drop_entry(self, f): + self._map.drop_item_and_copy_source(f) + def __setitem__(self, key, value): assert isinstance(value, DirstateItem) self._map.set_dirstate_item(key, value)