Changelog generator script for contrib

Vincent Wagelaar vincent at ricardis.tudelft.nl
Wed Aug 10 15:21:57 UTC 2005


On Wednesday 10 August 2005 16:08, Thomas Arendsen Hein wrote:
> * Vincent Wagelaar <vincent at ricardis.tudelft.nl> [20050810 15:04]:
> > I created a changelog generator script.  It can be downloaded from:
> >
> > http://hannibal.lr-s.tudelft.nl/~vincent/mercurial/hg-changelog
>
> Based on your code I hacked together a 'hg changelog' command.
> Here is the patch. Formatting is not perfect, as this is only a demo
> of how it could look like.
>
> Thomas

Added wordwrapping support to my script:

Now also a repo running at:
 http://hannibal.lr-s.tudelft.nl/~vincent/mercurial/hg/

>
> diff -r 2d2fee33ec68 mercurial/commands.py
> --- a/mercurial/commands.py	Wed Aug 10 07:41:23 2005
> +++ b/mercurial/commands.py	Wed Aug 10 16:07:22 2005
> @@ -469,6 +469,30 @@
>      fp = make_file(repo, r, opts['output'], node=n)
>      fp.write(r.read(n))
>
> +def changelog(ui, repo, *changesets):
> +    """generate changelog for one or more changesets"""
> +    if changesets:
> +        revs = list(revrange(ui, repo, changesets))
> +    else:
> +        revs = map(str, range(repo.changelog.count() - 1, -1, -1))
> +    last_date_author = None
> +    for cset in revs:
> +        node = repo.lookup(cset)
> +        changes = repo.changelog.read(node)
> +        author = changes[1]
> +        date = time.strftime("%Y-%m-%d",
> +                             time.localtime(float(changes[2].split('
> ')[0]))) +        date_author = "%s  %s\n\n" % (date, author)
> +        if last_date_author is None or last_date_author != date_author:
> +            if last_date_author:
> +                ui.write("\n")
> +            ui.write(date_author)
> +        description = changes[4].strip()
> +        if not ui.verbose:
> +            description = description.splitlines()[0]
> +        ui.write("\t* %s: %s\n" % (", ".join(changes[3]), description))
> +        last_date_author = date_author
> +
>  def clone(ui, source, dest=None, **opts):
>      """make a copy of an existing repository"""
>      if dest is None:
> @@ -1206,6 +1230,7 @@
>          (cat,
>           [('o', 'output', "", 'output to file')],
>           'hg cat [-o OUTFILE] FILE [REV]'),
> +    "changelog": (changelog, [], "hg changelog [REV]..."),
>      "^clone":
>          (clone,
>           [('U', 'noupdate', None, 'skip update after cloning')],



More information about the Mercurial mailing list