Mercurial > public > mercurial-scm > hg
comparison mercurial/dirstate.py @ 13754:ae157ca56cd5
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
author | Adrian Buehlmann <adrian@cadifra.com> |
---|---|
date | Thu, 24 Mar 2011 18:39:54 +0100 |
parents | 2d53cefb44e3 |
children | 7a73c406c0fd |
comparison
equal
deleted
inserted
replaced
13753:78a0a815fd41 | 13754:ae157ca56cd5 |
---|---|
283 def normal(self, f): | 283 def normal(self, f): |
284 '''Mark a file normal and clean.''' | 284 '''Mark a file normal and clean.''' |
285 self._dirty = True | 285 self._dirty = True |
286 self._addpath(f) | 286 self._addpath(f) |
287 s = os.lstat(self._join(f)) | 287 s = os.lstat(self._join(f)) |
288 self._map[f] = ('n', s.st_mode, s.st_size, int(s.st_mtime)) | 288 mtime = int(s.st_mtime) |
289 self._map[f] = ('n', s.st_mode, s.st_size, mtime) | |
289 if f in self._copymap: | 290 if f in self._copymap: |
290 del self._copymap[f] | 291 del self._copymap[f] |
291 | 292 |
292 # Right now, this file is clean: but if some code in this | 293 if mtime < self._lastnormaltime: |
293 # process modifies it without changing its size before the clock | 294 # We have already seen files with modification times from newer |
294 # ticks over to the next second, then it won't be clean anymore. | 295 # filesystem timeslots, so this timeslot is old and harmless. |
295 # So make sure that status() will look harder at it. | 296 # Comparing file times will work just fine for detecting modified |
296 if self._lastnormaltime < s.st_mtime: | 297 # files in status(). No special treatment is needed for f. |
297 self._lastnormaltime = s.st_mtime | 298 pass |
298 self._lastnormal = set() | 299 else: |
299 self._lastnormal.add(f) | 300 # f was modified most recently. |
301 if mtime > self._lastnormaltime: | |
302 # A new timeslot, which we've never seen before. | |
303 # We can drop the filenames of an older timeslot. | |
304 self._lastnormaltime = mtime | |
305 self._lastnormal = set() | |
306 # Remember f in _lastnormal for closer inspection on status(), | |
307 # to make sure we won't miss future size-preserving file content | |
308 # modifications that happen within the same timeslot. | |
309 self._lastnormal.add(f) | |
300 | 310 |
301 def normallookup(self, f): | 311 def normallookup(self, f): |
302 '''Mark a file normal, but possibly dirty.''' | 312 '''Mark a file normal, but possibly dirty.''' |
303 if self._pl[1] != nullid and f in self._map: | 313 if self._pl[1] != nullid and f in self._map: |
304 # if there is a merge going on and the file was either | 314 # if there is a merge going on and the file was either |