changeset 6026:217828aa0e29

pullbundle: use ui.makeprogress() directly without 4.6 compatibility
author Anton Shestakov <av6@dwimlabs.net>
date Sat, 04 Sep 2021 19:19:25 +0300
parents b1529f0a30ce
children 9e27494ac618
files hgext3rd/pullbundle.py
diffstat 1 files changed, 3 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/pullbundle.py	Sat Sep 04 19:17:46 2021 +0300
+++ b/hgext3rd/pullbundle.py	Sat Sep 04 19:19:25 2021 +0300
@@ -87,7 +87,6 @@
     node as nodemod,
     registrar,
     scmutil,
-    ui as uimod,
     util,
 )
 
@@ -513,10 +512,11 @@
 
     repo.ui.write(b"gathering %d sample pulls within %d revisions\n"
                   % (count, len(actionrevs)))
+    progress = repo.ui.makeprogress(b'gathering data', b'pulls', count)
     if 1 < min_cache:
         repo.ui.write(b"  not caching ranges smaller than %d changesets\n" % min_cache)
     for i in range(count):
-        progress(repo.ui, b'gathering data', i, total=count)
+        progress.update(i)
         outgoing = takeonesample(repo, actionrevs)
         ranges = sliceoutgoing(repo, outgoing)
         hitranges = 0
@@ -540,7 +540,7 @@
                  hitranges,
                  )
         pullstats.append(stats)
-    progress(repo.ui, b'gathering data', None)
+    progress.complete()
 
     sizes = []
     changesmissing = []
@@ -634,18 +634,6 @@
     data[b'name'] = name
     return STATSFORMAT % data
 
-# hg <= 4.6 (bec1212eceaa)
-if util.safehasattr(uimod.ui, 'makeprogress'):
-    def progress(ui, topic, pos, item=b"", unit=b"", total=None):
-        progress = ui.makeprogress(topic, unit, total)
-        if pos is not None:
-            progress.update(pos, item=item)
-        else:
-            progress.complete()
-else:
-    def progress(ui, topic, pos, item=b"", unit=b"", total=None):
-        ui.progress(topic, pos, item, unit, total)
-
 # nodemap.get and index.[has_node|rev|get_rev]
 # hg <= 5.2 (02802fa87b74)
 def getgetrev(cl):