changeset 9672:5bbf4f130684

churn: fix --progress (broken by f3d60543924f)
author Alexander Solovyov <piranha@piranha.org.ua>
date Fri, 30 Oct 2009 15:43:01 +0200
parents 9471d9a900b4
children 863ba2ea1f0b
files hgext/churn.py
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/churn.py	Mon Oct 26 13:37:39 2009 +0100
+++ b/hgext/churn.py	Fri Oct 30 15:43:01 2009 +0200
@@ -48,7 +48,7 @@
             tmpl.show(ctx)
             return ui.popbuffer()
 
-    count = pct = 0
+    state = {'count': 0, 'pct': 0}
     rate = {}
     df = False
     if opts.get('date'):
@@ -75,11 +75,11 @@
             rate[key] = [r + l for r, l in zip(rate.get(key, (0, 0)), lines)]
 
         if opts.get('progress'):
-            count += 1
-            newpct = int(100.0 * count / max(len(repo), 1))
-            if pct < newpct:
-                pct = newpct
-                ui.write("\r" + _("generating stats: %d%%") % pct)
+            state['count'] += 1
+            newpct = int(100.0 * state['count'] / max(len(repo), 1))
+            if state['pct'] < newpct:
+                state['pct'] = newpct
+                ui.write("\r" + _("generating stats: %d%%") % state['pct'])
                 sys.stdout.flush()
 
     for ctx in cmdutil.walkchangerevs(repo, m, opts, prep):