Patchwork D11571: dirstatemap: add a common `_refresh_entry` method for dirstatemap

login
register
mail settings
Submitter phabricator
Date Oct. 2, 2021, 3:05 p.m.
Message ID <differential-rev-PHID-DREV-carej2zeqvzh6tgu72hf-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49895/
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 once a DirstateItem have been modified to apply the
  change on the dirstatemap if necessary.
  
  Each variant have a different implementation (which is … the point).
  
  We use `addfile` for the rustmap and not `set_dirstate_item` because we need to
  keep the internal counter up to date and `set_dirstate_item` does not do it.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -98,6 +98,9 @@ 
         tracking in a different way.
         """
 
+    def _refresh_entry(self, f, entry):
+        """record updated state of an entry"""
+
 
 class dirstatemap(_dirstatemapcommon):
     """Map encapsulating the dirstate's contents.
@@ -381,6 +384,10 @@ 
 
     ### code related to manipulation of entries and copy-sources
 
+    def _refresh_entry(self, f, entry):
+        if not entry.any_tracked:
+            self._map.pop(f, None)
+
     def set_possibly_dirty(self, filename):
         """record that the current state of the file on disk is unknown"""
         self[filename].set_possibly_dirty()
@@ -770,6 +777,12 @@ 
 
         ### code related to manipulation of entries and copy-sources
 
+        def _refresh_entry(self, f, entry):
+            if not entry.any_tracked:
+                self._map.drop_item_and_copy_source(f)
+            else:
+                self._map.addfile(f, entry)
+
         def set_possibly_dirty(self, filename):
             """record that the current state of the file on disk is unknown"""
             entry = self[filename]