mercurial/dirstatemap.py
changeset 47687 e59bd6723f2f
parent 47686 e43128ee436f
child 47688 b37ab6b5c438
--- a/mercurial/dirstatemap.py	Wed Jul 14 22:06:13 2021 +0200
+++ b/mercurial/dirstatemap.py	Thu Jul 15 01:58:31 2021 +0200
@@ -146,6 +146,15 @@
         """Loads the underlying data, if it's not already loaded"""
         self._map
 
+    def _dirs_incr(self, filename, old_entry=None):
+        """incremente the dirstate counter if applicable"""
+        if (
+            old_entry is None or old_entry.removed
+        ) and "_dirs" in self.__dict__:
+            self._dirs.addpath(filename)
+        if old_entry is None and "_alldirs" in self.__dict__:
+            self._alldirs.addpath(filename)
+
     def addfile(
         self,
         f,
@@ -190,12 +199,7 @@
         assert size is not None
         assert mtime is not None
         old_entry = self.get(f)
-        if (
-            old_entry is None or old_entry.removed
-        ) and "_dirs" in self.__dict__:
-            self._dirs.addpath(f)
-        if old_entry is None and "_alldirs" in self.__dict__:
-            self._alldirs.addpath(f)
+        self._dirs_incr(f, old_entry)
         e = self._map[f] = DirstateItem(state, mode, size, mtime)
         if e.dm_nonnormal:
             self.nonnormalset.add(f)