--- a/mercurial/progress.py Tue Jun 19 22:06:28 2018 -0700
+++ b/mercurial/progress.py Tue Jun 19 22:11:34 2018 -0700
@@ -264,36 +264,40 @@
self.starttimes[topic] = now - interval
def progress(self, topic, pos, item='', unit='', total=None):
+ if pos is None:
+ self.closetopic(topic)
+ return
now = time.time()
with self._refreshlock:
- if pos is None:
- self.starttimes.pop(topic, None)
- self.startvals.pop(topic, None)
- self.topicstates.pop(topic, None)
- # reset the progress bar if this is the outermost topic
- if self.topics and self.topics[0] == topic and self.printed:
- self.complete()
- self.resetstate()
- # truncate the list of topics assuming all topics within
- # 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
- self.startvals[topic] = pos
- self.topics.append(topic)
- self.topicstates[topic] = pos, item, unit, total
- self.curtopic = topic
- self._calibrateestimate(topic, now, pos)
- if now - self.lastprint >= self.refresh and self.topics:
- if self._oktoprint(now):
- self.lastprint = now
- self.show(now, topic, *self.topicstates[topic])
+ if topic not in self.topics:
+ self.starttimes[topic] = now
+ self.startvals[topic] = pos
+ self.topics.append(topic)
+ self.topicstates[topic] = pos, item, unit, total
+ self.curtopic = topic
+ self._calibrateestimate(topic, now, pos)
+ if now - self.lastprint >= self.refresh and self.topics:
+ if self._oktoprint(now):
+ self.lastprint = now
+ self.show(now, topic, *self.topicstates[topic])
+
+ def closetopic(self, topic):
+ with self._refreshlock:
+ self.starttimes.pop(topic, None)
+ self.startvals.pop(topic, None)
+ self.topicstates.pop(topic, None)
+ # reset the progress bar if this is the outermost topic
+ if self.topics and self.topics[0] == topic and self.printed:
+ self.complete()
+ self.resetstate()
+ # truncate the list of topics assuming all topics within
+ # 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