Mercurial > dotfiles
comparison lib/hg/changelog/changelog.py @ 250:792cbc7bae1d
Add hg-changelog extension.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Wed, 24 Dec 2014 17:14:24 -0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
249:efff5f3e72bb | 250:792cbc7bae1d |
---|---|
1 """changelog | |
2 | |
3 Generates a user-centric changelog from commit messages | |
4 """ | |
5 import re | |
6 import markdown | |
7 from mercurial import command, util, cmdutil, scmutil, graphmod | |
8 from mercurial.i18n import _ | |
9 | |
10 cmdtable = {} | |
11 command = cmdutil.command(cmdtable) | |
12 | |
13 @command('changelog', | |
14 [ | |
15 ('l', 'limit', '', _('limit number of changes included in the changelog'), _('NUM')), | |
16 ('r', 'rev', [], _('include the specified revision or range'), _('REV')), | |
17 ], | |
18 _('hg changelog [OPTION]... [FILE]')) | |
19 def changelog(ui, repo, *pats, **opts): | |
20 """generate a changelog from the revision history | |
21 """ | |
22 rev = opts.get('rev') | |
23 if not rev: | |
24 rev = ['all()'] | |
25 revs = sorted(scmutil.revrange(repo, rev), reverse=1) | |
26 limit = cmdutil.loglimit(opts) | |
27 if limit is not None: | |
28 revs = revs[:limit] | |
29 | |
30 dateformat = ui.config('changelog', 'dateformat', '%B %d, %Y') | |
31 | |
32 entries = [i for i in ui.configitems('changelog') if i[0].startswith('entry')] | |
33 ui.write(entries) | |
34 ui.write("\n") | |
35 | |
36 ui.write("Generating changelog from:\n") | |
37 revdag = graphmod.dagwalker(repo, revs) | |
38 for rev, t, ctx, parents in revdag: | |
39 ui.write('%s: %s %s %s\n' % (util.datestr(ctx.date(), dateformat), rev, t, ctx.description())) | |
40 | |
41 ui.write("\n") | |
42 ui.write("foo = %s\n" % ui.config('changelog', 'foo')) | |
43 ui.write("blah = %s\n" % ui.config('changelog', 'blah')) | |
44 |