changeset 27448:f4f2179077cb

verify: move exc() function onto class This is part of an effort to make verify more modular so extensions can hook into it.
author Durham Goode <durham@fb.com>
date Fri, 18 Dec 2015 16:42:39 -0800
parents d1b91c10ce70
children 77c51a56392e
files mercurial/verify.py
diffstat 1 files changed, 13 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/verify.py	Fri Dec 18 16:42:39 2015 -0800
+++ b/mercurial/verify.py	Fri Dec 18 16:42:39 2015 -0800
@@ -75,6 +75,14 @@
         self.ui.warn(" " + msg + "\n")
         self.errors[0] += 1
 
+    def exc(self, linkrev, msg, inst, filename=None):
+        if isinstance(inst, KeyboardInterrupt):
+            self.ui.warn(_("interrupted"))
+            raise
+        if not str(inst):
+            inst = repr(inst)
+        self.err(linkrev, "%s: %s" % (msg, inst), filename)
+
     def verify(self):
         repo = self.repo
         mflinkrevs = {}
@@ -92,16 +100,6 @@
         if not repo.url().startswith('file:'):
             raise error.Abort(_("cannot verify bundle or remote repos"))
 
-
-        def exc(linkrev, msg, inst, filename=None):
-            if isinstance(inst, KeyboardInterrupt):
-                ui.warn(_("interrupted"))
-                raise
-            if not str(inst):
-                inst = repr(inst)
-            self.err(linkrev, "%s: %s" % (msg, inst), filename)
-
-
         def checklog(obj, name, linkrev):
             if not len(obj) and (havecl or havemf):
                 self.err(linkrev, _("empty or missing %s") % name)
@@ -148,7 +146,7 @@
                     self.err(lr, _("unknown parent 2 %s of %s") %
                              (short(p2), short(node)), f)
             except Exception as inst:
-                exc(lr, _("checking parents of %s") % short(node), inst, f)
+                self.exc(lr, _("checking parents of %s") % short(node), inst, f)
 
             if node in seen:
                 self.err(lr, _("duplicate revision %d (%d)") %
@@ -186,7 +184,7 @@
                         filelinkrevs.setdefault(_normpath(f), []).append(i)
             except Exception as inst:
                 self.refersmf = True
-                exc(i, _("unpacking changeset %s") % short(n), inst)
+                self.exc(i, _("unpacking changeset %s") % short(n), inst)
         ui.progress(_('checking'), None)
 
         ui.status(_("checking manifests\n"))
@@ -214,7 +212,7 @@
                             filenodes.setdefault(
                                 _normpath(f), {}).setdefault(fn, lr)
             except Exception as inst:
-                exc(lr, _("reading manifest delta %s") % short(n), inst)
+                self.exc(lr, _("reading manifest delta %s") % short(n), inst)
         ui.progress(_('checking'), None)
 
         ui.status(_("crosschecking files in changesets and manifests\n"))
@@ -316,7 +314,7 @@
                     if ui.config("censor", "policy", "abort") == "abort":
                         self.err(lr, _("censored file data"), f)
                 except Exception as inst:
-                    exc(lr, _("unpacking %s") % short(n), inst, f)
+                    self.exc(lr, _("unpacking %s") % short(n), inst, f)
 
                 # check renames
                 try:
@@ -342,7 +340,7 @@
                         else:
                             fl2.rev(rp[1])
                 except Exception as inst:
-                    exc(lr, _("checking rename of %s") % short(n), inst, f)
+                    self.exc(lr, _("checking rename of %s") % short(n), inst, f)
 
             # cross-check
             if f in filenodes: