[PATCH 2 of 9] verify: move cross-checking of changeset/manifest out of _crosscheckfiles()

Martin von Zweigbergk martinvonz at google.com
Fri Feb 12 22:38:26 UTC 2016


# HG changeset patch
# User Martin von Zweigbergk <martinvonz at google.com>
# Date 1454227856 28800
#      Sun Jan 31 00:10:56 2016 -0800
# Node ID ae50838573c112b79ef9ba231e168b0ca1fee6f9
# Parent  435b70f76264c170f59a46490364b4762ad2ac2f
verify: move cross-checking of changeset/manifest out of _crosscheckfiles()

Reasons:

 * _crosscheckfiles(), as the name suggests, is about checking that
   the set of files files mentioned in changesets match the set of
   files mentioned in the manifests.

 * The "checking" in _crosscheckfiles() looked rather strange, as it
   just emitted an error for *every* entry in mflinkrevs. The reason
   was that these were the entries remaining after the call to
   _verifymanifest(). Moving all the processing of mflinkrevs into
   _verifymanifest() makes it much clearer that it's the remaining
   entries that are a problem.

Functional change: progress is no longer reported for "crosschecking"
of missing manifest entries. Since the crosschecking phase takes a
tiny fraction of the verification, I don't think this is a
problem. Also, any reports of "changeset refers to unknown manifest"
will now come before "crosschecking files in changesets and
manifests".

diff --git a/mercurial/verify.py b/mercurial/verify.py
--- a/mercurial/verify.py
+++ b/mercurial/verify.py
@@ -147,9 +147,9 @@
         mflinkrevs, filelinkrevs = self._verifychangelog()

         filenodes = self._verifymanifest(mflinkrevs)
+        del mflinkrevs

-        self._crosscheckfiles(mflinkrevs, filelinkrevs, filenodes)
-        del mflinkrevs
+        self._crosscheckfiles(filelinkrevs, filenodes)

         totalfiles, filerevisions = self._verifyfiles(filenodes, filelinkrevs)

@@ -232,25 +232,24 @@
                 self.exc(lr, _("reading manifest delta %s") % short(n), inst)
         ui.progress(_('checking'), None)

+        if self.havemf:
+            for c, m in sorted([(c, m) for m in mflinkrevs
+                        for c in mflinkrevs[m]]):
+                if m == nullid:
+                    continue
+                self.err(c, _("changeset refers to unknown manifest %s") %
+                         short(m))
+
         return filenodes

-    def _crosscheckfiles(self, mflinkrevs, filelinkrevs, filenodes):
+    def _crosscheckfiles(self, filelinkrevs, filenodes):
         repo = self.repo
         ui = self.ui
         ui.status(_("crosschecking files in changesets and manifests\n"))

-        total = len(mflinkrevs) + len(filelinkrevs) + len(filenodes)
+        total = len(filelinkrevs) + len(filenodes)
         count = 0
         if self.havemf:
-            for c, m in sorted([(c, m) for m in mflinkrevs
-                                for c in mflinkrevs[m]]):
-                count += 1
-                if m == nullid:
-                    continue
-                ui.progress(_('crosschecking'), count, total=total)
-                self.err(c, _("changeset refers to unknown manifest %s") %
-                         short(m))
-
             for f in sorted(filelinkrevs):
                 count += 1
                 ui.progress(_('crosschecking'), count, total=total)


More information about the Mercurial-devel mailing list