evolve: adapt for deprecated ui.progress()
This makes a wrapper that has an interface like ui.progress() even
though that's the old interface that will eventually go away. That's
because it's a lot easier to convert from the ui.progress() to the
ui.makeprogress() interface than the other way around. Once we no
longer support hg<4.7, we can migrate our callers to ui.makeprogress()
and drop the wrapper.
--- a/hgext3rd/evolve/compat.py Fri Jan 11 09:26:41 2019 -0800
+++ b/hgext3rd/evolve/compat.py Mon Jan 14 09:14:38 2019 -0800
@@ -19,6 +19,7 @@
revset,
scmutil,
util,
+ ui as uimod,
vfs as vfsmod,
)
from mercurial.hgweb import hgweb_mod
@@ -91,6 +92,17 @@
def phasedivergentrevset(*args, **kwargs):
return revset.bumped(*args, **kwargs)
+if util.safehasattr(uimod.ui, 'makeprogress'):
+ def progress(ui, topic, pos, item="", unit="", 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="", unit="", total=None):
+ ui.progress(topic, pos, item="", unit="", total=None)
+
if not util.safehasattr(context.basectx, 'instabilities'):
def instabilities(self):
"""return the list of instabilities affecting this changeset.
--- a/hgext3rd/evolve/depthcache.py Fri Jan 11 09:26:41 2019 -0800
+++ b/hgext3rd/evolve/depthcache.py Mon Jan 14 09:14:38 2019 -0800
@@ -113,8 +113,8 @@
total = len(data)
def progress(pos, rev):
- repo.ui.progress('updating depth cache',
- pos, 'rev %s' % rev, unit='revision', total=total)
+ compat.progress(repo.ui, 'updating depth cache',
+ pos, 'rev %s' % rev, unit='revision', total=total)
progress(0, '')
for idx, rev in enumerate(data, 1):
assert rev == len(self._data), (rev, len(self._data))
--- a/hgext3rd/evolve/evolvecmd.py Fri Jan 11 09:26:41 2019 -0800
+++ b/hgext3rd/evolve/evolvecmd.py Mon Jan 14 09:14:38 2019 -0800
@@ -1294,7 +1294,7 @@
def _cleanup(ui, repo, startnode, showprogress, shouldupdate):
if showprogress:
- ui.progress(_('evolve'), None)
+ compat.progress(ui, _('evolve'), None)
if not shouldupdate:
unfi = repo.unfiltered()
@@ -1519,7 +1519,7 @@
def progresscb():
if revopt or allopt:
- ui.progress(_('evolve'), seen, unit=_('changesets'), total=count)
+ compat.progress(ui, _('evolve'), seen, unit=_('changesets'), total=count)
evolvestate = state.cmdstate(repo)
# Continuation handling
--- a/hgext3rd/evolve/firstmergecache.py Fri Jan 11 09:26:41 2019 -0800
+++ b/hgext3rd/evolve/firstmergecache.py Mon Jan 14 09:14:38 2019 -0800
@@ -75,8 +75,8 @@
total = len(data)
def progress(pos, rev):
- repo.ui.progress('updating firstmerge cache',
- pos, 'rev %s' % rev, unit='revision', total=total)
+ compat.progress(repo.ui, 'updating firstmerge cache',
+ pos, 'rev %s' % rev, unit='revision', total=total)
progress(0, '')
for idx, rev in enumerate(data, 1):
assert rev == len(self._data), (rev, len(self._data))
--- a/hgext3rd/evolve/obsdiscovery.py Fri Jan 11 09:26:41 2019 -0800
+++ b/hgext3rd/evolve/obsdiscovery.py Mon Jan 14 09:14:38 2019 -0800
@@ -95,8 +95,8 @@
common = set()
undecided = set(probeset)
totalnb = len(undecided)
- ui.progress(_("comparing with other"), 0, total=totalnb,
- unit=_("changesets"))
+ compat.progress(ui, _("comparing with other"), 0, total=totalnb,
+ unit=_("changesets"))
_takefullsample = setdiscovery._takefullsample
if remote.capable('_evoext_obshash_1'):
getremotehash = remote.evoext_obshash1
@@ -120,8 +120,8 @@
sample = _takefullsample(dag, undecided, size=fullsamplesize)
roundtrips += 1
- ui.progress(_("comparing with other"), totalnb - len(undecided),
- total=totalnb, unit=_("changesets"))
+ compat.progress(ui, _("comparing with other"), totalnb - len(undecided),
+ total=totalnb, unit=_("changesets"))
ui.debug("query %i; still undecided: %i, sample size is: %i\n"
% (roundtrips, len(undecided), len(sample)))
# indices between sample and externalized version must match
@@ -140,7 +140,7 @@
undecided.difference_update(missing)
undecided.difference_update(common)
- ui.progress(_("comparing with other"), None)
+ compat.progress(ui, _("comparing with other"), None)
result = dag.headsetofconnecteds(common)
ui.debug("%d total queries\n" % roundtrips)
@@ -182,8 +182,8 @@
local.obsstore.rangeobshashcache.update(local)
querycount = 0
- ui.progress(_("comparing obsmarker with other"), querycount,
- unit=_("queries"))
+ compat.progress(ui, _("comparing obsmarker with other"), querycount,
+ unit=_("queries"))
overflow = []
while sample or overflow:
if overflow:
@@ -238,9 +238,9 @@
addentry(new)
assert nbsample == nbreplies
querycount += 1
- ui.progress(_("comparing obsmarker with other"), querycount,
- unit=_("queries"))
- ui.progress(_("comparing obsmarker with other"), None)
+ compat.progress(ui, _("comparing obsmarker with other"), querycount,
+ unit=_("queries"))
+ compat.progress(ui, _("comparing obsmarker with other"), None)
local.obsstore.rangeobshashcache.save(local)
duration = util.timer() - starttime
logmsg = ('obsdiscovery, %d/%d mismatch'
@@ -545,8 +545,8 @@
total = len(revs)
def progress(pos, rev):
- repo.ui.progress('updating obshashrange cache',
- pos, 'rev %s' % rev, unit='revision', total=total)
+ compat.progress(repo.ui, 'updating obshashrange cache',
+ pos, 'rev %s' % rev, unit='revision', total=total)
# warm the cache for the new revs
progress(0, '')
for idx, r in enumerate(revs):
@@ -861,8 +861,8 @@
cache = []
unfi = repo.unfiltered()
markercache = {}
- repo.ui.progress(_("preparing locally"), 0, total=len(unfi),
- unit=_("changesets"))
+ compat.progress(repo.ui, _("preparing locally"), 0, total=len(unfi),
+ unit=_("changesets"))
for i in unfi:
ctx = unfi[i]
entry = 0
@@ -892,9 +892,9 @@
cache.append((ctx.node(), sha.digest()))
else:
cache.append((ctx.node(), node.nullid))
- repo.ui.progress(_("preparing locally"), i, total=len(unfi),
- unit=_("changesets"))
- repo.ui.progress(_("preparing locally"), None)
+ compat.progress(repo.ui, _("preparing locally"), i, total=len(unfi),
+ unit=_("changesets"))
+ compat.progress(repo.ui, _("preparing locally"), None)
return cache
def _obshash(repo, nodes, version=0):
--- a/hgext3rd/evolve/stablerange.py Fri Jan 11 09:26:41 2019 -0800
+++ b/hgext3rd/evolve/stablerange.py Mon Jan 14 09:14:38 2019 -0800
@@ -23,6 +23,7 @@
from mercurial.i18n import _
from . import (
+ compat,
exthelper,
firstmergecache,
stablesort,
@@ -619,12 +620,12 @@
rangeheap = []
for idx, r in enumerate(revs):
if not idx % 1000:
- ui.progress(_("filling depth cache"), idx, total=nbrevs,
- unit=_("changesets"))
+ compat.progress(ui, _("filling depth cache"), idx, total=nbrevs,
+ unit=_("changesets"))
# warm up depth
self.depthrev(repo, r)
rangeheap.append((-r, (r, 0)))
- ui.progress(_("filling depth cache"), None, total=nbrevs)
+ compat.progress(ui, _("filling depth cache"), None, total=nbrevs)
heappop = heapq.heappop
heappush = heapq.heappush
@@ -645,8 +646,8 @@
progress_new = time.time()
if (1 < progress_each) and (0.1 < progress_new - progress_last):
progress_each /= 10
- ui.progress(_("filling stablerange cache"), seen,
- total=nbrevs, unit=_("changesets"))
+ compat.progress(ui, _("filling stablerange cache"), seen,
+ total=nbrevs, unit=_("changesets"))
progress_last = progress_new
seen += 1
original.remove(value) # might have been added from other source
@@ -655,7 +656,7 @@
for sub in self.subranges(repo, rangeid):
if self._getsub(sub) is None:
heappush(rangeheap, (-sub[0], sub))
- ui.progress(_("filling stablerange cache"), None, total=nbrevs)
+ compat.progress(ui, _("filling stablerange cache"), None, total=nbrevs)
self._tiprev = upto
self._tipnode = cl.node(upto)
--- a/hgext3rd/evolve/stablerangecache.py Fri Jan 11 09:26:41 2019 -0800
+++ b/hgext3rd/evolve/stablerangecache.py Mon Jan 14 09:14:38 2019 -0800
@@ -21,6 +21,7 @@
)
from . import (
+ compat,
exthelper,
genericcaches,
stablerange,
@@ -97,8 +98,8 @@
warned_long = True
if (1 < progress_each) and (0.1 < progress_new - progress_last):
progress_each /= 10
- ui.progress(_("filling stablerange cache"), seen,
- total=total, unit=_("changesets"))
+ compat.progress(ui, _("filling stablerange cache"), seen,
+ total=total, unit=_("changesets"))
progress_last = progress_new
seen += 1
original.remove(rangeid) # might have been added from other source
@@ -107,7 +108,7 @@
for sub in self.subranges(repo, rangeid):
if self._getsub(sub) is None:
heappush(rangeheap, sub)
- ui.progress(_("filling stablerange cache"), None, total=total)
+ compat.progress(ui, _("filling stablerange cache"), None, total=total)
def clear(self, reset=False):
super(stablerangeondiskbase, self).clear()
--- a/hgext3rd/evolve/stablesort.py Fri Jan 11 09:26:41 2019 -0800
+++ b/hgext3rd/evolve/stablesort.py Mon Jan 14 09:14:38 2019 -0800
@@ -577,8 +577,8 @@
total = len(data)
def progress(pos, rev):
- repo.ui.progress('updating stablesort cache',
- pos, 'rev %s' % rev, unit='revision', total=total)
+ compat.progress(repo.ui, 'updating stablesort cache',
+ pos, 'rev %s' % rev, unit='revision', total=total)
progress(0, '')
for idx, rev in enumerate(data):
--- a/hgext3rd/evolve/utility.py Fri Jan 11 09:26:41 2019 -0800
+++ b/hgext3rd/evolve/utility.py Mon Jan 14 09:14:38 2019 -0800
@@ -13,6 +13,10 @@
from mercurial.node import nullrev
+from . import (
+ compat,
+)
+
shorttemplate = "[{label('evolve.rev', rev)}] {desc|firstline}\n"
stacktemplate = """[{label('evolve.rev', if(topicidx, "s{topicidx}", rev))}] {desc|firstline}\n"""
@@ -27,7 +31,7 @@
topic = 'obsmarkers exchange'
if ui.configbool('experimental', 'verbose-obsolescence-exchange'):
topic = 'OBSEXC'
- ui.progress(topic, *args, **kwargs)
+ compat.progress(ui, topic, *args, **kwargs)
def filterparents(parents):
"""filter nullrev parents