dirstate: add code to update the non-normal set
authorLaurent Charignon <lcharignon@fb.com>
Fri, 01 Jan 2016 23:40:54 +0100
changeset 27590 f2d0ada00257
parent 27589 3e4f9d78ebd4
child 27591 127cc7f78475
dirstate: add code to update the non-normal set Before this patch, we were only populating the non-normal set when parsing or packing the dirstate. This was not enough to keep the non-normal set 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 set when it should be updated. note: pack_dirstate changes the dmap and we have it keep it unchanged for retrocompatibility so we are forced to recompute the non-normal set after calling it.
mercurial/dirstate.py
--- a/mercurial/dirstate.py	Wed Dec 23 13:13:22 2015 -0800
+++ b/mercurial/dirstate.py	Fri Jan 01 23:40:54 2016 +0100
@@ -440,7 +440,7 @@
 
     def invalidate(self):
         for a in ("_map", "_copymap", "_filefoldmap", "_dirfoldmap", "_branch",
-                  "_pl", "_dirs", "_ignore"):
+                  "_pl", "_dirs", "_ignore", "_nonnormalset"):
             if a in self.__dict__:
                 delattr(self, a)
         self._lastnormaltime = 0
@@ -489,6 +489,8 @@
             self._dirs.addpath(f)
         self._dirty = True
         self._map[f] = dirstatetuple(state, mode, size, mtime)
+        if state != 'n' or mtime == -1:
+            self._nonnormalset.add(f)
 
     def normal(self, f):
         '''Mark a file normal and clean.'''
@@ -498,6 +500,8 @@
                       s.st_size & _rangemask, mtime & _rangemask)
         if f in self._copymap:
             del self._copymap[f]
+        if f in self._nonnormalset:
+            self._nonnormalset.remove(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
@@ -525,6 +529,8 @@
         self._addpath(f, 'n', 0, -1, -1)
         if f in self._copymap:
             del self._copymap[f]
+        if f in self._nonnormalset:
+            self._nonnormalset.remove(f)
 
     def otherparent(self, f):
         '''Mark as coming from the other parent, always dirty.'''
@@ -560,6 +566,7 @@
             elif entry[0] == 'n' and entry[2] == -2: # other parent
                 size = -2
         self._map[f] = dirstatetuple('r', 0, size, 0)
+        self._nonnormalset.add(f)
         if size == 0 and f in self._copymap:
             del self._copymap[f]
 
@@ -575,6 +582,8 @@
             self._dirty = True
             self._droppath(f)
             del self._map[f]
+            if f in self._nonnormalset:
+                self._nonnormalset.remove(f)
 
     def _discoverpath(self, path, normed, ignoremissing, exists, storemap):
         if exists is None:
@@ -652,6 +661,7 @@
 
     def clear(self):
         self._map = {}
+        self._nonnormalset = set()
         if "_dirs" in self.__dict__:
             delattr(self, "_dirs")
         self._copymap = {}
@@ -676,6 +686,8 @@
                 self._map[f] = dirstatetuple('n', mode, -1, 0)
             else:
                 self._map.pop(f, None)
+                if f in self._nonnormalset:
+                    self._nonnormalset.remove(f)
 
         self._pl = (parent, nullid)
         self._dirty = True
@@ -709,6 +721,7 @@
             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._nonnormalset.add(f)
 
             # emulate that all 'dirstate.normal' results are written out
             self._lastnormaltime = 0
@@ -743,6 +756,7 @@
                     break
 
         st.write(parsers.pack_dirstate(self._map, self._copymap, self._pl, now))
+        self._nonnormalset = nonnormalentries(self._map)
         st.close()
         self._lastnormaltime = 0
         self._dirty = self._dirtypl = False