Mercurial > hg > mercurial-source
diff mercurial/templater.py @ 29015:ac371d4c007f
templater: drop redundant type conversion when evaluating integer argument
A function argument may be an integer. In this case, it isn't necessary to
convert a value to string and back to integer.
Because an argument may be an arbitrary object (e.g. date tuple), TypeError
should be caught as well.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sun, 14 Feb 2016 12:48:14 +0900 |
parents | a6c2310b3827 |
children | d81437c91a26 |
line wrap: on
line diff
--- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -221,9 +221,10 @@ return thing def evalinteger(context, mapping, arg, err): + v = evalfuncarg(context, mapping, arg) try: - return int(stringify(arg[0](context, mapping, arg[1]))) - except ValueError: + return int(v) + except (TypeError, ValueError): raise error.ParseError(err) def runinteger(context, mapping, data):