Patchwork D11577: dirstatemap: add a common `_drop_entry` method for dirstatemap

login
register
mail settings
Submitter phabricator
Date Oct. 2, 2021, 3:05 p.m.
Message ID <differential-rev-PHID-DREV-dligntugqsykyj2vvbzz-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49901/
State Superseded
Headers show

Comments

phabricator - Oct. 2, 2021, 3:05 p.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  This method is called to remove DirstateItem from the map.
  
  Each variant have a different implementation (which is … the point).

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11577

AFFECTED FILES
  mercurial/dirstatemap.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/dirstatemap.py b/mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py
+++ b/mercurial/dirstatemap.py
@@ -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)