comparison hgext3rd/pullbundle.py @ 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 18aa756353a7
children 6b619b4edbbe
comparison
equal deleted inserted replaced
6025:b1529f0a30ce 6026:217828aa0e29
85 exchange, 85 exchange,
86 narrowspec, 86 narrowspec,
87 node as nodemod, 87 node as nodemod,
88 registrar, 88 registrar,
89 scmutil, 89 scmutil,
90 ui as uimod,
91 util, 90 util,
92 ) 91 )
93 92
94 from mercurial.i18n import _ 93 from mercurial.i18n import _
95 94
511 510
512 rlen = lambda rangeid: repo.stablerange.rangelength(repo, rangeid) 511 rlen = lambda rangeid: repo.stablerange.rangelength(repo, rangeid)
513 512
514 repo.ui.write(b"gathering %d sample pulls within %d revisions\n" 513 repo.ui.write(b"gathering %d sample pulls within %d revisions\n"
515 % (count, len(actionrevs))) 514 % (count, len(actionrevs)))
515 progress = repo.ui.makeprogress(b'gathering data', b'pulls', count)
516 if 1 < min_cache: 516 if 1 < min_cache:
517 repo.ui.write(b" not caching ranges smaller than %d changesets\n" % min_cache) 517 repo.ui.write(b" not caching ranges smaller than %d changesets\n" % min_cache)
518 for i in range(count): 518 for i in range(count):
519 progress(repo.ui, b'gathering data', i, total=count) 519 progress.update(i)
520 outgoing = takeonesample(repo, actionrevs) 520 outgoing = takeonesample(repo, actionrevs)
521 ranges = sliceoutgoing(repo, outgoing) 521 ranges = sliceoutgoing(repo, outgoing)
522 hitranges = 0 522 hitranges = 0
523 hitchanges = 0 523 hitchanges = 0
524 totalchanges = 0 524 totalchanges = 0
538 hitchanges, 538 hitchanges,
539 len(largeranges), 539 len(largeranges),
540 hitranges, 540 hitranges,
541 ) 541 )
542 pullstats.append(stats) 542 pullstats.append(stats)
543 progress(repo.ui, b'gathering data', None) 543 progress.complete()
544 544
545 sizes = [] 545 sizes = []
546 changesmissing = [] 546 changesmissing = []
547 totalchanges = 0 547 totalchanges = 0
548 totalcached = 0 548 totalcached = 0
632 632
633 def fmtdist(name, data): 633 def fmtdist(name, data):
634 data[b'name'] = name 634 data[b'name'] = name
635 return STATSFORMAT % data 635 return STATSFORMAT % data
636 636
637 # hg <= 4.6 (bec1212eceaa)
638 if util.safehasattr(uimod.ui, 'makeprogress'):
639 def progress(ui, topic, pos, item=b"", unit=b"", total=None):
640 progress = ui.makeprogress(topic, unit, total)
641 if pos is not None:
642 progress.update(pos, item=item)
643 else:
644 progress.complete()
645 else:
646 def progress(ui, topic, pos, item=b"", unit=b"", total=None):
647 ui.progress(topic, pos, item, unit, total)
648
649 # nodemap.get and index.[has_node|rev|get_rev] 637 # nodemap.get and index.[has_node|rev|get_rev]
650 # hg <= 5.2 (02802fa87b74) 638 # hg <= 5.2 (02802fa87b74)
651 def getgetrev(cl): 639 def getgetrev(cl):
652 """Returns index.get_rev or nodemap.get (for pre-5.3 Mercurial).""" 640 """Returns index.get_rev or nodemap.get (for pre-5.3 Mercurial)."""
653 if util.safehasattr(cl.index, 'get_rev'): 641 if util.safehasattr(cl.index, 'get_rev'):