[PATCH 3 of 7 V6] dirstate: add code to update the non-normal set
Laurent Charignon
lcharignon at fb.com
Mon Dec 21 18:33:12 CST 2015
# HG changeset patch
# User Laurent Charignon <lcharignon at fb.com>
# Date 1450743845 28800
# Mon Dec 21 16:24:05 2015 -0800
# Node ID 1be21e4798cd66383e8f63eafe84a3e32ef4b8d9
# Parent d7d4f75cce20bd0466fffae5c9214835833d1e0f
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.
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -425,7 +425,7 @@ class dirstate(object):
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
@@ -474,6 +474,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._nonnormalset.add(f)
def normal(self, f):
'''Mark a file normal and clean.'''
@@ -483,6 +485,8 @@ class dirstate(object):
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
@@ -510,6 +514,8 @@ class dirstate(object):
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.'''
@@ -545,6 +551,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._nonnormalset.add(f)
if size == 0 and f in self._copymap:
del self._copymap[f]
@@ -560,6 +567,8 @@ class dirstate(object):
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:
@@ -637,6 +646,7 @@ class dirstate(object):
def clear(self):
self._map = {}
+ self._nonnormalset = set()
if "_dirs" in self.__dict__:
delattr(self, "_dirs")
self._copymap = {}
@@ -661,6 +671,8 @@ class dirstate(object):
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
@@ -694,6 +706,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._nonnormalset.add(f)
# emulate that all 'dirstate.normal' results are written out
self._lastnormaltime = 0
More information about the Mercurial-devel
mailing list