dirstate-item: use the properties in dirstatemap
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 05 Jul 2021 03:58:38 +0200
changeset 47542 b8013cb71ef3
parent 47541 a9f38b144096
child 47543 20b65f34d704
dirstate-item: use the properties in dirstatemap Differential Revision: https://phab.mercurial-scm.org/D10986
mercurial/dirstatemap.py
--- a/mercurial/dirstatemap.py	Mon Jul 05 03:57:40 2021 +0200
+++ b/mercurial/dirstatemap.py	Mon Jul 05 03:58:38 2021 +0200
@@ -219,13 +219,13 @@
                 # backup the previous state
                 if entry.merged:  # merge
                     size = NONNORMAL
-                elif entry[0] == b'n' and entry.from_p2:
+                elif entry.from_p2:
                     size = FROM_P2
                     self.otherparentset.add(f)
         if size == 0:
             self.copymap.pop(f, None)
 
-        if entry is not None and entry[0] != b'r' and "_dirs" in self.__dict__:
+        if entry is not None and not entry.removed and "_dirs" in self.__dict__:
             self._dirs.delpath(f)
         if entry is None and "_alldirs" in self.__dict__:
             self._alldirs.addpath(f)
@@ -260,8 +260,10 @@
     def clearambiguoustimes(self, files, now):
         for f in files:
             e = self.get(f)
-            if e is not None and e[0] == b'n' and e[3] == now:
-                self._map[f] = DirstateItem(e[0], e[1], e[2], AMBIGUOUS_TIME)
+            if e is not None and e.need_delay(now):
+                self._map[f] = DirstateItem(
+                    e.state, e.mode, e.size, AMBIGUOUS_TIME
+                )
                 self.nonnormalset.add(f)
 
     def nonnormalentries(self):
@@ -272,9 +274,9 @@
             nonnorm = set()
             otherparent = set()
             for fname, e in pycompat.iteritems(self._map):
-                if e[0] != b'n' or e[3] == AMBIGUOUS_TIME:
+                if e.state != b'n' or e.mtime == AMBIGUOUS_TIME:
                     nonnorm.add(fname)
-                if e[0] == b'n' and e[2] == FROM_P2:
+                if e.from_p2:
                     otherparent.add(fname)
             return nonnorm, otherparent
 
@@ -295,7 +297,7 @@
         f = {}
         normcase = util.normcase
         for name, s in pycompat.iteritems(self._map):
-            if s[0] != b'r':
+            if not s.removed:
                 f[normcase(name)] = name
         f[b'.'] = b'.'  # prevents useless util.fspath() invocation
         return f