comparison hgext3rd/pullbundle.py @ 5044:b9179a034005

pullbundle: compatibility for progress in hg <= 4.6
author Anton Shestakov <av6@dwimlabs.net>
date Thu, 19 Dec 2019 18:02:31 +0700
parents 1015a1dbaf7c
children ebd0f5c6098f
comparison
equal deleted inserted replaced
5043:db341dafdccb 5044:b9179a034005
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,
90 util, 91 util,
91 ) 92 )
92 93
93 from mercurial.i18n import _ 94 from mercurial.i18n import _
94 95
506 repo.ui.write(b"gathering %d sample pulls within %d revisions\n" 507 repo.ui.write(b"gathering %d sample pulls within %d revisions\n"
507 % (count, len(actionrevs))) 508 % (count, len(actionrevs)))
508 if 1 < min_cache: 509 if 1 < min_cache:
509 repo.ui.write(b" not caching ranges smaller than %d changesets\n" % min_cache) 510 repo.ui.write(b" not caching ranges smaller than %d changesets\n" % min_cache)
510 for i in range(count): 511 for i in range(count):
511 repo.ui.progress(b'gathering data', i, total=count) 512 progress(repo.ui, b'gathering data', i, total=count)
512 outgoing = takeonesample(repo, actionrevs) 513 outgoing = takeonesample(repo, actionrevs)
513 ranges = sliceoutgoing(repo, outgoing) 514 ranges = sliceoutgoing(repo, outgoing)
514 hitranges = 0 515 hitranges = 0
515 hitchanges = 0 516 hitchanges = 0
516 totalchanges = 0 517 totalchanges = 0
530 hitchanges, 531 hitchanges,
531 len(largeranges), 532 len(largeranges),
532 hitranges, 533 hitranges,
533 ) 534 )
534 pullstats.append(stats) 535 pullstats.append(stats)
535 repo.ui.progress(b'gathering data', None) 536 progress(repo.ui, b'gathering data', None)
536 537
537 sizes = [] 538 sizes = []
538 changesmissing = [] 539 changesmissing = []
539 totalchanges = 0 540 totalchanges = 0
540 totalcached = 0 541 totalcached = 0
622 """ 623 """
623 624
624 def fmtdist(name, data): 625 def fmtdist(name, data):
625 return STATSFORMAT.format(name=name, **data) 626 return STATSFORMAT.format(name=name, **data)
626 627
628 # hg <= 4.6 (bec1212eceaa)
629 if util.safehasattr(uimod.ui, 'makeprogress'):
630 def progress(ui, topic, pos, item=b"", unit=b"", total=None):
631 progress = ui.makeprogress(topic, unit, total)
632 if pos is not None:
633 progress.update(pos, item=item)
634 else:
635 progress.complete()
636 else:
637 def progress(ui, topic, pos, item=b"", unit=b"", total=None):
638 ui.progress(topic, pos, item, unit, total)
639
627 # nodemap.get and index.[has_node|rev|get_rev] 640 # nodemap.get and index.[has_node|rev|get_rev]
628 # hg <= 5.3 (02802fa87b74) 641 # hg <= 5.3 (02802fa87b74)
629 def getgetrev(cl): 642 def getgetrev(cl):
630 """Returns index.get_rev or nodemap.get (for pre-5.3 Mercurial).""" 643 """Returns index.get_rev or nodemap.get (for pre-5.3 Mercurial)."""
631 if util.safehasattr(cl.index, 'get_rev'): 644 if util.safehasattr(cl.index, 'get_rev'):