Show More
@@ -392,9 +392,7 b' def rebuildfncache(ui, repo):' | |||||
392 |
|
392 | |||
393 | with repo.lock(): |
|
393 | with repo.lock(): | |
394 | fnc = repo.store.fncache |
|
394 | fnc = repo.store.fncache | |
395 | # Trigger load of fncache. |
|
395 | fnc.ensureloaded(warn=ui.warn) | |
396 | if 'irrelevant' in fnc: |
|
|||
397 | pass |
|
|||
398 |
|
396 | |||
399 | oldentries = set(fnc.entries) |
|
397 | oldentries = set(fnc.entries) | |
400 | newentries = set() |
|
398 | newentries = set() |
@@ -458,7 +458,15 b' class fncache(object):' | |||||
458 | # set of new additions to fncache |
|
458 | # set of new additions to fncache | |
459 | self.addls = set() |
|
459 | self.addls = set() | |
460 |
|
460 | |||
461 |
def |
|
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 | '''fill the entries from the fncache file''' |
|
470 | '''fill the entries from the fncache file''' | |
463 | self._dirty = False |
|
471 | self._dirty = False | |
464 | try: |
|
472 | try: | |
@@ -482,19 +490,26 b' class fncache(object):' | |||||
482 | pass |
|
490 | pass | |
483 |
|
491 | |||
484 | if chunk: |
|
492 | if chunk: | |
485 |
|
|
493 | msg = _("fncache does not ends with a newline") | |
486 | hint=_("use 'hg debugrebuildfncache' to rebuild" |
|
494 | if warn: | |
487 | " the fncache")) |
|
495 | warn(msg + '\n') | |
488 | self._checkentries(fp) |
|
496 | else: | |
|
497 | raise error.Abort(msg, | |||
|
498 | hint=_("use 'hg debugrebuildfncache' to " | |||
|
499 | "rebuild the fncache")) | |||
|
500 | self._checkentries(fp, warn) | |||
489 | fp.close() |
|
501 | fp.close() | |
490 |
|
502 | |||
491 | def _checkentries(self, fp): |
|
503 | def _checkentries(self, fp, warn): | |
492 | """ make sure there is no empty string in entries """ |
|
504 | """ make sure there is no empty string in entries """ | |
493 | if '' in self.entries: |
|
505 | if '' in self.entries: | |
494 | fp.seek(0) |
|
506 | fp.seek(0) | |
495 | for n, line in enumerate(util.iterfile(fp)): |
|
507 | for n, line in enumerate(util.iterfile(fp)): | |
496 | if not line.rstrip('\n'): |
|
508 | if not line.rstrip('\n'): | |
497 | t = _('invalid entry in fncache, line %d') % (n + 1) |
|
509 | t = _('invalid entry in fncache, line %d') % (n + 1) | |
|
510 | if warn: | |||
|
511 | warn(t + '\n') | |||
|
512 | else: | |||
498 | raise error.Abort(t) |
|
513 | raise error.Abort(t) | |
499 |
|
514 | |||
500 | def write(self, tr): |
|
515 | def write(self, tr): |
@@ -435,16 +435,18 b' A single missing file should get restore' | |||||
435 | data/.bar.i |
|
435 | data/.bar.i | |
436 | data/foo.i |
|
436 | data/foo.i | |
437 |
|
437 | |||
438 |
debugrebuildfncache |
|
438 | debugrebuildfncache recovers from truncated line in fncache | |
439 |
|
439 | |||
440 | $ printf a > .hg/store/fncache |
|
440 | $ printf a > .hg/store/fncache | |
441 | $ hg debugrebuildfncache |
|
441 | $ hg debugrebuildfncache | |
442 |
|
|
442 | fncache does not ends with a newline | |
443 | (use 'hg debugrebuildfncache' to rebuild the fncache) |
|
443 | adding data/.bar.i | |
444 | [255] |
|
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 | $ cd .. |
|
451 | $ cd .. | |
450 |
|
452 |
General Comments 0
You need to be logged in to leave comments.
Login now