Patchwork D3798: verify: use progress helper

login
register
mail settings
Submitter phabricator
Date June 18, 2018, 8:26 p.m.
Message ID <e5a5da4944c15848e0cb697d194643fb@localhost.localdomain>
Download mbox | patch
Permalink /patch/32304/
State Not Applicable
Headers show

Comments

phabricator - June 18, 2018, 8:26 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG1249475f0bd6: verify: use progress helper (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3798?vs=9192&id=9200

REVISION DETAIL
  https://phab.mercurial-scm.org/D3798

AFFECTED FILES
  mercurial/verify.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers, pulkit
Cc: mercurial-devel

Patch

diff --git a/mercurial/verify.py b/mercurial/verify.py
--- a/mercurial/verify.py
+++ b/mercurial/verify.py
@@ -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,28 +305,26 @@ 
         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)
                         lr = min([fl.linkrev(fl.rev(n)) for n in filenodes[f]])
                     except Exception:
                         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):