changeset 38397:1249475f0bd6

verify: use progress helper Differential Revision: https://phab.mercurial-scm.org/D3798
author Martin von Zweigbergk <martinvonz@google.com>
date Sun, 17 Jun 2018 23:28:00 -0700
parents 0ddbe03c5aaa
children f273b768b60f
files mercurial/verify.py
diffstat 1 files changed, 16 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/verify.py	Sun Jun 17 23:35:49 2018 -0700
+++ b/mercurial/verify.py	Sun Jun 17 23:28:00 2018 -0700
@@ -178,9 +178,10 @@
         filelinkrevs = {}
         seen = {}
         self.checklog(cl, "changelog", 0)
-        total = len(repo)
+        progress = ui.makeprogress(_('checking'), unit=_('changesets'),
+                                   total=len(repo))
         for i in repo:
-            ui.progress(_('checking'), i, total=total, unit=_('changesets'))
+            progress.update(i)
             n = cl.node(i)
             self.checkentry(cl, i, n, seen, [i], "changelog")
 
@@ -195,7 +196,7 @@
             except Exception as inst:
                 self.refersmf = True
                 self.exc(i, _("unpacking changeset %s") % short(n), inst)
-        ui.progress(_('checking'), None)
+        progress.complete()
         return mflinkrevs, filelinkrevs
 
     def _verifymanifest(self, mflinkrevs, dir="", storefiles=None,
@@ -223,10 +224,11 @@
             # Do not check manifest if there are only changelog entries with
             # null manifests.
             self.checklog(mf, label, 0)
-        total = len(mf)
+        progress = ui.makeprogress(_('checking'), unit=_('manifests'),
+                                   total=len(mf))
         for i in mf:
             if not dir:
-                ui.progress(_('checking'), i, total=total, unit=_('manifests'))
+                progress.update(i)
             n = mf.node(i)
             lr = self.checkentry(mf, i, n, seen, mflinkrevs.get(n, []), label)
             if n in mflinkrevs:
@@ -257,7 +259,7 @@
             except Exception as inst:
                 self.exc(lr, _("reading delta %s") % short(n), inst, label)
         if not dir:
-            ui.progress(_('checking'), None)
+            progress.complete()
 
         if self.havemf:
             for c, m in sorted([(c, m) for m in mflinkrevs
@@ -303,19 +305,17 @@
         ui.status(_("crosschecking files in changesets and manifests\n"))
 
         total = len(filelinkrevs) + len(filenodes)
-        count = 0
+        progress = ui.makeprogress(_('crosschecking'), total=total)
         if self.havemf:
             for f in sorted(filelinkrevs):
-                count += 1
-                ui.progress(_('crosschecking'), count, total=total)
+                progress.increment()
                 if f not in filenodes:
                     lr = filelinkrevs[f][0]
                     self.err(lr, _("in changeset but not in manifest"), f)
 
         if self.havecl:
             for f in sorted(filenodes):
-                count += 1
-                ui.progress(_('crosschecking'), count, total=total)
+                progress.increment()
                 if f not in filelinkrevs:
                     try:
                         fl = repo.file(f)
@@ -324,7 +324,7 @@
                         lr = None
                     self.err(lr, _("in manifest but not in changeset"), f)
 
-        ui.progress(_('crosschecking'), None)
+        progress.complete()
 
     def _verifyfiles(self, filenodes, filelinkrevs):
         repo = self.repo
@@ -342,10 +342,11 @@
                 storefiles.add(_normpath(f))
 
         files = sorted(set(filenodes) | set(filelinkrevs))
-        total = len(files)
         revisions = 0
+        progress = ui.makeprogress(_('checking'), unit=_('files'),
+                                   total=len(files))
         for i, f in enumerate(files):
-            ui.progress(_('checking'), i, item=f, total=total, unit=_('files'))
+            progress.update(i, item=f)
             try:
                 linkrevs = filelinkrevs[f]
             except KeyError:
@@ -479,7 +480,7 @@
                 for lr, node in sorted(fns):
                     self.err(lr, _("manifest refers to unknown revision %s") %
                              short(node), f)
-        ui.progress(_('checking'), None)
+        progress.complete()
 
         if self.warnorphanstorefiles:
             for f in sorted(storefiles):