diff --git a/hgext/progress.py b/hgext/progress.py --- a/hgext/progress.py +++ b/hgext/progress.py @@ -239,6 +239,13 @@ class progbar(object): # this one are also closed if topic in self.topics: self.topics = self.topics[:self.topics.index(topic)] + # reset the last topic to the one we just unwound to, + # so that higher-level topics will be stickier than + # lower-level topics + if self.topics: + self.lasttopic = self.topics[-1] + else: + self.lasttopic = None else: if topic not in self.topics: self.starttimes[topic] = now diff --git a/tests/test-progress.t b/tests/test-progress.t --- a/tests/test-progress.t +++ b/tests/test-progress.t @@ -1,6 +1,14 @@ $ cat > loop.py < from mercurial import commands + > import time + > class incrementingtime(object): + > def __init__(self): + > self._time = 0.0 + > def __call__(self): + > self._time += 0.25 + > return self._time + > time.time = incrementingtime() > > def loop(ui, loops, **opts): > loops = int(loops) @@ -19,9 +27,14 @@ > if opts.get('parallel'): > ui.progress('other', i, 'other.%d' % i, 'othernum', total) > if nested: - > for j in range(2): - > ui.progress('nested', j, 'nested.%d' % j, 'nestnum', 2) - > ui.progress('nested', None, 'nested.done', 'nestnum', 2) + > nested_steps = 2 + > if i and i % 4 == 0: + > nested_steps = 5 + > for j in range(nested_steps): + > ui.progress( + > 'nested', j, 'nested.%d' % j, 'nestnum', nested_steps) + > ui.progress( + > 'nested', None, 'nested.done', 'nestnum', nested_steps) > ui.progress('loop', None, 'loop.done', 'loopnum', total) > > commands.norepo += " loop" @@ -69,6 +82,24 @@ test nested short-lived topics (which sh loop [===============================> ] 2/3\r (no-eol) (esc) \r (no-eol) (esc) +Test nested long-lived topic which has the same name as a short-lived +peer. We shouldn't get stuck showing the short-lived inner steps, and +should go back to skipping the inner steps when the slow nested step +finishes. + + $ hg -y loop 7 --nested + \r (no-eol) (esc) + loop [ ] 0/7\r (no-eol) (esc) + loop [=====> ] 1/7\r (no-eol) (esc) + loop [============> ] 2/7\r (no-eol) (esc) + loop [===================> ] 3/7\r (no-eol) (esc) + loop [==========================> ] 4/7\r (no-eol) (esc) + nested [==========================> ] 3/5\r (no-eol) (esc) + nested [===================================> ] 4/5\r (no-eol) (esc) + loop [=================================> ] 5/7\r (no-eol) (esc) + loop [========================================> ] 6/7\r (no-eol) (esc) + \r (no-eol) (esc) + $ hg --config progress.changedelay=0 -y loop 3 --nested \r (no-eol) (esc)