[PATCH] churn: generalisation, now it is possible to see statistics grouped by custom template
Benoit Boissinot
bboissin at gmail.com
Sun Oct 5 17:25:13 CDT 2008
On Thu, Oct 2, 2008 at 11:12 PM, Alexander Solovyov
<piranha at piranha.org.ua> wrote:
> # HG changeset patch
> # User Alexander Solovyov <piranha at piranha.org.ua>
> # Date 1222981658 -10800
> # Node ID 3b9aa06a858ccfa9453970fedbd1e7f90991ee8e
> # Parent f29b674cc2210126c2899d94d882c367a8ea64bc
> churn: generalisation, now it is possible to see statistics grouped by custom template
I like the way you're doing it :)
Some comments below (and maybe you could expand the doc with more examples).
>
> diff --git a/hgext/churn.py b/hgext/churn.py
> --- a/hgext/churn.py
> +++ b/hgext/churn.py
> @@ -1,14 +1,16 @@
> -# churn.py - create a graph showing who changed the most lines
> +# churn.py - create a graph of revisions count grouped by template
> #
> # Copyright 2006 Josef "Jeff" Sipek <jeffpc at josefsipek.net>
> +# Copyright 2008 Alexander Solovyov <piranha at piranha.org.ua>
> #
> # This software may be used and distributed according to the terms
> # of the GNU General Public License, incorporated herein by reference.
> -'''allow graphing the number of lines changed per contributor'''
> +'''allow graphing the number of lines (of count of revisions) grouped by template'''
Is it meant to be "or count of revisions"?
> -
> - if progress:
> + if opts['progress']:
we tend to prefer opts.get() for option retrieval, but it's not really
important,
in this case, it's supposed to be always set, right ?
>
> - stats = util.sort([(-l, u, l) for u,l in stats.items()])
> - maxchurn = float(max(1, stats[0][2]))
> - maxuser = max([len(u) for k, u, l in stats])
> + keyfn = (not opts.get('sort')) and (lambda (k,v): (v,k)) or None
> + rate = sorted(rate, key=keyfn, reverse=not opts.get('sort'))
> +
> + maxcount = float(max(v for k, v in rate))
> + maxdate = max(len(k) for k, v in rate)
maybe this is misnamed (maxname ?)
>
> ttywidth = get_tty_width()
> ui.debug(_("assuming %i character terminal\n") % ttywidth)
> - width = ttywidth - maxuser - 2 - 6 - 2 - 2
> + width = ttywidth - maxdate - 2 - 6 - 2 - 2
>
> +def churn(ui, repo, **opts):
> + '''graphs the number of lines changed
> +
> + The map file format used to specify aliases is fairly simple:
> +
> + <alias email> <actual email>'''
> + opts.update({'lines': True,
> + 'sort': False,
> + 'template': '{author|email}'})
> + stats(ui, repo, *(), **opts)
why the *() ? and I think you could just do:
stats(ui, repo, lines=True, sort=False, ..., **opts)
The following is unrelated, right ?
> diff --git a/hgext/mq.py b/hgext/mq.py
> --- a/hgext/mq.py
> +++ b/hgext/mq.py
> @@ -2241,6 +2241,9 @@
> q.save_dirty()
> return 0
>
> +def stage(ui, repo, **opts):
> + pass
> +
> def reposetup(ui, repo):
> class mqrepo(repo.__class__):
> def abort_if_wdir_patched(self, errmsg, force=False):
> @@ -2456,4 +2459,7 @@
> (finish,
> [('a', 'applied', None, _('finish all applied changesets'))],
> _('hg qfinish [-a] [REV...]')),
> + "qstage":
> + (stage,
> + []),
> }
More information about the Mercurial-devel
mailing list