dirstatemap: use a common implementation for `dirstatemap.set_untracked`
authorPierre-Yves David <pierre-yves.david@octobus.net>
Fri, 01 Oct 2021 19:14:09 +0200
changeset 48127 ced8cf9c4905
parent 48126 a1a6569b9283
child 48128 a8ff00ad290b
dirstatemap: use a common implementation for `dirstatemap.set_untracked` 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. Differential Revision: https://phab.mercurial-scm.org/D11572
mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py	Fri Oct 01 18:54:40 2021 +0200
+++ b/mercurial/dirstatemap.py	Fri Oct 01 19:14:09 2021 +0200
@@ -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(