Mercurial > hg
diff mercurial/templateutil.py @ 36982:255f635c3204
templater: convert resources to a table of callables for future extension
I'm going to add a full templating support to the annotate command. As the
annotate is a filectx-oriented command, we'll need a way to look up a ctx
from a bounded fctx only when necessary.
This is the minimal change to support that. I'm thinking of defining a proper
interface to look up template resources to fix other issues, but that isn't
ready yet.
(Changes from V1: just updated tests and patch descriptions.)
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 11 Mar 2018 21:05:29 +0900 |
parents | 32f9b7e3f056 |
children | c97b936d8bb5 |
line wrap: on
line diff
--- a/mercurial/templateutil.py Sat Mar 17 21:46:17 2018 -0400 +++ b/mercurial/templateutil.py Sun Mar 11 21:05:29 2018 +0900 @@ -350,7 +350,8 @@ v = default if callable(v) and getattr(v, '_requires', None) is None: # old templatekw: expand all keywords and resources - props = context._resources.copy() + props = {k: f(context, mapping, k) + for k, f in context._resources.items()} props.update(mapping) return v(**pycompat.strkwargs(props)) if callable(v):