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
--- a/mercurial/dirstatemap.py Fri Oct 01 23:49:40 2021 +0200
+++ b/mercurial/dirstatemap.py Sat Oct 02 00:01:56 2021 +0200
@@ -107,6 +107,13 @@
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 @@
)
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 @@
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)