Mercurial > hg-stable
changeset 37164:9ab3491f84c2
templater: extract unwrapinteger() function from evalinteger()
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Fri, 23 Mar 2018 20:34:12 +0900 |
parents | 0023da2910c9 |
children | 0fb28899e81a |
files | mercurial/templateutil.py |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/templateutil.py Fri Mar 23 21:03:21 2018 +0900 +++ b/mercurial/templateutil.py Fri Mar 23 20:34:12 2018 +0900 @@ -318,9 +318,12 @@ 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'))