D3809: synthrepo: use progress helper

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Tue Jun 19 00:45:17 UTC 2018


martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/synthrepo.py

CHANGE DETAILS

diff --git a/contrib/synthrepo.py b/contrib/synthrepo.py
--- a/contrib/synthrepo.py
+++ b/contrib/synthrepo.py
@@ -172,13 +172,10 @@
         revs = scmutil.revrange(repo, revs)
         revs.sort()
 
-        progress = ui.progress
-        _analyzing = _('analyzing')
-        _changesets = _('changesets')
-        _total = len(revs)
-
+        progress = ui.makeprogress(_('analyzing'), unit=_('changesets'),
+                                   total=len(revs))
         for i, rev in enumerate(revs):
-            progress(_analyzing, i, unit=_changesets, total=_total)
+            progress.update(i)
             ctx = repo[rev]
             pl = ctx.parents()
             pctx = pl[0]
@@ -338,7 +335,6 @@
 
     nevertouch = {'.hgsub', '.hgignore', '.hgtags'}
 
-    progress = ui.progress
     _synthesizing = _('synthesizing')
     _files = _('initial files')
     _changesets = _('changesets')
@@ -362,8 +358,9 @@
                 path = os.path.dirname(path)
             return True
 
+        progress = ui.makeprogress(_synthesizing, unit=_files, total=initcount)
         for i in xrange(0, initcount):
-            ui.progress(_synthesizing, i, unit=_files, total=initcount)
+            progress.update(i)
 
             path = pickpath()
             while not validpath(path):
@@ -378,7 +375,7 @@
         def filectxfn(repo, memctx, path):
             return context.memfilectx(repo, memctx, path, files[path])
 
-        ui.progress(_synthesizing, None)
+        progress.complete()
         message = 'synthesized wide repo with %d files' % (len(files),)
         mc = context.memctx(repo, [pctx.node(), nullid], message,
                             files, filectxfn, ui.username(),
@@ -394,8 +391,9 @@
     # Synthesize incremental revisions to the repository, adding repo depth.
     count = int(opts['count'])
     heads = set(map(repo.changelog.rev, repo.heads()))
+    progress = ui.makeprogress(_synthesizing, unit=_changesets, total=count)
     for i in xrange(count):
-        progress(_synthesizing, i, unit=_changesets, total=count)
+        progress.update(i)
 
         node = repo.changelog.node
         revs = len(repo)



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


More information about the Mercurial-devel mailing list