verify: move filelog verification to its own function
authorDurham Goode <durham@fb.com>
Tue, 05 Jan 2016 18:28:46 -0800
changeset 27644 331e5c28f5f0
parent 27643 62ce86fcfd06
child 27645 df8973e1fb45
verify: move filelog verification to its own function This makes verify more modular so extensions can hook in more easily.
mercurial/verify.py
--- a/mercurial/verify.py	Tue Jan 05 17:08:14 2016 -0800
+++ b/mercurial/verify.py	Tue Jan 05 18:28:46 2016 -0800
@@ -142,7 +142,6 @@
         ui = repo.ui
         cl = repo.changelog
         mf = repo.manifest
-        lrugetctx = self.lrugetctx
 
         if not repo.url().startswith('file:'):
             raise error.Abort(_("cannot verify bundle or remote repos"))
@@ -245,6 +244,29 @@
 
         ui.progress(_('crosschecking'), None)
 
+        totalfiles, filerevisions = self._verifyfiles(filenodes, filelinkrevs)
+        revisions += filerevisions
+
+        ui.status(_("%d files, %d changesets, %d total revisions\n") %
+                       (totalfiles, len(cl), revisions))
+        if self.warnings:
+            ui.warn(_("%d warnings encountered!\n") % self.warnings)
+        if self.fncachewarned:
+            ui.warn(_('hint: run "hg debugrebuildfncache" to recover from '
+                      'corrupt fncache\n'))
+        if self.errors:
+            ui.warn(_("%d integrity errors encountered!\n") % self.errors)
+            if badrevs:
+                ui.warn(_("(first damaged changeset appears to be %d)\n")
+                        % min(badrevs))
+            return 1
+
+    def _verifyfiles(self, filenodes, filelinkrevs):
+        repo = self.repo
+        ui = self.ui
+        lrugetctx = self.lrugetctx
+        revlogv1 = self.revlogv1
+        havemf = self.havemf
         ui.status(_("checking files\n"))
 
         storefiles = set()
@@ -256,6 +278,7 @@
 
         files = sorted(set(filenodes) | set(filelinkrevs))
         total = len(files)
+        revisions = 0
         for i, f in enumerate(files):
             ui.progress(_('checking'), i, item=f, total=total)
             try:
@@ -347,16 +370,4 @@
         for f in storefiles:
             self.warn(_("warning: orphan revlog '%s'") % f)
 
-        ui.status(_("%d files, %d changesets, %d total revisions\n") %
-                       (len(files), len(cl), revisions))
-        if self.warnings:
-            ui.warn(_("%d warnings encountered!\n") % self.warnings)
-        if self.fncachewarned:
-            ui.warn(_('hint: run "hg debugrebuildfncache" to recover from '
-                      'corrupt fncache\n'))
-        if self.errors:
-            ui.warn(_("%d integrity errors encountered!\n") % self.errors)
-            if badrevs:
-                ui.warn(_("(first damaged changeset appears to be %d)\n")
-                        % min(badrevs))
-            return 1
+        return len(files), revisions