hgext/churn.py
changeset 10647 4ba41eebb3a8
parent 10282 08a0f04b56bd
child 10700 b2b71c304de0
equal deleted inserted replaced
10644:63948e7d37f7 10647:4ba41eebb3a8
    46         def getkey(ctx):
    46         def getkey(ctx):
    47             ui.pushbuffer()
    47             ui.pushbuffer()
    48             tmpl.show(ctx)
    48             tmpl.show(ctx)
    49             return ui.popbuffer()
    49             return ui.popbuffer()
    50 
    50 
    51     state = {'count': 0, 'pct': 0}
    51     state = {'count': 0}
    52     rate = {}
    52     rate = {}
    53     df = False
    53     df = False
    54     if opts.get('date'):
    54     if opts.get('date'):
    55         df = util.matchdate(opts['date'])
    55         df = util.matchdate(opts['date'])
    56 
    56 
    72 
    72 
    73             ctx1 = parents[0]
    73             ctx1 = parents[0]
    74             lines = changedlines(ui, repo, ctx1, ctx, fns)
    74             lines = changedlines(ui, repo, ctx1, ctx, fns)
    75             rate[key] = [r + l for r, l in zip(rate.get(key, (0, 0)), lines)]
    75             rate[key] = [r + l for r, l in zip(rate.get(key, (0, 0)), lines)]
    76 
    76 
    77         if opts.get('progress'):
    77         state['count'] += 1
    78             state['count'] += 1
    78         ui.progress(_('churning changes'), state['count'], total=len(repo))
    79             newpct = int(100.0 * state['count'] / max(len(repo), 1))
       
    80             if state['pct'] < newpct:
       
    81                 state['pct'] = newpct
       
    82                 ui.write("\r" + _("generating stats: %d%%") % state['pct'])
       
    83                 sys.stdout.flush()
       
    84 
    79 
    85     for ctx in cmdutil.walkchangerevs(repo, m, opts, prep):
    80     for ctx in cmdutil.walkchangerevs(repo, m, opts, prep):
    86         continue
    81         continue
    87 
    82 
    88     if opts.get('progress'):
    83     ui.progress(_('churning changes'), None)
    89         ui.write("\r")
       
    90         sys.stdout.flush()
       
    91 
    84 
    92     return rate
    85     return rate
    93 
    86 
    94 
    87 
    95 def churn(ui, repo, *pats, **opts):
    88 def churn(ui, repo, *pats, **opts):
   186               _('strftime-compatible format for grouping by date')),
   179               _('strftime-compatible format for grouping by date')),
   187           ('c', 'changesets', False, _('count rate by number of changesets')),
   180           ('c', 'changesets', False, _('count rate by number of changesets')),
   188           ('s', 'sort', False, _('sort by key (default: sort by count)')),
   181           ('s', 'sort', False, _('sort by key (default: sort by count)')),
   189           ('', 'diffstat', False, _('display added/removed lines separately')),
   182           ('', 'diffstat', False, _('display added/removed lines separately')),
   190           ('', 'aliases', '', _('file with email aliases')),
   183           ('', 'aliases', '', _('file with email aliases')),
   191           ('', 'progress', None, _('show progress'))],
   184           ],
   192          _("hg churn [-d DATE] [-r REV] [--aliases FILE] [--progress] [FILE]")),
   185          _("hg churn [-d DATE] [-r REV] [--aliases FILE] [FILE]")),
   193 }
   186 }