[PATCH 3 of 4 V3] dirstate: add code to update the non-normal map when it should be

Laurent Charignon lcharignon at fb.com
Thu Dec 17 12:24:45 CST 2015


# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1450376480 28800
#      Thu Dec 17 10:21:20 2015 -0800
# Node ID 530d455d2eb83e6b70c3887f5998b84681b5783e
# Parent  2846cbe881e7eda5399cdbbf25166331c3a28872
dirstate: add code to update the non-normal map when it should be

Before this patch, we were only populating the non-normal map when parsing
or packing the dirstate. This was not enough to keep the non-normal map up to
date at all time as we don't write and read the dirstate whenever a change
happens. This patch solves this issue by updating the non-normal map when it
should be updated.

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -424,7 +424,7 @@ class dirstate(object):
 
     def invalidate(self):
         for a in ("_map", "_copymap", "_filefoldmap", "_dirfoldmap", "_branch",
-                  "_pl", "_dirs", "_ignore"):
+                  "_pl", "_dirs", "_ignore", "_nonnormalmap"):
             if a in self.__dict__:
                 delattr(self, a)
         self._lastnormaltime = 0
@@ -473,6 +473,8 @@ class dirstate(object):
             self._dirs.addpath(f)
         self._dirty = True
         self._map[f] = dirstatetuple(state, mode, size, mtime)
+        if state != 'n' or mtime == -1:
+            self._nonnormalmap[f] = dirstatetuple(state, mode, size, mtime)
 
     def normal(self, f):
         '''Mark a file normal and clean.'''
@@ -482,6 +484,8 @@ class dirstate(object):
                       s.st_size & _rangemask, mtime & _rangemask)
         if f in self._copymap:
             del self._copymap[f]
+        if f in self._nonnormalmap:
+            del self._nonnormalmap[f]
         if mtime > self._lastnormaltime:
             # Remember the most recent modification timeslot for status(),
             # to make sure we won't miss future size-preserving file content
@@ -509,6 +513,8 @@ class dirstate(object):
         self._addpath(f, 'n', 0, -1, -1)
         if f in self._copymap:
             del self._copymap[f]
+        if f in self._nonnormalmap:
+            del self._nonnormalmap[f]
 
     def otherparent(self, f):
         '''Mark as coming from the other parent, always dirty.'''
@@ -544,6 +550,7 @@ class dirstate(object):
             elif entry[0] == 'n' and entry[2] == -2: # other parent
                 size = -2
         self._map[f] = dirstatetuple('r', 0, size, 0)
+        self._nonnormalmap[f] = dirstatetuple('r', 0, size, 0)
         if size == 0 and f in self._copymap:
             del self._copymap[f]
 
@@ -559,6 +566,8 @@ class dirstate(object):
             self._dirty = True
             self._droppath(f)
             del self._map[f]
+            if f in self._nonnormalmap:
+                del self._nonnormalmap[f]
 
     def _discoverpath(self, path, normed, ignoremissing, exists, storemap):
         if exists is None:
@@ -636,6 +645,7 @@ class dirstate(object):
 
     def clear(self):
         self._map = {}
+        self._nonnormalmap = {}
         if "_dirs" in self.__dict__:
             delattr(self, "_dirs")
         self._copymap = {}
@@ -660,6 +670,8 @@ class dirstate(object):
                 self._map[f] = dirstatetuple('n', mode, -1, 0)
             else:
                 self._map.pop(f, None)
+                if f in self._nonnormalmap:
+                    del self._nonnormalmap[f]
 
         self._pl = (parent, nullid)
         self._dirty = True
@@ -700,6 +712,7 @@ class dirstate(object):
             for f, e in dmap.iteritems():
                 if e[0] == 'n' and e[3] == now:
                     dmap[f] = dirstatetuple(e[0], e[1], e[2], -1)
+                    self._nonnormalmap[f] = dirstatetuple(e[0], e[1], e[2], -1)
 
             # emulate that all 'dirstate.normal' results are written out
             self._lastnormaltime = 0


More information about the Mercurial-devel mailing list