Patchwork [1,of,2] progress: add try/finally to make the diffs for the next commit more readable

login
register
mail settings
Submitter Solomon Matthews
Date Jan. 17, 2015, 1:13 a.m.
Message ID <3e58f60b9c419e275eb1.1421457203@dev562.prn1.facebook.com>
Download mbox | patch
Permalink /patch/7508/
State Accepted
Commit 8b5b963ba95a7920329e6ebe733e6d25613ef512
Headers show

Comments

Solomon Matthews - Jan. 17, 2015, 1:13 a.m.
# HG changeset patch
# User Solomon Matthews <smat@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.

Patch

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