[PATCH] dirstate: check mtime when adding to _lastnormal
adrian at cadifra.com
Thu Mar 24 13:57:19 CDT 2011
# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1300988394 -3600
# Node ID ae5ebb51a1b0c2ad40515d912c118fd14ae912c1
# Parent 366e014a1ded5b0c56f275e7be26688d741478bf
dirstate: check mtime when adding to _lastnormal
- consistently use mtime as mapped to dirstate granularity (needed for
filesystems like NTFS, which have sub-second resolution)
- no need to add files with mtime < _lastnormaltime
- improve comments
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
@@ -285,18 +285,28 @@ class dirstate(object):
self._dirty = True
s = os.lstat(self._join(f))
- self._map[f] = ('n', s.st_mode, s.st_size, int(s.st_mtime))
+ mtime = int(s.st_mtime)
+ self._map[f] = ('n', s.st_mode, s.st_size, mtime)
if f in self._copymap:
- # Right now, this file is clean: but if some code in this
- # process modifies it without changing its size before the clock
- # ticks over to the next second, then it won't be clean anymore.
- # So make sure that status() will look harder at it.
- if self._lastnormaltime < s.st_mtime:
- self._lastnormaltime = s.st_mtime
- self._lastnormal = set()
+ if mtime < self._lastnormaltime:
+ # We have already seen files with modification times from newer
+ # filesystem timeslots, so this timeslot is old and harmless.
+ # Comparing file times will work just fine for detecting modified
+ # files in status(). No special treatment is needed for f.
+ # f was modified most recently.
+ if mtime > self._lastnormaltime:
+ # A new timeslot, which we've never seen before.
+ # We can drop the filenames of an older timeslot.
+ self._lastnormaltime = mtime
+ self._lastnormal = set()
+ # Remember f in _lastnormal for closer inspection on status(),
+ # to make sure we won't miss future size-preserving file content
+ # modifications that happen within the same timeslot.
def normallookup(self, f):
'''Mark a file normal, but possibly dirty.'''
More information about the Mercurial-devel