Mercurial > public > mercurial-scm > hg-stable
diff mercurial/templateutil.py @ 37224:54355c243042
templatefilters: allow declaration of input data type
Currently filters take an unwrapped value, which should have no hybrid magic
but actually it does because stringify() relies on it. The 'intype' allows
us to pre-process the magic by .e.g. evalstring() keeping filter functions
as simple as they are now.
stringify() is ported as an example. More follow.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 18 Mar 2018 15:14:58 +0900 |
parents | 0fb28899e81a |
children | 67efce231633 |
line wrap: on
line diff
--- a/mercurial/templateutil.py Mon Mar 19 20:39:06 2018 +0900 +++ b/mercurial/templateutil.py Sun Mar 18 15:14:58 2018 +0900 @@ -342,6 +342,7 @@ return stringify(thing) _unwrapfuncbytype = { + None: _unwrapvalue, bytes: stringify, int: unwrapinteger, } @@ -400,8 +401,9 @@ def runfilter(context, mapping, data): arg, filt = data - thing = evalfuncarg(context, mapping, arg) + thing = evalrawexp(context, mapping, arg) try: + thing = unwrapastype(thing, getattr(filt, '_intype', None)) return filt(thing) except (ValueError, AttributeError, TypeError): sym = findsymbolicname(arg)