Mercurial > hg
comparison hgext/churn.py @ 21245:75c8720092ba
churn: declare command using decorator
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 04 May 2014 21:46:24 -0700 |
parents | 9846b40d01e7 |
children | a57deb45c744 |
comparison
equal
deleted
inserted
replaced
21244:f0dbafceeb9a | 21245:75c8720092ba |
---|---|
12 from mercurial import patch, cmdutil, scmutil, util, templater, commands | 12 from mercurial import patch, cmdutil, scmutil, util, templater, commands |
13 from mercurial import encoding | 13 from mercurial import encoding |
14 import os | 14 import os |
15 import time, datetime | 15 import time, datetime |
16 | 16 |
17 cmdtable = {} | |
18 command = cmdutil.command(cmdtable) | |
17 testedwith = 'internal' | 19 testedwith = 'internal' |
18 | 20 |
19 def maketemplater(ui, repo, tmpl): | 21 def maketemplater(ui, repo, tmpl): |
20 tmpl = templater.parsestring(tmpl, quoted=False) | 22 tmpl = templater.parsestring(tmpl, quoted=False) |
21 try: | 23 try: |
86 ui.progress(_('analyzing'), None) | 88 ui.progress(_('analyzing'), None) |
87 | 89 |
88 return rate | 90 return rate |
89 | 91 |
90 | 92 |
93 @command('churn', | |
94 [('r', 'rev', [], | |
95 _('count rate for the specified revision or range'), _('REV')), | |
96 ('d', 'date', '', | |
97 _('count rate for revisions matching date spec'), _('DATE')), | |
98 ('t', 'template', '{author|email}', | |
99 _('template to group changesets'), _('TEMPLATE')), | |
100 ('f', 'dateformat', '', | |
101 _('strftime-compatible format for grouping by date'), _('FORMAT')), | |
102 ('c', 'changesets', False, _('count rate by number of changesets')), | |
103 ('s', 'sort', False, _('sort by key (default: sort by count)')), | |
104 ('', 'diffstat', False, _('display added/removed lines separately')), | |
105 ('', 'aliases', '', _('file with email aliases'), _('FILE')), | |
106 ] + commands.walkopts, | |
107 _("hg churn [-d DATE] [-r REV] [--aliases FILE] [FILE]")) | |
91 def churn(ui, repo, *pats, **opts): | 108 def churn(ui, repo, *pats, **opts): |
92 '''histogram of changes to the repository | 109 '''histogram of changes to the repository |
93 | 110 |
94 This command will display a histogram representing the number | 111 This command will display a histogram representing the number |
95 of changed lines or revisions, grouped according to the given | 112 of changed lines or revisions, grouped according to the given |
179 return int(round(count * width / maxcount)) | 196 return int(round(count * width / maxcount)) |
180 | 197 |
181 for name, count in rate: | 198 for name, count in rate: |
182 ui.write(format(name, count)) | 199 ui.write(format(name, count)) |
183 | 200 |
184 | |
185 cmdtable = { | |
186 "churn": | |
187 (churn, | |
188 [('r', 'rev', [], | |
189 _('count rate for the specified revision or range'), _('REV')), | |
190 ('d', 'date', '', | |
191 _('count rate for revisions matching date spec'), _('DATE')), | |
192 ('t', 'template', '{author|email}', | |
193 _('template to group changesets'), _('TEMPLATE')), | |
194 ('f', 'dateformat', '', | |
195 _('strftime-compatible format for grouping by date'), _('FORMAT')), | |
196 ('c', 'changesets', False, _('count rate by number of changesets')), | |
197 ('s', 'sort', False, _('sort by key (default: sort by count)')), | |
198 ('', 'diffstat', False, _('display added/removed lines separately')), | |
199 ('', 'aliases', '', | |
200 _('file with email aliases'), _('FILE')), | |
201 ] + commands.walkopts, | |
202 _("hg churn [-d DATE] [-r REV] [--aliases FILE] [FILE]")), | |
203 } | |
204 | |
205 commands.inferrepo += " churn" | 201 commands.inferrepo += " churn" |