Skip to content
Snippets Groups Projects
Commit ae157ca56cd5 authored by Adrian Buehlmann's avatar Adrian Buehlmann
Browse files

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
parent 78a0a815fd41
No related branches found
No related tags found
No related merge requests found
......@@ -285,7 +285,8 @@
self._dirty = True
self._addpath(f)
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:
del self._copymap[f]
......@@ -289,14 +290,23 @@
if f in self._copymap:
del self._copymap[f]
# 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()
self._lastnormal.add(f)
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.
pass
else:
# 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.
self._lastnormal.add(f)
def normallookup(self, f):
'''Mark a file normal, but possibly dirty.'''
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment