templater: extract unwrapinteger() function from evalinteger()
authorYuya Nishihara <yuya@tcha.org>
Fri, 23 Mar 2018 20:34:12 +0900
changeset 37162 9ab3491f84c2
parent 37161 0023da2910c9
child 37163 0fb28899e81a
templater: extract unwrapinteger() function from evalinteger()
mercurial/templateutil.py
--- 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'))