Patchwork D11572: dirstatemap: use a common implementation for `dirstatemap.set_untracked`

login
register
mail settings
Submitter phabricator
Date Oct. 2, 2021, 3:05 p.m.
Message ID <differential-rev-PHID-DREV-pf7qdz7utcdxz64vlxuo-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49896/
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
  We can now make sure they use the same code, and drop the older, out of sync,
  implementation of `set_untracked` for the rust wrapper.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

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
@@ -101,6 +101,21 @@ 
     def _refresh_entry(self, f, entry):
         """record updated state of an entry"""
 
+    ### method to manipulate the entries
+
+    def set_untracked(self, f):
+        """Mark a file as no longer tracked in the dirstate map"""
+        entry = self.get(f)
+        if entry is None:
+            return False
+        else:
+            self._dirs_decr(f, old_entry=entry, remove_variant=not entry.added)
+            if not entry.merged:
+                self.copymap.pop(f, None)
+            entry.set_untracked()
+            self._refresh_entry(f, entry)
+            return True
+
 
 class dirstatemap(_dirstatemapcommon):
     """Map encapsulating the dirstate's contents.
@@ -496,20 +511,6 @@ 
             self.set_possibly_dirty(filename)
         return new
 
-    def set_untracked(self, f):
-        """Mark a file as no longer tracked in the dirstate map"""
-        entry = self.get(f)
-        if entry is None:
-            return False
-        else:
-            self._dirs_decr(f, old_entry=entry, remove_variant=not entry.added)
-            if not entry.merged:
-                self.copymap.pop(f, None)
-            entry.set_untracked()
-            if not entry.any_tracked:
-                self._map.pop(f, None)
-            return True
-
 
 if rustmod is not None:
 
@@ -898,22 +899,6 @@ 
                 self.set_possibly_dirty(filename)
             return new
 
-        def set_untracked(self, f):
-            """Mark a file as no longer tracked in the dirstate map"""
-            # in merge is only trigger more logic, so it "fine" to pass it.
-            #
-            # the inner rust dirstate map code need to be adjusted once the API
-            # for dirstate/dirstatemap/DirstateItem is a bit more settled
-            entry = self.get(f)
-            if entry is None:
-                return False
-            else:
-                if entry.added:
-                    self._map.drop_item_and_copy_source(f)
-                else:
-                    self._map.removefile(f, in_merge=True)
-                return True
-
         ### Legacy method we need to get rid of
 
         def addfile(