# HG changeset patch # User Alexander Solovyov # Date 2009-10-30 13:43:01 # Node ID 5bbf4f130684e27ce4491ea31fbe1629dcc4ebdb # Parent 9471d9a900b4f6f154bae04c1577c045a57d8f05 churn: fix --progress (broken by f3d60543924f) diff --git a/hgext/churn.py b/hgext/churn.py --- a/hgext/churn.py +++ b/hgext/churn.py @@ -48,7 +48,7 @@ def countrate(ui, repo, amap, *pats, **o 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 @@ def countrate(ui, repo, amap, *pats, **o 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):