[PATCH 1 of 2] progress: add try/finally to make the diffs for the next commit more readable
Solomon Matthews
smat at fb.com
Sat Jan 17 01:13:23 UTC 2015
# HG changeset patch
# User Solomon Matthews <smat at fb.com>
# Date 1421381008 28800
# Thu Jan 15 20:03:28 2015 -0800
# Node ID 3e58f60b9c419e275eb14087c76e1ab04feeb3ed
# Parent 5827ad0b849e3757c876e9f034846b1aba37ba88
progress: add try/finally to make the diffs for the next commit more readable
No change in behavior.
diff --git a/hgext/progress.py b/hgext/progress.py
--- a/hgext/progress.py
+++ b/hgext/progress.py
@@ -229,39 +229,42 @@
def progress(self, topic, pos, item='', unit='', total=None):
now = time.time()
- 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
- if now - self.lastprint >= self.refresh and self.topics:
- if (self.lasttopic is None # first time we printed
- # not a topic change
- or topic == self.lasttopic
- # it's been long enough we should print anyway
- or now - self.lastprint >= self.changedelay):
- self.lastprint = now
- self.show(now, topic, *self.topicstates[topic])
+ try:
+ 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
+ if now - self.lastprint >= self.refresh and self.topics:
+ if (self.lasttopic is None # first time we printed
+ # not a topic change
+ or topic == self.lasttopic
+ # it's been long enough we should print anyway
+ or now - self.lastprint >= self.changedelay):
+ self.lastprint = now
+ self.show(now, topic, *self.topicstates[topic])
+ finally:
+ pass
_singleton = None
More information about the Mercurial-devel
mailing list