# HG changeset patch # User Yuya Nishihara # Date 2018-03-23 12:03:21 # Node ID 0023da2910c99ca52b933670c5ac2c3ba8fa05db # Parent 53e6b7e05553c6bed2f7beeca2f28f27a5a3f28c templater: extract type conversion from evalfuncarg() Needed by the subsequent patches. diff --git a/mercurial/templateutil.py b/mercurial/templateutil.py --- a/mercurial/templateutil.py +++ b/mercurial/templateutil.py @@ -287,7 +287,12 @@ def evalrawexp(context, mapping, arg): def evalfuncarg(context, mapping, arg): """Evaluate given argument as value type""" - thing = evalrawexp(context, mapping, arg) + return _unwrapvalue(evalrawexp(context, mapping, arg)) + +# TODO: unify this with unwrapvalue() once the bug of templatefunc.join() +# is fixed. we can't do that right now because join() has to take a generator +# of byte strings as it is, not a lazy byte string. +def _unwrapvalue(thing): thing = unwrapvalue(thing) # evalrawexp() may return string, generator of strings or arbitrary object # such as date tuple, but filter does not want generator.