# HG changeset patch # User Yuya Nishihara # Date 2018-03-23 11:34:12 # Node ID 9ab3491f84c2ba678bd06131b0da97900244a420 # Parent 0023da2910c99ca52b933670c5ac2c3ba8fa05db templater: extract unwrapinteger() function from evalinteger() diff --git a/mercurial/templateutil.py b/mercurial/templateutil.py --- a/mercurial/templateutil.py +++ b/mercurial/templateutil.py @@ -318,9 +318,12 @@ def evalboolean(context, mapping, arg): return bool(stringify(thing)) def evalinteger(context, mapping, arg, err=None): - v = evalfuncarg(context, mapping, arg) + return unwrapinteger(evalrawexp(context, mapping, arg), err) + +def unwrapinteger(thing, err=None): + thing = _unwrapvalue(thing) try: - return int(v) + return int(thing) except (TypeError, ValueError): raise error.ParseError(err or _('not an integer'))