[PATCH RESEND] templater: support using templates with non-standard names from map file

Kevin Bullock kbullock+mercurial at ringworld.org
Thu Sep 5 20:16:45 CDT 2013


On 2 Sep 2013, at 2:46 PM, Alexander Plavin wrote:

> # HG changeset patch
> # User Alexander Plavin <alexander at plav.in>
> # Date 1374620882 -14400
> #      Wed Jul 24 03:08:02 2013 +0400
> # Node ID c71151e59f50d5a112f9e7971df1f7417cdba2cd
> # Parent  3dfc0bf05e89f5faa109827b921099cde038130c
> templater: support using templates with non-standard names from map file
> 
> This allows adding arbitrarily-named entries to a template map file, and then
> referencing them, giving the ability to deduplicate and simplify templates code.
> 
> diff -r 3dfc0bf05e89 -r c71151e59f50 mercurial/templater.py
> --- a/mercurial/templater.py	Sun Sep 01 10:40:11 2013 +0400
> +++ b/mercurial/templater.py	Wed Jul 24 03:08:02 2013 +0400
> @@ -139,7 +139,12 @@
> def runsymbol(context, mapping, key):
>     v = mapping.get(key)
>     if v is None:
> -        v = context._defaults.get(key, '')
> +        v = context._defaults.get(key)
> +    if v is None:
> +        try:
> +            v = context.process(key, mapping)
> +        except util.Abort:

Not too keen on trapping util.Abort; is there a reasonable way to refactor the process() method to throw some other kind of exception (like KeyError), and have its current callers do the aborting?

pacem in terris / мир / शान्ति / ‎‫سَلاَم‬ / 平和
Kevin R. Bullock



More information about the Mercurial-devel mailing list