changeset 48144:c057d7c97b72

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
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 02 Oct 2021 00:01:56 +0200
parents f903a357ba72
children 55293938b843
files mercurial/dirstatemap.py
diffstat 1 files changed, 14 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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)