Patchwork [6,of,7] templater: extract unwrapinteger() function from evalinteger()

login
register
mail settings
Submitter Yuya Nishihara
Date March 25, 2018, 5:15 a.m.
Message ID <b5bdcfbf663e1fa1d7c2.1521954953@mimosa>
Download mbox | patch
Permalink /patch/29843/
State Accepted
Headers show

Comments

Yuya Nishihara - March 25, 2018, 5:15 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1521804852 -32400
#      Fri Mar 23 20:34:12 2018 +0900
# Node ID b5bdcfbf663e1fa1d7c2004a0ef6b3172cc8eff9
# Parent  974b91e77122678881e9618d1682cfe0cf02d367
templater: extract unwrapinteger() function from evalinteger()

Patch

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'))