# HG changeset patch # User Eric Eisner # Date 1268316661 18000 # Node ID 4ba41eebb3a8560ee088cb4a171a5ff8e500a6d2 # Parent 63948e7d37f7b1381c5f683efd55e99408bb51a4 churn: use ui.progress instead of --progress diff -r 63948e7d37f7 -r 4ba41eebb3a8 hgext/churn.py --- a/hgext/churn.py Thu Mar 11 13:33:29 2010 +0100 +++ b/hgext/churn.py Thu Mar 11 09:11:01 2010 -0500 @@ -48,7 +48,7 @@ tmpl.show(ctx) return ui.popbuffer() - state = {'count': 0, 'pct': 0} + state = {'count': 0} rate = {} df = False if opts.get('date'): @@ -74,20 +74,13 @@ lines = changedlines(ui, repo, ctx1, ctx, fns) rate[key] = [r + l for r, l in zip(rate.get(key, (0, 0)), lines)] - if opts.get('progress'): - 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() + state['count'] += 1 + ui.progress(_('churning changes'), state['count'], total=len(repo)) for ctx in cmdutil.walkchangerevs(repo, m, opts, prep): continue - if opts.get('progress'): - ui.write("\r") - sys.stdout.flush() + ui.progress(_('churning changes'), None) return rate @@ -188,6 +181,6 @@ ('s', 'sort', False, _('sort by key (default: sort by count)')), ('', 'diffstat', False, _('display added/removed lines separately')), ('', 'aliases', '', _('file with email aliases')), - ('', 'progress', None, _('show progress'))], - _("hg churn [-d DATE] [-r REV] [--aliases FILE] [--progress] [FILE]")), + ], + _("hg churn [-d DATE] [-r REV] [--aliases FILE] [FILE]")), }