##// END OF EJS Templates
fncache: make debugrebuildfncache not fail on broken fncache...
Valentin Gatien-Baron -
r42960:f59f8a5e stable
parent child Browse files
Show More
@@ -392,9 +392,7 b' def rebuildfncache(ui, repo):'
392 392
393 393 with repo.lock():
394 394 fnc = repo.store.fncache
395 # Trigger load of fncache.
396 if 'irrelevant' in fnc:
397 pass
395 fnc.ensureloaded(warn=ui.warn)
398 396
399 397 oldentries = set(fnc.entries)
400 398 newentries = set()
@@ -458,7 +458,15 b' class fncache(object):'
458 458 # set of new additions to fncache
459 459 self.addls = set()
460 460
461 def _load(self):
461 def ensureloaded(self, warn=None):
462 '''read the fncache file if not already read.
463
464 If the file on disk is corrupted, raise. If warn is provided,
465 warn and keep going instead.'''
466 if self.entries is None:
467 self._load(warn)
468
469 def _load(self, warn=None):
462 470 '''fill the entries from the fncache file'''
463 471 self._dirty = False
464 472 try:
@@ -482,20 +490,27 b' class fncache(object):'
482 490 pass
483 491
484 492 if chunk:
485 raise error.Abort(_("fncache does not ends with a newline"),
486 hint=_("use 'hg debugrebuildfncache' to rebuild"
487 " the fncache"))
488 self._checkentries(fp)
493 msg = _("fncache does not ends with a newline")
494 if warn:
495 warn(msg + '\n')
496 else:
497 raise error.Abort(msg,
498 hint=_("use 'hg debugrebuildfncache' to "
499 "rebuild the fncache"))
500 self._checkentries(fp, warn)
489 501 fp.close()
490 502
491 def _checkentries(self, fp):
503 def _checkentries(self, fp, warn):
492 504 """ make sure there is no empty string in entries """
493 505 if '' in self.entries:
494 506 fp.seek(0)
495 507 for n, line in enumerate(util.iterfile(fp)):
496 508 if not line.rstrip('\n'):
497 509 t = _('invalid entry in fncache, line %d') % (n + 1)
498 raise error.Abort(t)
510 if warn:
511 warn(t + '\n')
512 else:
513 raise error.Abort(t)
499 514
500 515 def write(self, tr):
501 516 if self._dirty:
@@ -435,16 +435,18 b' A single missing file should get restore'
435 435 data/.bar.i
436 436 data/foo.i
437 437
438 debugrebuildfncache fails to recover from truncated line in fncache
438 debugrebuildfncache recovers from truncated line in fncache
439 439
440 440 $ printf a > .hg/store/fncache
441 441 $ hg debugrebuildfncache
442 abort: fncache does not ends with a newline
443 (use 'hg debugrebuildfncache' to rebuild the fncache)
444 [255]
442 fncache does not ends with a newline
443 adding data/.bar.i
444 adding data/foo.i
445 2 items added, 0 removed from fncache
445 446
446 447 $ cat .hg/store/fncache | sort
447 a
448 data/.bar.i
449 data/foo.i
448 450
449 451 $ cd ..
450 452
General Comments 0
You need to be logged in to leave comments. Login now