comparison mercurial/store.py @ 20885:f49d60fa40a5

fncache: clean up fncache during strips Previously the fncache was cleaned up at read time by noticing when it was out of sync. This caused writes to happen outside the scope of transactions and could have caused race conditions. With this change, we'll keep the fncache up-to-date as we go by removing old entries during repair.strip.
author Durham Goode <durham@fb.com>
date Mon, 24 Mar 2014 15:43:15 -0700
parents 2efdd186925d
children afe0b48ef2d7
comparison
equal deleted inserted replaced
20884:2efdd186925d 20885:f49d60fa40a5
341 pass 341 pass
342 342
343 def invalidatecaches(self): 343 def invalidatecaches(self):
344 pass 344 pass
345 345
346 def markremoved(self, fn):
347 pass
348
346 def __contains__(self, path): 349 def __contains__(self, path):
347 '''Checks if the store contains path''' 350 '''Checks if the store contains path'''
348 path = "/".join(("data", path)) 351 path = "/".join(("data", path))
349 # file? 352 # file?
350 if self.vfs.exists(path + ".i"): 353 if self.vfs.exists(path + ".i"):
419 self._load() 422 self._load()
420 if fn not in self.entries: 423 if fn not in self.entries:
421 self._dirty = True 424 self._dirty = True
422 self.entries.add(fn) 425 self.entries.add(fn)
423 426
427 def remove(self, fn):
428 if self.entries is None:
429 self._load()
430 try:
431 self.entries.remove(fn)
432 self._dirty = True
433 except KeyError:
434 pass
435
424 def __contains__(self, fn): 436 def __contains__(self, fn):
425 if self.entries is None: 437 if self.entries is None:
426 self._load() 438 self._load()
427 return fn in self.entries 439 return fn in self.entries
428 440
493 self.fncache.write(tr) 505 self.fncache.write(tr)
494 506
495 def invalidatecaches(self): 507 def invalidatecaches(self):
496 self.fncache.entries = None 508 self.fncache.entries = None
497 509
510 def markremoved(self, fn):
511 self.fncache.remove(fn)
512
498 def _exists(self, f): 513 def _exists(self, f):
499 ef = self.encode(f) 514 ef = self.encode(f)
500 try: 515 try:
501 self.getsize(ef) 516 self.getsize(ef)
502 return True 517 return True