changeset 250:792cbc7bae1d

Add hg-changelog extension.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 24 Dec 2014 17:14:24 -0800
parents efff5f3e72bb
children 7fd33f60cfee
files lib/hg/changelog/README.md lib/hg/changelog/changelog.py lib/hg/changelog/changelog.pyc
diffstat 3 files changed, 54 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/hg/changelog/README.md	Wed Dec 24 17:14:24 2014 -0800
@@ -0,0 +1,10 @@
+
+Release Notes Extension
+-----------------------
+
+This extension adds a `releasenotes` command (also aliased to `rnotes`) that
+helps generate release notes for the project in the repository. By default, it
+will create a `ReleaseNotes.html` file, but you can specify another output file:
+
+    hg rnotes -o SomeOtherFile.html
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lib/hg/changelog/changelog.py	Wed Dec 24 17:14:24 2014 -0800
@@ -0,0 +1,44 @@
+"""changelog
+
+Generates a user-centric changelog from commit messages
+"""
+import re
+import markdown
+from mercurial import command, util, cmdutil, scmutil, graphmod
+from mercurial.i18n import _
+
+cmdtable = {}
+command = cmdutil.command(cmdtable)
+
+@command('changelog',
+    [
+        ('l', 'limit', '', _('limit number of changes included in the changelog'), _('NUM')),
+        ('r', 'rev', [], _('include the specified revision or range'), _('REV')),
+    ],
+    _('hg changelog [OPTION]... [FILE]'))
+def changelog(ui, repo, *pats, **opts):
+    """generate a changelog from the revision history
+    """
+    rev = opts.get('rev')
+    if not rev:
+        rev = ['all()']
+    revs = sorted(scmutil.revrange(repo, rev), reverse=1)
+    limit = cmdutil.loglimit(opts)
+    if limit is not None:
+        revs = revs[:limit]
+
+    dateformat = ui.config('changelog', 'dateformat', '%B %d, %Y')
+    
+    entries = [i for i in ui.configitems('changelog') if i[0].startswith('entry')]
+    ui.write(entries)
+    ui.write("\n")
+
+    ui.write("Generating changelog from:\n")
+    revdag = graphmod.dagwalker(repo, revs)
+    for rev, t, ctx, parents in revdag:
+        ui.write('%s: %s %s %s\n' % (util.datestr(ctx.date(), dateformat), rev, t, ctx.description()))
+
+    ui.write("\n")
+    ui.write("foo = %s\n" % ui.config('changelog', 'foo'))
+    ui.write("blah = %s\n" % ui.config('changelog', 'blah'))
+
Binary file lib/hg/changelog/changelog.pyc has changed