Mercurial > hg
changeset 7070:2627ef59195d
churn and stats commands merged
author | Alexander Solovyov <piranha@piranha.org.ua> |
---|---|
date | Thu, 09 Oct 2008 00:14:20 +0300 |
parents | 852f39691a0a |
children | 643c751e60b2 |
files | hgext/churn.py tests/test-churn tests/test-churn.out tests/test-stats tests/test-stats.out |
diffstat | 5 files changed, 36 insertions(+), 89 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/churn.py Tue Sep 30 17:23:08 2008 -0400 +++ b/hgext/churn.py Thu Oct 09 00:14:20 2008 +0300 @@ -85,7 +85,9 @@ ctx = repo[rev] key = getkey(ctx) key = amap.get(key, key) # alias remap - if opts.get('lines'): + if opts.get('changesets'): + rate[key] = rate.get(key, 0) + 1 + else: parents = ctx.parents() if len(parents) > 1: ui.note(_('Revision %d is a merge, ignoring...\n') % (rev,)) @@ -94,8 +96,6 @@ ctx1 = parents[0] lines = changedlines(ui, repo, ctx1, ctx) rate[key] = rate.get(key, 0) + lines - else: - rate[key] = rate.get(key, 0) + 1 if opts.get('progress'): count += 1 @@ -112,28 +112,32 @@ return rate -def stats(ui, repo, *pats, **opts): +def churn(ui, repo, *pats, **opts): '''Graph count of revisions grouped by template - Will graph count of revisions grouped by template or alternatively by - date, if dateformat is used. In this case it will override template. + Will graph count of changed lines or revisions grouped by template or + alternatively by date, if dateformat is used. In this case it will override + template. - By default statistics are counted for number of revisions. + By default statistics are counted for number of changed lines. Examples: - # display count of revisions for every committer - hg stats -t '{author|email}' + # display count of changed lines for every committer + hg churn -t '{author|email}' # display daily activity graph - hg stats -f '%H' -s + hg churn -f '%H' -s -c # display activity of developers by month - hg stats -f '%Y-%m' -s + hg churn -f '%Y-%m' -s -c # display count of lines changed in every year - hg stats -l -f '%Y' -s - ''' + hg churn -f '%Y' -s + + The map file format used to specify aliases is fairly simple: + + <alias email> <actual email>''' def pad(s, l): return (s + " " * l)[:l] @@ -163,32 +167,18 @@ print "%s %6d %s" % (pad(date, maxname), count, "*" * int(count * width / maxcount)) -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>''' - stats(ui, repo, lines=True, sort=False, template='{author|email}', **opts) - cmdtable = { - "stats": - (stats, + "churn": + (churn, [('r', 'rev', [], _('count rate for the specified revision or range')), ('d', 'date', '', _('count rate for revs matching date spec')), ('t', 'template', '{author|email}', _('template to group changesets')), ('f', 'dateformat', '', _('strftime-compatible format for grouping by date')), - ('l', 'lines', False, _('count rate by number of changed lines')), + ('c', 'changesets', False, _('count rate by number of changesets')), ('s', 'sort', False, _('sort by key (default: sort by count)')), ('', 'aliases', '', _('file with email aliases')), ('', 'progress', None, _('show progress'))], - _("hg stats [-d DATE] [-r REV] [FILE]")), - "churn": - (churn, - [('r', 'rev', [], _('limit statistics to the specified revisions')), - ('', 'aliases', '', _('file with email aliases')), - ('', 'progress', None, _('show progress'))], - 'hg churn [-r REVISIONS] [--aliases FILE] [--progress]'), + _("hg stats [-d DATE] [-r REV] [--aliases FILE] [--progress] [FILE]")), }
--- a/tests/test-churn Tue Sep 30 17:23:08 2008 -0400 +++ b/tests/test-churn Thu Oct 09 00:14:20 2008 +0300 @@ -9,19 +9,22 @@ hg init repo cd repo echo a > a -hg ci -Am adda -u user1 +hg ci -Am adda -u user1 -d 6:00 echo b >> a echo b > b -hg ci -Am addb -u user2 +hg ci -m changeba -u user2 -d 9:00 a +hg ci -Am addb -u user2 -d 9:30 echo c >> a echo c >> b echo c > c -hg ci -Am addc -u user3 +hg ci -m changeca -u user3 -d 12:00 a +hg ci -m changecb -u user3 -d 12:15 b +hg ci -Am addc -u user3 -d 12:30 echo % churn all hg churn -echo % churn up to rev 1 -hg churn -r :1 +echo % churn up to rev 2 +hg churn -r :2 echo % churn with aliases cat > ../aliases <<EOF user1 alias1 @@ -30,4 +33,6 @@ hg churn --aliases ../aliases echo % churn with column specifier COLUMNS=40 hg churn +echo % churn by hour +hg churn -f '%H' -s
--- a/tests/test-churn.out Tue Sep 30 17:23:08 2008 -0400 +++ b/tests/test-churn.out Thu Oct 09 00:14:20 2008 +0300 @@ -6,7 +6,7 @@ user3 3 *************************************************************** user2 2 ****************************************** user1 1 ********************* -% churn up to rev 1 +% churn up to rev 2 user2 2 *************************************************************** user1 1 ******************************* % churn with aliases @@ -17,3 +17,7 @@ user3 3 *********************** user2 2 *************** user1 1 ******* +% churn by hour +06 1 ********************** +09 2 ******************************************** +12 3 ******************************************************************
--- a/tests/test-stats Tue Sep 30 17:23:08 2008 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -#!/bin/sh - -echo "[extensions]" >> $HGRCPATH -echo "churn=" >> $HGRCPATH - -COLUMNS=80; export COLUMNS - -echo % create test repository -hg init repo -cd repo -echo a > a -hg ci -Am adda -u user1 -d 6:00 -echo b >> a -echo b > b -hg ci -m changeba -u user2 -d 9:00 a -hg ci -Am addb -u user2 -d 9:30 -echo c >> a -echo c >> b -echo c > c -hg ci -m changeca -u user3 -d 12:00 a -hg ci -m changecb -u user3 -d 12:15 b -hg ci -Am addc -u user3 -d 12:30 - -echo % all stats -hg stats -echo % stats by hour -hg stats -f '%H' -s -echo % stats with aliases -cat > ../aliases <<EOF -06 09 -EOF -hg stats -f '%H' -s --aliases ../aliases -echo % stats with column specifier -COLUMNS=40 hg stats -f '%Y' -s -
--- a/tests/test-stats.out Tue Sep 30 17:23:08 2008 -0400 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,17 +0,0 @@ -% create test repository -adding a -adding b -adding c -% all stats -user3 3 *************************************************************** -user2 2 ****************************************** -user1 1 ********************* -% stats by hour -06 1 ********************** -09 2 ******************************************** -12 3 ****************************************************************** -% stats with aliases -09 3 ****************************************************************** -12 3 ****************************************************************** -% stats with column specifier -2008 6 ************************