contrib/churn.py
changeset 6223 bab6c8f2bb1a
parent 6212 e75aab656f46
equal deleted inserted replaced
6222:d2353ed8b153 6223:bab6c8f2bb1a
   176     revs.sort()
   176     revs.sort()
   177     stats = gather_stats(ui, repo, amap, revs, opts.get('progress'))
   177     stats = gather_stats(ui, repo, amap, revs, opts.get('progress'))
   178 
   178 
   179     # make a list of tuples (name, lines) and sort it in descending order
   179     # make a list of tuples (name, lines) and sort it in descending order
   180     ordered = stats.items()
   180     ordered = stats.items()
   181     ordered.sort(lambda x, y: cmp(y[1], x[1]))
       
   182 
       
   183     if not ordered:
   181     if not ordered:
   184         return
   182         return
   185     maximum = ordered[0][1]
   183     ordered.sort(lambda x, y: cmp(y[1], x[1]))
   186 
   184     max_churn = ordered[0][1]
   187     width = get_tty_width()
   185 
   188     ui.note(_("assuming %i character terminal\n") % width)
   186     tty_width = get_tty_width()
   189     width -= 1
   187     ui.note(_("assuming %i character terminal\n") % tty_width)
   190 
   188     tty_width -= 1
   191     for i in ordered:
   189 
   192         person = i[0]
   190     max_user_width = max([len(user) for user, churn in ordered])
   193         lines = i[1]
   191 
   194         print "%s %6d %s" % (pad(person, 20), lines,
   192     graph_width = tty_width - max_user_width - 1 - 6 - 2 - 2
   195                 graph(lines, maximum, width - 20 - 1 - 6 - 2 - 2, '*'))
   193 
       
   194     for user, churn in ordered:
       
   195         print "%s %6d %s" % (pad(user, max_user_width),
       
   196                              churn,
       
   197                              graph(churn, max_churn, graph_width, '*'))
   196 
   198 
   197 cmdtable = {
   199 cmdtable = {
   198     "churn":
   200     "churn":
   199     (churn,
   201     (churn,
   200      [('r', 'rev', [], _('limit statistics to the specified revisions')),
   202      [('r', 'rev', [], _('limit statistics to the specified revisions')),