Mercurial > hg
annotate hgext/churn.py @ 8781:385a2d94885e
hgrc.5: fix quoting of literal strings
The quotes would go wrong in many places due to differences between
asciidoc version 8.2.7 used by Benoit and 8.4.5 used by me. Between
those versions asciidoc stopped interpreting the content of `quoted
strings`, and so `*` would start bold text in the old version, but do
nothing in the new version.
To complicate things further, `\*` would escape the bold tag in the
old version, but in the new version the backslash was inserted
literally into the output (because the backtick quotes it).
I've now replaced backticks with non-quoting plusses and escaped
backslashes as appropriate.
author | Martin Geisler <mg@lazybytes.net> |
---|---|
date | Thu, 11 Jun 2009 17:19:48 +0200 |
parents | f108e89400d8 |
children | d9f4c182aeca |
rev | line source |
---|---|
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
1 # churn.py - create a graph of revisions count grouped by template |
3040 | 2 # |
3 # Copyright 2006 Josef "Jeff" Sipek <jeffpc@josefsipek.net> | |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
4 # Copyright 2008 Alexander Solovyov <piranha@piranha.org.ua> |
3040 | 5 # |
8225
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
8085
diff
changeset
|
6 # This software may be used and distributed according to the terms of the |
46293a0c7e9f
updated license to be explicit about GPL version 2
Martin Geisler <mg@lazybytes.net>
parents:
8085
diff
changeset
|
7 # GNU General Public License version 2, incorporated herein by reference. |
8228
eee2319c5895
add blank line after copyright notices and after header
Martin Geisler <mg@lazybytes.net>
parents:
8225
diff
changeset
|
8 |
7127
9df67ee30ef5
help: better documentation intro for a few extensions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7076
diff
changeset
|
9 '''command to show certain statistics about revision history''' |
3040 | 10 |
7051
5f201f711932
i18n, churn: mark string for translation
Martin Geisler <mg@daimi.au.dk>
parents:
6955
diff
changeset
|
11 from mercurial.i18n import _ |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
12 from mercurial import patch, cmdutil, util, templater |
8254
f108e89400d8
churn: use .hgchurn in repo root as default map file
Martin Geisler <mg@lazybytes.net>
parents:
8228
diff
changeset
|
13 import sys, os |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
14 import time, datetime |
4955
9bbc0217209b
churn: get current terminal width if possible
Christian Ebert <blacktrash@gmx.net>
parents:
3963
diff
changeset
|
15 |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
16 def maketemplater(ui, repo, tmpl): |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
17 tmpl = templater.parsestring(tmpl, quoted=False) |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
18 try: |
7762
fece056bf240
add --git option to commands supporting --patch (log, incoming, history, tip)
Jim Correia <jim.correia@pobox.com>
parents:
7626
diff
changeset
|
19 t = cmdutil.changeset_templater(ui, repo, False, None, None, False) |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
20 except SyntaxError, inst: |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
21 raise util.Abort(inst.args[0]) |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
22 t.use_template(tmpl) |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
23 return t |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
24 |
7870
7bcce39e8f07
Returns lines changed for paths specified as arguments correctly.
madhu@madhu
parents:
7762
diff
changeset
|
25 def changedlines(ui, repo, ctx1, ctx2, fns): |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
26 lines = 0 |
7870
7bcce39e8f07
Returns lines changed for paths specified as arguments correctly.
madhu@madhu
parents:
7762
diff
changeset
|
27 fmatch = cmdutil.match(repo, pats=fns) |
7bcce39e8f07
Returns lines changed for paths specified as arguments correctly.
madhu@madhu
parents:
7762
diff
changeset
|
28 diff = ''.join(patch.diff(repo, ctx1.node(), ctx2.node(), fmatch)) |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
29 for l in diff.split('\n'): |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
30 if (l.startswith("+") and not l.startswith("+++ ") or |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
31 l.startswith("-") and not l.startswith("--- ")): |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
32 lines += 1 |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
33 return lines |
3050
dd1a142988d3
[churn] progress meter
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
3049
diff
changeset
|
34 |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
35 def countrate(ui, repo, amap, *pats, **opts): |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
36 """Calculate stats""" |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
37 if opts.get('dateformat'): |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
38 def getkey(ctx): |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
39 t, tz = ctx.date() |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
40 date = datetime.datetime(*time.gmtime(float(t) - tz)[:6]) |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
41 return date.strftime(opts['dateformat']) |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
42 else: |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
43 tmpl = opts.get('template', '{author|email}') |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
44 tmpl = maketemplater(ui, repo, tmpl) |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
45 def getkey(ctx): |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
46 ui.pushbuffer() |
7369
87158be081b8
cmdutil: use change contexts for cset-printer and cset-templater
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
7308
diff
changeset
|
47 tmpl.show(ctx) |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
48 return ui.popbuffer() |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
49 |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
50 count = pct = 0 |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
51 rate = {} |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
52 df = False |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
53 if opts.get('date'): |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
54 df = util.matchdate(opts['date']) |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
55 |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
56 get = util.cachefunc(lambda r: repo[r].changeset()) |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
57 changeiter, matchfn = cmdutil.walkchangerevs(ui, repo, pats, get, opts) |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
58 for st, rev, fns in changeiter: |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
59 if not st == 'add': |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
60 continue |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
61 if df and not df(get(rev)[2][0]): # doesn't match date format |
3050
dd1a142988d3
[churn] progress meter
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
3049
diff
changeset
|
62 continue |
3049
461573aa02ef
[churn] Ignore merge csets
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
3048
diff
changeset
|
63 |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
64 ctx = repo[rev] |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
65 key = getkey(ctx) |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
66 key = amap.get(key, key) # alias remap |
7070
2627ef59195d
churn and stats commands merged
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7065
diff
changeset
|
67 if opts.get('changesets'): |
2627ef59195d
churn and stats commands merged
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7065
diff
changeset
|
68 rate[key] = rate.get(key, 0) + 1 |
2627ef59195d
churn and stats commands merged
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7065
diff
changeset
|
69 else: |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
70 parents = ctx.parents() |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
71 if len(parents) > 1: |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
72 ui.note(_('Revision %d is a merge, ignoring...\n') % (rev,)) |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
73 continue |
3040 | 74 |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
75 ctx1 = parents[0] |
7870
7bcce39e8f07
Returns lines changed for paths specified as arguments correctly.
madhu@madhu
parents:
7762
diff
changeset
|
76 lines = changedlines(ui, repo, ctx1, ctx, fns) |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
77 rate[key] = rate.get(key, 0) + lines |
3040 | 78 |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
79 if opts.get('progress'): |
6759 | 80 count += 1 |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
81 newpct = int(100.0 * count / max(len(repo), 1)) |
6759 | 82 if pct < newpct: |
83 pct = newpct | |
8085
404a2c318e70
i18n: the message should not contain '\r'
Benoit Boissinot <benoit.boissinot@ens-lyon.org>
parents:
8028
diff
changeset
|
84 ui.write("\r" + _("generating stats: %d%%") % pct) |
3050
dd1a142988d3
[churn] progress meter
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
3049
diff
changeset
|
85 sys.stdout.flush() |
dd1a142988d3
[churn] progress meter
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
3049
diff
changeset
|
86 |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
87 if opts.get('progress'): |
5989
a7817ad608ea
added \r for progress counting in churn extension
Armin Ronacher <armin.ronacher@active-4.com>
parents:
5976
diff
changeset
|
88 ui.write("\r") |
3050
dd1a142988d3
[churn] progress meter
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
3049
diff
changeset
|
89 sys.stdout.flush() |
dd1a142988d3
[churn] progress meter
Josef "Jeff" Sipek <jeffpc@josefsipek.net>
parents:
3049
diff
changeset
|
90 |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
91 return rate |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
92 |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
93 |
7070
2627ef59195d
churn and stats commands merged
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7065
diff
changeset
|
94 def churn(ui, repo, *pats, **opts): |
7598 | 95 '''graph count of revisions grouped by template |
3040 | 96 |
7987
17147b465a9d
churn: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7888
diff
changeset
|
97 Will graph count of changed lines or revisions grouped by template |
17147b465a9d
churn: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7888
diff
changeset
|
98 or alternatively by date, if dateformat is used. In this case it |
17147b465a9d
churn: word-wrap help texts at 70 characters
Martin Geisler <mg@daimi.au.dk>
parents:
7888
diff
changeset
|
99 will override template. |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
100 |
7070
2627ef59195d
churn and stats commands merged
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7065
diff
changeset
|
101 By default statistics are counted for number of changed lines. |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
102 |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
103 Examples: |
6666
53465a7464e2
convert comments to docstrings in a bunch of extensions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6598
diff
changeset
|
104 |
7070
2627ef59195d
churn and stats commands merged
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7065
diff
changeset
|
105 # display count of changed lines for every committer |
2627ef59195d
churn and stats commands merged
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7065
diff
changeset
|
106 hg churn -t '{author|email}' |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
107 |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
108 # display daily activity graph |
7070
2627ef59195d
churn and stats commands merged
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7065
diff
changeset
|
109 hg churn -f '%H' -s -c |
6666
53465a7464e2
convert comments to docstrings in a bunch of extensions
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6598
diff
changeset
|
110 |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
111 # display activity of developers by month |
7070
2627ef59195d
churn and stats commands merged
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7065
diff
changeset
|
112 hg churn -f '%Y-%m' -s -c |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3090
diff
changeset
|
113 |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
114 # display count of lines changed in every year |
7070
2627ef59195d
churn and stats commands merged
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7065
diff
changeset
|
115 hg churn -f '%Y' -s |
2627ef59195d
churn and stats commands merged
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7065
diff
changeset
|
116 |
2627ef59195d
churn and stats commands merged
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7065
diff
changeset
|
117 The map file format used to specify aliases is fairly simple: |
2627ef59195d
churn and stats commands merged
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7065
diff
changeset
|
118 |
8254
f108e89400d8
churn: use .hgchurn in repo root as default map file
Martin Geisler <mg@lazybytes.net>
parents:
8228
diff
changeset
|
119 <alias email> <actual email> |
f108e89400d8
churn: use .hgchurn in repo root as default map file
Martin Geisler <mg@lazybytes.net>
parents:
8228
diff
changeset
|
120 |
f108e89400d8
churn: use .hgchurn in repo root as default map file
Martin Geisler <mg@lazybytes.net>
parents:
8228
diff
changeset
|
121 By default .hgchurn in the working directory root will be used, if |
f108e89400d8
churn: use .hgchurn in repo root as default map file
Martin Geisler <mg@lazybytes.net>
parents:
8228
diff
changeset
|
122 it exists. Use the --aliases option to override this. |
f108e89400d8
churn: use .hgchurn in repo root as default map file
Martin Geisler <mg@lazybytes.net>
parents:
8228
diff
changeset
|
123 ''' |
3040 | 124 def pad(s, l): |
6759 | 125 return (s + " " * l)[:l] |
3223
53e843840349
Whitespace/Tab cleanup
Thomas Arendsen Hein <thomas@intevation.de>
parents:
3090
diff
changeset
|
126 |
3040 | 127 amap = {} |
3045
c0be8990e819
Add revision range support
Brendan Cully <brendan@kublai.com>
parents:
3043
diff
changeset
|
128 aliases = opts.get('aliases') |
8254
f108e89400d8
churn: use .hgchurn in repo root as default map file
Martin Geisler <mg@lazybytes.net>
parents:
8228
diff
changeset
|
129 if not aliases and os.path.exists(repo.wjoin('.hgchurn')): |
f108e89400d8
churn: use .hgchurn in repo root as default map file
Martin Geisler <mg@lazybytes.net>
parents:
8228
diff
changeset
|
130 aliases = repo.wjoin('.hgchurn') |
3040 | 131 if aliases: |
6759 | 132 for l in open(aliases, "r"): |
133 l = l.strip() | |
134 alias, actual = l.split() | |
135 amap[alias] = actual | |
3040 | 136 |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
137 rate = countrate(ui, repo, amap, *pats, **opts).items() |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
138 if not rate: |
5588
083b6e3142a2
churn: avoid division by zero
Matt Mackall <mpm@selenic.com>
parents:
5482
diff
changeset
|
139 return |
3040 | 140 |
7076
c29d3f4ed967
churn: py2.3 compatibility fix
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7070
diff
changeset
|
141 sortfn = ((not opts.get('sort')) and (lambda a, b: cmp(b[1], a[1])) or None) |
c29d3f4ed967
churn: py2.3 compatibility fix
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7070
diff
changeset
|
142 rate.sort(sortfn) |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
143 |
7076
c29d3f4ed967
churn: py2.3 compatibility fix
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7070
diff
changeset
|
144 maxcount = float(max([v for k, v in rate])) |
c29d3f4ed967
churn: py2.3 compatibility fix
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7070
diff
changeset
|
145 maxname = max([len(k) for k, v in rate]) |
3040 | 146 |
7547
4949729ee9ee
python implementation of diffstat
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7369
diff
changeset
|
147 ttywidth = util.termwidth() |
6759 | 148 ui.debug(_("assuming %i character terminal\n") % ttywidth) |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
149 width = ttywidth - maxname - 2 - 6 - 2 - 2 |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
150 |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
151 for date, count in rate: |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
152 print "%s %6d %s" % (pad(date, maxname), count, |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
153 "*" * int(count * width / maxcount)) |
6223
bab6c8f2bb1a
churn: show comitter email addresses unclipped (bug 1023)
Stephen Deasey <sdeasey@gmail.com>
parents:
6212
diff
changeset
|
154 |
3040 | 155 |
156 cmdtable = { | |
7070
2627ef59195d
churn and stats commands merged
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7065
diff
changeset
|
157 "churn": |
2627ef59195d
churn and stats commands merged
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7065
diff
changeset
|
158 (churn, |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
159 [('r', 'rev', [], _('count rate for the specified revision or range')), |
8028
3aaca5901ade
expand "rev" to "revision" in help texts
Martin Geisler <mg@lazybytes.net>
parents:
7987
diff
changeset
|
160 ('d', 'date', '', _('count rate for revisions matching date spec')), |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
161 ('t', 'template', '{author|email}', _('template to group changesets')), |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
162 ('f', 'dateformat', '', |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
163 _('strftime-compatible format for grouping by date')), |
7070
2627ef59195d
churn and stats commands merged
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7065
diff
changeset
|
164 ('c', 'changesets', False, _('count rate by number of changesets')), |
7065
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
165 ('s', 'sort', False, _('sort by key (default: sort by count)')), |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
166 ('', 'aliases', '', _('file with email aliases')), |
9bc46d069a76
churn: generalisation, now it is possible to see statistics grouped by custom template
Alexander Solovyov <piranha@piranha.org.ua>
parents:
7051
diff
changeset
|
167 ('', 'progress', None, _('show progress'))], |
7129
7e6a3bae0e8e
churn: corrected help output
Martin Geisler <mg@daimi.au.dk>
parents:
7127
diff
changeset
|
168 _("hg churn [-d DATE] [-r REV] [--aliases FILE] [--progress] [FILE]")), |
3040 | 169 } |