# HG changeset patch # User Anton Shestakov # Date 1576753351 -25200 # Node ID b9179a034005f65af98a8490af9c85b9ff7bf67f # Parent db341dafdccb3cc4a1daa82563c7177814a4f6a8 pullbundle: compatibility for progress in hg <= 4.6 diff -r db341dafdccb -r b9179a034005 hgext3rd/pullbundle.py --- 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):