verify: print hint to run debugrebuildfncache
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 20 Jun 2015 20:11:53 -0700
changeset 26078 9d1e04f5dca72f39233bc663fd31866c3610f3d3
parent 26077 2882d6886919577588a3e782ac8344c18d97ca97
child 26079 af329a84310c3d784b3717395b6fc4a32ca736f2
push id16
push usergszorc@mozilla.com
push dateSat, 08 Aug 2015 03:14:19 +0000
verify: print hint to run debugrebuildfncache Corrupt fncache is now a recoverable operation. Inform the user how to recover from this warning.
mercurial/verify.py
tests/test-fncache.t
tests/test-verify.t
--- a/mercurial/verify.py
+++ b/mercurial/verify.py
@@ -214,16 +214,17 @@ def _verify(repo):
 
     storefiles = set()
     for f, f2, size in repo.store.datafiles():
         if not f:
             err(None, _("cannot decode filename '%s'") % f2)
         elif size > 0 or not revlogv1:
             storefiles.add(_normpath(f))
 
+    fncachewarned = False
     files = sorted(set(filenodes) | set(filelinkrevs))
     total = len(files)
     for i, f in enumerate(files):
         ui.progress(_('checking'), i, item=f, total=total)
         try:
             linkrevs = filelinkrevs[f]
         except KeyError:
             # in manifest but not in changelog
@@ -240,16 +241,17 @@ def _verify(repo):
             err(lr, _("broken revlog! (%s)") % e, f)
             continue
 
         for ff in fl.files():
             try:
                 storefiles.remove(ff)
             except KeyError:
                 warn(_(" warning: revlog '%s' not in fncache!") % ff)
+                fncachewarned = True
 
         checklog(fl, f, lr)
         seen = {}
         rp = None
         for i in fl:
             revisions += 1
             n = fl.node(i)
             lr = checkentry(fl, i, n, seen, linkrevs, f)
@@ -308,14 +310,17 @@ def _verify(repo):
 
     for f in storefiles:
         warn(_("warning: orphan revlog '%s'") % f)
 
     ui.status(_("%d files, %d changesets, %d total revisions\n") %
                    (len(files), len(cl), revisions))
     if warnings[0]:
         ui.warn(_("%d warnings encountered!\n") % warnings[0])
+    if fncachewarned:
+        ui.warn(_('hint: run "hg debugrebuildfncache" to recover from '
+                  'corrupt fncache\n'))
     if errors[0]:
         ui.warn(_("%d integrity errors encountered!\n") % errors[0])
         if badrevs:
             ui.warn(_("(first damaged changeset appears to be %d)\n")
                     % min(badrevs))
         return 1
--- a/tests/test-fncache.t
+++ b/tests/test-fncache.t
@@ -48,16 +48,33 @@ Testing verify:
   checking manifests
   crosschecking files in changesets and manifests
   checking files
    warning: revlog 'data/a.i' not in fncache!
    warning: revlog 'data/a.i.hg/c.i' not in fncache!
    warning: revlog 'data/a.i/b.i' not in fncache!
   3 files, 3 changesets, 3 total revisions
   3 warnings encountered!
+  hint: run "hg debugrebuildfncache" to recover from corrupt fncache
+
+Follow the hint to make sure it works
+
+  $ hg debugrebuildfncache
+  adding data/a.i
+  adding data/a.i.hg/c.i
+  adding data/a.i/b.i
+  3 items added, 0 removed from fncache
+
+  $ hg verify
+  checking changesets
+  checking manifests
+  crosschecking files in changesets and manifests
+  checking files
+  3 files, 3 changesets, 3 total revisions
+
   $ cd ..
 
 Non store repo:
 
   $ hg --config format.usestore=False init foo
   $ cd foo
   $ mkdir tst.d
   $ echo foo > tst.d/foo
--- a/tests/test-verify.t
+++ b/tests/test-verify.t
@@ -50,16 +50,17 @@ introduce some bugs in repo
    warning: revlog 'data/QUICK.txt.i' not in fncache!
    0: empty or missing QUICK.txt
    QUICK.txt@0: 88b857db8eba in manifests not found
    warning: revlog 'data/bar.txt.i' not in fncache!
    0: empty or missing bar.txt
    bar.txt@0: 256559129457 in manifests not found
   3 files, 1 changesets, 0 total revisions
   3 warnings encountered!
+  hint: run "hg debugrebuildfncache" to recover from corrupt fncache
   6 integrity errors encountered!
   (first damaged changeset appears to be 0)
   [1]
 
   $ cd ../../..
   $ cd ..
 
 test changelog without a manifest