hgext3rd/pullbundle.py
changeset 5044 b9179a034005
parent 5034 1015a1dbaf7c
child 5046 ebd0f5c6098f
--- a/hgext3rd/pullbundle.py	Thu Dec 19 18:01:15 2019 +0700
+++ b/hgext3rd/pullbundle.py	Thu Dec 19 18:02:31 2019 +0700
@@ -87,6 +87,7 @@
     node as nodemod,
     registrar,
     scmutil,
+    ui as uimod,
     util,
 )
 
@@ -508,7 +509,7 @@
     if 1 < min_cache:
         repo.ui.write(b"  not caching ranges smaller than %d changesets\n" % min_cache)
     for i in range(count):
-        repo.ui.progress(b'gathering data', i, total=count)
+        progress(repo.ui, b'gathering data', i, total=count)
         outgoing = takeonesample(repo, actionrevs)
         ranges = sliceoutgoing(repo, outgoing)
         hitranges = 0
@@ -532,7 +533,7 @@
                  hitranges,
                  )
         pullstats.append(stats)
-    repo.ui.progress(b'gathering data', None)
+    progress(repo.ui, b'gathering data', None)
 
     sizes = []
     changesmissing = []
@@ -624,6 +625,18 @@
 def fmtdist(name, data):
     return STATSFORMAT.format(name=name, **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.3 (02802fa87b74)
 def getgetrev(cl):