[PATCH] template: add rev*(revision) functions for use with revsets

Yuya Nishihara yuya at tcha.org
Wed Sep 2 14:20:51 UTC 2015


On Tue, 01 Sep 2015 23:30:12 -0500, timeless at mozdev.org wrote:
> # HG changeset patch
> # User timeless at mozdev.org
> # Date 1441163415 14400
> #      Tue Sep 01 23:10:15 2015 -0400
> # Node ID ce481a6fe8d07685374baca22066dcdc4ab72c80
> # Parent  f77a3f27cea533232dc107a72773e90e2de9549d
> template: add rev*(revision) functions for use with revsets
> 
> revauthor
> revbisect
> revbookmarks
> revbranches
> revdate
> revdesc
> revdiffstat
> revfiles
> revset
> revtags
> 
> diff --git a/mercurial/templater.py b/mercurial/templater.py
> --- a/mercurial/templater.py
> +++ b/mercurial/templater.py
> @@ -15,8 +15,10 @@
>  from . import (
>      config,
>      error,
> +    hbisect,
>      minirst,
>      parser,
> +    patch,
>      revset as revsetmod,
>      templatefilters,
>      templatekw,
> @@ -544,6 +546,80 @@
>          tzoffset = util.makedate()[1]
>      return (date[0], tzoffset)
>  
> +def ctxrepo(func, context, mapping, args):
> +    if not len(args) == 1:
> +        raise error.ParseError(_("%s expects one argument" % func))
> +    raw = stringify(args[0][0](context, mapping, args[0][1]))
> +    rev = raw
> +    ctx = mapping['ctx']
> +    repo = ctx.repo()
> +    ctx = repo[rev]
> +    return ctx, repo
> +
> +def revdesc(context, mapping, args):
> +    """:revdesc(rev): Show description.
> +    See :hg:`help templates.desc`."""
> +    ctx, repo = ctxrepo('revdesc', context, mapping, args)
> +    return ctx.description().strip()

My idea is to add a function or operator that switches mapping['ctx'].
For example, "{desc[rev]}" will copy mapping, replace ctx by repo[rev],
then call showdescription().

https://selenic.com/pipermail/mercurial-devel/2015-May/070092.html



More information about the Mercurial-devel mailing list