[PATCH 5 of 8] progress: cache time.time() as now

Augie Fackler durin42 at gmail.com
Thu Dec 9 17:41:05 CST 2010


# HG changeset patch
# User timeless <timeless at gmail.com>
# Date 1288093318 -10800
# Node ID f0ef6533d1cc76e38053bc192f91b65a9c41b89a
# Parent  50766f487403088037b03f8d183a2bb30f03c1dd
progress: cache time.time() as now

diff --git a/hgext/progress.py b/hgext/progress.py
--- a/hgext/progress.py
+++ b/hgext/progress.py
@@ -167,6 +167,7 @@
         return min(int(self.ui.config('progress', 'width', default=tw)), tw)
 
     def progress(self, topic, pos, item='', unit='', total=None):
+        now = time.time()
         if pos is None:
             self.pendingtopics.pop(topic, None)
             if self.topics and self.topics[0] == topic and self.printed:
@@ -177,17 +178,16 @@
         else:
             if self.topics:
                 if topic in self.pendingtopics:
-                    if self.pendingtopics[topic] > time.time():
+                    if self.pendingtopics[topic] > now:
                         return
                 else:
-                    self.pendingtopics[topic] = time.time() + float(
+                    self.pendingtopics[topic] = now + float(
                         self.ui.config('progress', 'nestdelay', default=0.5))
                     return
             if topic not in self.topics:
                 self.pendingtopics[topic] = 0
                 self.topics.append(topic)
             self.topicstates[topic] = pos, item, unit, total
-        now = time.time()
         if now - self.lastprint >= self.refresh and self.topics:
             self.lastprint = now
             curtopic = self.topics[-1]


More information about the Mercurial-devel mailing list