changeset 27645:df8973e1fb45

verify: move file cross checking to its own function This is part of making verify more modular so extensions can hook into it.
author Durham Goode <durham@fb.com>
date Tue, 05 Jan 2016 18:31:51 -0800
parents 331e5c28f5f0
children 8f43793382c6
files mercurial/verify.py
diffstat 1 files changed, 24 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/verify.py	Tue Jan 05 18:28:46 2016 -0800
+++ b/mercurial/verify.py	Tue Jan 05 18:31:51 2016 -0800
@@ -154,9 +154,6 @@
             ui.status(_("repository uses revlog format %d\n") %
                            (revlogv1 and 1 or 0))
 
-        havecl = self.havecl
-        havemf = self.havemf
-
         ui.status(_("checking changesets\n"))
         seen = {}
         self.checklog(cl, "changelog", 0)
@@ -208,11 +205,33 @@
                 self.exc(lr, _("reading manifest delta %s") % short(n), inst)
         ui.progress(_('checking'), None)
 
+        self._crosscheckfiles(mflinkrevs, filelinkrevs, filenodes)
+
+        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 _crosscheckfiles(self, mflinkrevs, filelinkrevs, filenodes):
+        repo = self.repo
+        ui = self.ui
         ui.status(_("crosschecking files in changesets and manifests\n"))
 
         total = len(mflinkrevs) + len(filelinkrevs) + len(filenodes)
         count = 0
-        if havemf:
+        if self.havemf:
             for c, m in sorted([(c, m) for m in mflinkrevs
                                 for c in mflinkrevs[m]]):
                 count += 1
@@ -230,7 +249,7 @@
                     lr = filelinkrevs[f][0]
                     self.err(lr, _("in changeset but not in manifest"), f)
 
-        if havecl:
+        if self.havecl:
             for f in sorted(filenodes):
                 count += 1
                 ui.progress(_('crosschecking'), count, total=total)
@@ -244,23 +263,6 @@
 
         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