Patchwork [5,of,7] verify: move manifest verification to it's own function

login
register
mail settings
Submitter Durham Goode
Date Jan. 6, 2016, 2:44 a.m.
Message ID <94e1449952e04acf0c28.1452048289@dev8486.prn1.facebook.com>
Download mbox | patch
Permalink /patch/12549/
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 1452047679 28800
#      Tue Jan 05 18:34:39 2016 -0800
# Node ID 94e1449952e04acf0c289892850ae167b1f57c3c
# Parent  c76614d116682a35de6e45b403f63a1acbdd34a6
verify: move manifest verification to it's own function

This makes verify more modular, making it easier for extensions to extend.
timeless - Jan. 6, 2016, 6:30 a.m.
Durham Goode wrote:
> verify: move manifest verification to it's own function

"its" :)

Patch

diff --git a/mercurial/verify.py b/mercurial/verify.py
--- a/mercurial/verify.py
+++ b/mercurial/verify.py
@@ -141,7 +141,6 @@  class verifier(object):
         badrevs = self.badrevs
         ui = repo.ui
         cl = repo.changelog
-        mf = repo.manifest
 
         if not repo.url().startswith('file:'):
             raise error.Abort(_("cannot verify bundle or remote repos"))
@@ -176,6 +175,32 @@  class verifier(object):
                 self.exc(i, _("unpacking changeset %s") % short(n), inst)
         ui.progress(_('checking'), None)
 
+        self._verifymanifest(mflinkrevs, filenodes)
+
+        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 _verifymanifest(self, mflinkrevs, filenodes):
+        repo = self.repo
+        ui = self.ui
+        mf = self.repo.manifest
+
         ui.status(_("checking manifests\n"))
         seen = {}
         if self.refersmf:
@@ -205,24 +230,7 @@  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
+        return mflinkrevs
 
     def _crosscheckfiles(self, mflinkrevs, filelinkrevs, filenodes):
         repo = self.repo