[PATCH RFC] contrib: script to generate release notes from commit messages

Augie Fackler raf at durin42.com
Mon Feb 6 13:54:12 EST 2017


On Thu, Feb 02, 2017 at 11:56:29PM -0800, Gregory Szorc wrote:
> # HG changeset patch
> # User Gregory Szorc <gregory.szorc at gmail.com>
> # Date 1486108530 28800
> #      Thu Feb 02 23:55:30 2017 -0800
> # Node ID 5fe78521b9cb553b9a7c6bd4d96576a35b8d3517
> # Parent  abf029200e198878a4576a87e095bd8d77d9cea9
> contrib: script to generate release notes from commit messages
>
> Per discussion on the mailing list, we want better release notes.
>
> This patch introduces a script for producing better release notes.

Did you look at adapting towncrier from hawkowl on github at all? I'm
sure it's git-only now, but maybe that's easy to adapt?

(I suspect you did look, but wanted to be sure. That said, this ain't
much code...)

Overall, I think I'm pretty happy with this approach, though since I'm
the one that brought it up I guess that's unsurprising. How does this
handle the file being copy-edited mid-stream? That is, if I copy-edit
one of the release note lines, will it get clobbered by future runs of
the tool?

As for who and when, if we don't expect much copyediting before
release time, maybe the thing to do is to just run this as part of the
release process and do the copyediting then? Or if we do, we could
just have a bot do it on mercurial-scm.org as part of the accept
process tooling.

> diff --git a/contrib/generate-release-notes b/contrib/generate-release-notes
> new file mode 100755
> --- /dev/null
> +++ b/contrib/generate-release-notes
> @@ -0,0 +1,270 @@
> +
> +def unpublishedcommitmessages():
> +    """Obtain commit messages for unpublished commits."""

Is it the intent that this only scrapes the log messages of non-public
commits? I feel like maybe the approach should instead be to record a
last-run version in the .rst file, and then we process everything in
the repo that's a descendant of that or something?

> +
> +    env = dict(os.environ)
> +    env['HGMODULEPOLICY'] = 'py'
> +
> +    sep = str(uuid.uuid4())
> +
> +    args = [
> +        'hg',
> +        'log',
> +        '-r', '::. and not public()',
> +        '-T', '{desc}%s' % sep
> +    ]
> +
> +    p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE,
> +                         cwd=SRCDIR, env=env)
> +    out, err = p.communicate()
> +    res = p.wait()
> +    if res:
> +        raise Exception('error running `hg log`')
> +
> +    return out.split(sep)[:-1]
> +


More information about the Mercurial-devel mailing list