[PATCH 3 of 5 V4] dirstate: add code to update the non-normal map when it should be
Laurent Charignon
lcharignon at fb.com
Thu Dec 17 13:34:26 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 7102d975a6179468b3812739e90939df2d8dbed4
# Parent bdf09a71be9563912b94b230537c0905de90f865
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
@@ -419,7 +419,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
@@ -468,6 +468,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.'''
@@ -477,6 +479,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
@@ -504,6 +508,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.'''
@@ -539,6 +545,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]
@@ -554,6 +561,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:
@@ -631,6 +640,7 @@ class dirstate(object):
def clear(self):
self._map = {}
+ self._nonnormalmap = {}
if "_dirs" in self.__dict__:
delattr(self, "_dirs")
self._copymap = {}
@@ -655,6 +665,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
@@ -695,6 +707,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