Patchwork [4,of,7] verify: move file cross checking to it's own function

login
register
mail settings
Submitter Durham Goode
Date Jan. 6, 2016, 2:44 a.m.
Message ID <c76614d116682a35de6e.1452048288@dev8486.prn1.facebook.com>
Download mbox | patch
Permalink /patch/12552/
State Accepted
Delegated to: Martin von Zweigbergk
Headers show

Comments

Durham Goode - Jan. 6, 2016, 2:44 a.m.
# HG changeset patch
# User Durham Goode <durham@fb.com>
# Date 1452047511 28800
#      Tue Jan 05 18:31:51 2016 -0800
# Node ID c76614d116682a35de6e45b403f63a1acbdd34a6
# Parent  f7aac2bae0947baf0661d137cd38b1f2fbdcef62
verify: move file cross checking to it's own function

This is part of making verify more modular so extensions can hook into it.

Patch

diff --git a/mercurial/verify.py b/mercurial/verify.py
--- a/mercurial/verify.py
+++ b/mercurial/verify.py
@@ -154,9 +154,6 @@  class verifier(object):
             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 @@  class verifier(object):
                 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 @@  class verifier(object):
                     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 @@  class verifier(object):
 
         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