##// END OF EJS Templates
dirstate: eliminate _lastnormal set...
Adrian Buehlmann -
r13763:7a73c406 default
parent child Browse files
Show More
@@ -49,7 +49,6 b' class dirstate(object):'
49 self._rootdir = os.path.join(root, '')
49 self._rootdir = os.path.join(root, '')
50 self._dirty = False
50 self._dirty = False
51 self._dirtypl = False
51 self._dirtypl = False
52 self._lastnormal = set() # files believed to be normal
53 self._lastnormaltime = None
52 self._lastnormaltime = None
54 self._ui = ui
53 self._ui = ui
55
54
@@ -238,7 +237,6 b' class dirstate(object):'
238 "_ignore"):
237 "_ignore"):
239 if a in self.__dict__:
238 if a in self.__dict__:
240 delattr(self, a)
239 delattr(self, a)
241 self._lastnormal = set()
242 self._lastnormaltime = None
240 self._lastnormaltime = None
243 self._dirty = False
241 self._dirty = False
244
242
@@ -289,24 +287,11 b' class dirstate(object):'
289 self._map[f] = ('n', s.st_mode, s.st_size, mtime)
287 self._map[f] = ('n', s.st_mode, s.st_size, mtime)
290 if f in self._copymap:
288 if f in self._copymap:
291 del self._copymap[f]
289 del self._copymap[f]
292
293 if mtime < self._lastnormaltime:
294 # We have already seen files with modification times from newer
295 # filesystem timeslots, so this timeslot is old and harmless.
296 # Comparing file times will work just fine for detecting modified
297 # files in status(). No special treatment is needed for f.
298 pass
299 else:
300 # f was modified most recently.
301 if mtime > self._lastnormaltime:
290 if mtime > self._lastnormaltime:
302 # A new timeslot, which we've never seen before.
291 # Remember the most recent modification timeslot for status(),
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
292 # to make sure we won't miss future size-preserving file content
308 # modifications that happen within the same timeslot.
293 # modifications that happen within the same timeslot.
309 self._lastnormal.add(f)
294 self._lastnormaltime = mtime
310
295
311 def normallookup(self, f):
296 def normallookup(self, f):
312 '''Mark a file normal, but possibly dirty.'''
297 '''Mark a file normal, but possibly dirty.'''
@@ -331,7 +316,6 b' class dirstate(object):'
331 self._map[f] = ('n', 0, -1, -1)
316 self._map[f] = ('n', 0, -1, -1)
332 if f in self._copymap:
317 if f in self._copymap:
333 del self._copymap[f]
318 del self._copymap[f]
334 self._lastnormal.discard(f)
335
319
336 def otherparent(self, f):
320 def otherparent(self, f):
337 '''Mark as coming from the other parent, always dirty.'''
321 '''Mark as coming from the other parent, always dirty.'''
@@ -343,7 +327,6 b' class dirstate(object):'
343 self._map[f] = ('n', 0, -2, -1)
327 self._map[f] = ('n', 0, -2, -1)
344 if f in self._copymap:
328 if f in self._copymap:
345 del self._copymap[f]
329 del self._copymap[f]
346 self._lastnormal.discard(f)
347
330
348 def add(self, f):
331 def add(self, f):
349 '''Mark a file added.'''
332 '''Mark a file added.'''
@@ -352,7 +335,6 b' class dirstate(object):'
352 self._map[f] = ('a', 0, -1, -1)
335 self._map[f] = ('a', 0, -1, -1)
353 if f in self._copymap:
336 if f in self._copymap:
354 del self._copymap[f]
337 del self._copymap[f]
355 self._lastnormal.discard(f)
356
338
357 def remove(self, f):
339 def remove(self, f):
358 '''Mark a file removed.'''
340 '''Mark a file removed.'''
@@ -369,7 +351,6 b' class dirstate(object):'
369 self._map[f] = ('r', 0, size, 0)
351 self._map[f] = ('r', 0, size, 0)
370 if size == 0 and f in self._copymap:
352 if size == 0 and f in self._copymap:
371 del self._copymap[f]
353 del self._copymap[f]
372 self._lastnormal.discard(f)
373
354
374 def merge(self, f):
355 def merge(self, f):
375 '''Mark a file merged.'''
356 '''Mark a file merged.'''
@@ -379,7 +360,6 b' class dirstate(object):'
379 self._map[f] = ('m', s.st_mode, s.st_size, int(s.st_mtime))
360 self._map[f] = ('m', s.st_mode, s.st_size, int(s.st_mtime))
380 if f in self._copymap:
361 if f in self._copymap:
381 del self._copymap[f]
362 del self._copymap[f]
382 self._lastnormal.discard(f)
383
363
384 def forget(self, f):
364 def forget(self, f):
385 '''Forget a file.'''
365 '''Forget a file.'''
@@ -389,7 +369,6 b' class dirstate(object):'
389 del self._map[f]
369 del self._map[f]
390 except KeyError:
370 except KeyError:
391 self._ui.warn(_("not in dirstate: %s\n") % f)
371 self._ui.warn(_("not in dirstate: %s\n") % f)
392 self._lastnormal.discard(f)
393
372
394 def _normalize(self, path, isknown):
373 def _normalize(self, path, isknown):
395 normed = os.path.normcase(path)
374 normed = os.path.normcase(path)
@@ -426,7 +405,6 b' class dirstate(object):'
426 delattr(self, "_dirs")
405 delattr(self, "_dirs")
427 self._copymap = {}
406 self._copymap = {}
428 self._pl = [nullid, nullid]
407 self._pl = [nullid, nullid]
429 self._lastnormal = set()
430 self._lastnormaltime = None
408 self._lastnormaltime = None
431 self._dirty = True
409 self._dirty = True
432
410
@@ -475,7 +453,6 b' class dirstate(object):'
475 write(f)
453 write(f)
476 st.write(cs.getvalue())
454 st.write(cs.getvalue())
477 st.rename()
455 st.rename()
478 self._lastnormal = set()
479 self._lastnormaltime = None
456 self._lastnormaltime = None
480 self._dirty = self._dirtypl = False
457 self._dirty = self._dirtypl = False
481
458
@@ -691,7 +668,6 b' class dirstate(object):'
691 radd = removed.append
668 radd = removed.append
692 dadd = deleted.append
669 dadd = deleted.append
693 cadd = clean.append
670 cadd = clean.append
694 lastnormal = self._lastnormal.__contains__
695
671
696 lnkkind = stat.S_IFLNK
672 lnkkind = stat.S_IFLNK
697
673
@@ -714,6 +690,7 b' class dirstate(object):'
714 # lines are an expansion of "islink => checklink"
690 # lines are an expansion of "islink => checklink"
715 # where islink means "is this a link?" and checklink
691 # where islink means "is this a link?" and checklink
716 # means "can we check links?".
692 # means "can we check links?".
693 mtime = int(st.st_mtime)
717 if (size >= 0 and
694 if (size >= 0 and
718 (size != st.st_size
695 (size != st.st_size
719 or ((mode ^ st.st_mode) & 0100 and self._checkexec))
696 or ((mode ^ st.st_mode) & 0100 and self._checkexec))
@@ -721,20 +698,14 b' class dirstate(object):'
721 or size == -2 # other parent
698 or size == -2 # other parent
722 or fn in self._copymap):
699 or fn in self._copymap):
723 madd(fn)
700 madd(fn)
724 elif (time != int(st.st_mtime)
701 elif (mtime != time
725 and (mode & lnkkind != lnkkind or self._checklink)):
702 and (mode & lnkkind != lnkkind or self._checklink)):
726 ladd(fn)
703 ladd(fn)
727 elif lastnormal(fn):
704 elif mtime == self._lastnormaltime:
728 # If previously in this process we recorded that
705 # fn may have been changed in the same timeslot without
729 # this file is clean, think twice: intervening code
706 # changing its size. This can happen if we quickly do
730 # may have modified the file in the same second
707 # multiple commits in a single transaction.
731 # without changing its size. So force caller to
708 # Force lookup, so we don't miss such a racy file change.
732 # check file contents. Because we're not updating
733 # self._map, this only affects the current process.
734 # That should be OK because this mainly affects
735 # multiple commits in the same process, and each
736 # commit by definition makes the committed files
737 # clean.
738 ladd(fn)
709 ladd(fn)
739 elif listclean:
710 elif listclean:
740 cadd(fn)
711 cadd(fn)
General Comments 0
You need to be logged in to leave comments. Login now