[PATCH 4 of 6 DRAFT] progress: cache time.time() as now

timeless timeless at gmail.com
Tue Oct 19 11:32:21 CDT 2010


# HG changeset patch
# User timeless <timeless at gmail.com>
# Date 1287478262 -10800
# Node ID d00dab51aff9972373b2af0dd90f36af8cece609
# Parent  2fabb5a56127eb79c1fcf90834088b60b80b1d83
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 @@ class progbar(object):
         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 @@ class progbar(object):
         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