Patchwork D5372: perfrevlogwrite: use progress helper on modern hg

login
register
mail settings
Submitter phabricator
Date Jan. 9, 2019, 8:40 p.m.
Message ID <111409ad7b6abba0226c98dfa5d4c0ff@localhost.localdomain>
Download mbox | patch
Permalink /patch/37592/
State Not Applicable
Headers show

Comments

phabricator - Jan. 9, 2019, 8:40 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGf36fd52dae8f: perfrevlogwrite: use progress helper on modern hg (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5372?vs=13109&id=13111

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

AFFECTED FILES
  contrib/perf.py

CHANGE DETAILS




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

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -1838,17 +1838,30 @@ 
         topic = 'adding'
         if runidx is not None:
             topic += ' (run #%d)' % runidx
+         # Support both old and new progress API
+        if util.safehasattr(ui, 'makeprogress'):
+            progress = ui.makeprogress(topic, unit='revs', total=total)
+            def updateprogress(pos):
+                progress.update(pos)
+            def completeprogress():
+                progress.complete()
+        else:
+            def updateprogress(pos):
+                ui.progress(topic, pos, unit='revs', total=total)
+            def completeprogress():
+                ui.progress(topic, None, unit='revs', total=total)
+
         for idx, rev in enumerate(revs):
-            ui.progress(topic, idx, unit='revs', total=total)
+            updateprogress(idx)
             addargs, addkwargs = _getrevisionseed(orig, rev, tr, source)
             if clearcaches:
                 dest.index.clearcaches()
                 dest.clearcaches()
             with timeone() as r:
                 dest.addrawrevision(*addargs, **addkwargs)
             timings.append((rev, r[0]))
-        ui.progress(topic, total, unit='revs', total=total)
-        ui.progress(topic, None, unit='revs', total=total)
+        updateprogress(total)
+        completeprogress()
     return timings
 
 def _getrevisionseed(orig, rev, tr, source):