# HG changeset patch # User Anton Shestakov # Date 1630772500 -10800 # Node ID 9e27494ac6189fafd3606031875768ab18db5625 # Parent 217828aa0e29a48b9706ea6fa8047117f45ba04e evolve: use ui.makeprogress() directly without 4.6 compatibility diff -r 217828aa0e29 -r 9e27494ac618 hgext3rd/evolve/compat.py --- a/hgext3rd/evolve/compat.py Sat Sep 04 19:19:25 2021 +0300 +++ b/hgext3rd/evolve/compat.py Sat Sep 04 19:21:40 2021 +0300 @@ -24,7 +24,6 @@ registrar, scmutil, util, - ui as uimod, ) # hg <= 5.2 (c21aca51b392) @@ -55,18 +54,6 @@ r'PHASEDIVERGENT': b'phase-divergent', } -# 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) - # XXX: Better detection of property cache if r'predecessors' not in dir(obsolete.obsstore): @property diff -r 217828aa0e29 -r 9e27494ac618 hgext3rd/evolve/depthcache.py --- a/hgext3rd/evolve/depthcache.py Sat Sep 04 19:19:25 2021 +0300 +++ b/hgext3rd/evolve/depthcache.py Sat Sep 04 19:21:40 2021 +0300 @@ -20,7 +20,6 @@ from mercurial.utils.stringutil import forcebytestr from . import ( - compat, error, exthelper, genericcaches, @@ -113,17 +112,15 @@ cl = repo.unfiltered().changelog total = len(data) - def progress(pos, rev=None): - revstr = b'' if rev is None else (b'rev %d' % rev) - compat.progress(repo.ui, b'updating depth cache', - pos, revstr, unit=_(b'changesets'), total=total) - progress(0) + progress = repo.ui.makeprogress(b'updating depth cache', _(b'changesets'), total) + progress.update(0) for idx, rev in enumerate(data, 1): assert rev == len(self._data), (rev, len(self._data)) self._data.append(self._depth(cl, rev)) if not (idx % 10000): # progress as a too high performance impact - progress(idx, rev) - progress(None) + revstr = b'' if rev is None else (b'rev %d' % rev) + progress.update(idx, item=revstr) + progress.complete() def _depth(self, changelog, rev): cl = changelog diff -r 217828aa0e29 -r 9e27494ac618 hgext3rd/evolve/evolvecmd.py --- a/hgext3rd/evolve/evolvecmd.py Sat Sep 04 19:19:25 2021 +0300 +++ b/hgext3rd/evolve/evolvecmd.py Sat Sep 04 19:21:40 2021 +0300 @@ -1742,11 +1742,12 @@ seen = 1 showprogress = allopt or revopt count = len(revs) + if showprogress: + progress = repo.ui.makeprogress(_(b'evolve'), _(b'changesets'), count) def progresscb(): if showprogress: - compat.progress(ui, _(b'evolve'), seen, unit=_(b'changesets'), - total=count) + progress.update(seen) # Order the revisions revs = _orderrevs(repo, revs) @@ -1773,7 +1774,7 @@ seen += 1 if showprogress: - compat.progress(ui, _(b'evolve'), None) + progress.complete() _cleanup(ui, repo, startnode, shouldupdate, headnode) @@ -2003,10 +2004,10 @@ # Progress handling seen = 1 count = len(evolvestate[b'revs']) + progress = repo.ui.makeprogress(_(b'evolve'), _(b'changesets'), count) def progresscb(): - compat.progress(ui, _(b'evolve'), seen, unit=_(b'changesets'), - total=count) + progress.update(seen) headnode = None category = evolvestate[b'category'] @@ -2039,6 +2040,7 @@ else: evolvestate[b'skippedrevs'].append(curctx.node()) seen += 1 + progress.complete() return headnode def _continuecontentdivergent(ui, repo, evolvestate, progresscb): diff -r 217828aa0e29 -r 9e27494ac618 hgext3rd/evolve/firstmergecache.py --- a/hgext3rd/evolve/firstmergecache.py Sat Sep 04 19:19:25 2021 +0300 +++ b/hgext3rd/evolve/firstmergecache.py Sat Sep 04 19:21:40 2021 +0300 @@ -20,7 +20,6 @@ from mercurial.utils.stringutil import forcebytestr from . import ( - compat, error, exthelper, genericcaches, @@ -86,17 +85,15 @@ cl = repo.unfiltered().changelog total = len(data) - def progress(pos, rev=None): - revstr = b'' if rev is None else (b'rev %d' % rev) - compat.progress(repo.ui, b'updating firstmerge cache', - pos, revstr, unit=_(b'changesets'), total=total) - progress(0) + progress = repo.ui.makeprogress(b'updating firstmerge cache', _(b'changesets'), total) + progress.update(0) for idx, rev in enumerate(data, 1): assert rev == len(self._data), (rev, len(self._data)) self._data.append(self._firstmerge(cl, rev)) if not (idx % 10000): # progress as a too high performance impact - progress(idx, rev) - progress(None) + revstr = b'' if rev is None else (b'rev %d' % rev) + progress.update(idx, item=revstr) + progress.complete() def _firstmerge(self, changelog, rev): cl = changelog diff -r 217828aa0e29 -r 9e27494ac618 hgext3rd/evolve/obsdiscovery.py --- a/hgext3rd/evolve/obsdiscovery.py Sat Sep 04 19:19:25 2021 +0300 +++ b/hgext3rd/evolve/obsdiscovery.py Sat Sep 04 19:21:40 2021 +0300 @@ -102,8 +102,7 @@ local.obsstore.rangeobshashcache.update(local) querycount = 0 - compat.progress(ui, _(b"comparing obsmarker with other"), querycount, - unit=_(b"queries")) + progress = ui.makeprogress(_(b"comparing obsmarker with other"), _(b"queries")) overflow = [] while sample or overflow: if overflow: @@ -158,9 +157,8 @@ addentry(new) assert nbsample == nbreplies querycount += 1 - compat.progress(ui, _(b"comparing obsmarker with other"), querycount, - unit=_(b"queries")) - compat.progress(ui, _(b"comparing obsmarker with other"), None) + progress.update(querycount) + progress.complete() local.obsstore.rangeobshashcache.save(local) duration = util.timer() - starttime logmsg = (b'obsdiscovery, %d/%d mismatch' @@ -468,16 +466,14 @@ repo.depthcache.update(repo) total = len(revs) - def progress(pos, rev=None): - revstr = b'' if rev is None else (b'rev %d' % rev) - compat.progress(repo.ui, b'updating obshashrange cache', - pos, revstr, unit=_(b'changesets'), total=total) # warm the cache for the new revs - progress(0) + progress = repo.ui.makeprogress(b'updating obshashrange cache', _(b'changesets'), total) + progress.update(0) for idx, r in enumerate(revs): _obshashrange(repo, (r, 0)) - progress(idx, r) - progress(None) + revstr = b'' if r is None else (b'rev %d' % r) + progress.update(idx, item=revstr) + progress.complete() del self._updating diff -r 217828aa0e29 -r 9e27494ac618 hgext3rd/evolve/obshashtree.py --- a/hgext3rd/evolve/obshashtree.py Sat Sep 04 19:19:25 2021 +0300 +++ b/hgext3rd/evolve/obshashtree.py Sat Sep 04 19:21:40 2021 +0300 @@ -18,7 +18,6 @@ from mercurial.i18n import _ from . import ( - compat, exthelper, ) @@ -61,8 +60,8 @@ cache = [] unfi = repo.unfiltered() markercache = {} - compat.progress(repo.ui, _(b"preparing locally"), 0, total=len(unfi), - unit=_(b"changesets")) + progress = repo.ui.makeprogress(_(b"preparing locally"), _(b"changesets"), + len(unfi)) for i in unfi: ctx = unfi[i] entry = 0 @@ -92,7 +91,6 @@ cache.append((ctx.node(), sha.digest())) else: cache.append((ctx.node(), node.nullid)) - compat.progress(repo.ui, _(b"preparing locally"), i, total=len(unfi), - unit=_(b"changesets")) - compat.progress(repo.ui, _(b"preparing locally"), None) + progress.update(i) + progress.complete() return cache diff -r 217828aa0e29 -r 9e27494ac618 hgext3rd/evolve/stablerange.py --- a/hgext3rd/evolve/stablerange.py Sat Sep 04 19:19:25 2021 +0300 +++ b/hgext3rd/evolve/stablerange.py Sat Sep 04 19:21:40 2021 +0300 @@ -369,7 +369,6 @@ from mercurial.i18n import _ from . import ( - compat, exthelper, firstmergecache, stablesort, @@ -964,14 +963,14 @@ revs = cl.revs(start=self._tiprev + 1, stop=upto) nbrevs = upto - self._tiprev rangeheap = [] + progress = ui.makeprogress(_(b"filling depth cache"), _(b"changesets"), nbrevs) for idx, r in enumerate(revs): if not idx % 1000: - compat.progress(ui, _(b"filling depth cache"), idx, total=nbrevs, - unit=_(b"changesets")) + progress.update(idx) # warm up depth self.depthrev(repo, r) rangeheap.append((-r, (r, 0))) - compat.progress(ui, _(b"filling depth cache"), None, total=nbrevs) + progress.complete() heappop = heapq.heappop heappush = heapq.heappush @@ -984,6 +983,7 @@ progress_each = 100 progress_last = time.time() heapify(rangeheap) + progress = ui.makeprogress(_(b"filling stablerange cache"), _(b"changesets"), nbrevs) while rangeheap: value = heappop(rangeheap) if value in original: @@ -992,8 +992,7 @@ progress_new = time.time() if (1 < progress_each) and (0.1 < progress_new - progress_last): progress_each /= 10 - compat.progress(ui, _(b"filling stablerange cache"), seen, - total=nbrevs, unit=_(b"changesets")) + progress.update(seen) progress_last = progress_new seen += 1 original.remove(value) # might have been added from other source @@ -1002,7 +1001,7 @@ for sub in self.subranges(repo, rangeid): if self._getsub(sub) is None: heappush(rangeheap, (-sub[0], sub)) - compat.progress(ui, _(b"filling stablerange cache"), None, total=nbrevs) + progress.complete() self._tiprev = upto self._tipnode = cl.node(upto) diff -r 217828aa0e29 -r 9e27494ac618 hgext3rd/evolve/stablerangecache.py --- a/hgext3rd/evolve/stablerangecache.py Sat Sep 04 19:19:25 2021 +0300 +++ b/hgext3rd/evolve/stablerangecache.py Sat Sep 04 19:21:40 2021 +0300 @@ -28,7 +28,6 @@ from mercurial.utils.stringutil import forcebytestr from . import ( - compat, exthelper, genericcaches, stablerange, @@ -92,6 +91,7 @@ initial_time = progress_last = time.time() warned_long = False heapify(rangeheap) + progress = ui.makeprogress(_(b"filling stablerange cache"), _(b"changesets"), total) while rangeheap: rangeid = heappop(rangeheap) if rangeid in original: @@ -103,8 +103,7 @@ warned_long = True if (1 < progress_each) and (0.1 < progress_new - progress_last): progress_each /= 10 - compat.progress(ui, _(b"filling stablerange cache"), seen, - total=total, unit=_(b"changesets")) + progress.update(seen) progress_last = progress_new seen += 1 original.remove(rangeid) # might have been added from other source @@ -113,7 +112,7 @@ for sub in self.subranges(repo, rangeid): if self._getsub(sub) is None: heappush(rangeheap, sub) - compat.progress(ui, _(b"filling stablerange cache"), None, total=total) + progress.complete() def clear(self, reset=False): super(stablerangeondiskbase, self).clear() diff -r 217828aa0e29 -r 9e27494ac618 hgext3rd/evolve/stablesort.py --- a/hgext3rd/evolve/stablesort.py Sat Sep 04 19:19:25 2021 +0300 +++ b/hgext3rd/evolve/stablesort.py Sat Sep 04 19:21:40 2021 +0300 @@ -264,7 +264,6 @@ from mercurial.utils.stringutil import forcebytestr from . import ( - compat, depthcache, exthelper, utility, @@ -861,12 +860,8 @@ total = len(data) - def progress(pos, rev=None): - revstr = b'' if rev is None else (b'rev %d' % rev) - compat.progress(repo.ui, b'updating stablesort cache', - pos, revstr, unit=_(b'changesets'), total=total) - - progress(0) + progress = repo.ui.makeprogress(b'updating stablesort cache', _(b'changesets'), total) + progress.update(0) for idx, rev in enumerate(data): parents = filterparents(repo.changelog.parentrevs(rev)) if len(parents) <= 1: @@ -879,8 +874,9 @@ if r == minparent: break if not (idx % 1000): # progress as a too high performance impact - progress(idx, rev) - progress(None) + revstr = b'' if rev is None else (b'rev %d' % rev) + progress.update(idx, item=revstr) + progress.complete() def clear(self, reset=False): super(ondiskstablesortcache, self).clear()