changeset 48139:ced8cf9c4905

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
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 01 Oct 2021 19:14:09 +0200
parents a1a6569b9283
children a8ff00ad290b
files mercurial/dirstatemap.py
diffstat 1 files changed, 15 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- 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(