Patchwork [5,of,7] templater: extract type conversion from evalfuncarg()

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

Comments

Yuya Nishihara - March 25, 2018, 5:15 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1521806601 -32400
#      Fri Mar 23 21:03:21 2018 +0900
# Node ID 974b91e77122678881e9618d1682cfe0cf02d367
# Parent  8b71d63fb9cc8c635fab41b872b8db6d5279a58a
templater: extract type conversion from evalfuncarg()

Needed by the subsequent patches.

Patch

diff --git a/mercurial/templateutil.py b/mercurial/templateutil.py
--- a/mercurial/templateutil.py
+++ b/mercurial/templateutil.py
@@ -287,7 +287,12 @@  def evalrawexp(context, mapping, arg):
 
 def evalfuncarg(context, mapping, arg):
     """Evaluate given argument as value type"""
-    thing = evalrawexp(context, mapping, arg)
+    return _unwrapvalue(evalrawexp(context, mapping, arg))
+
+# TODO: unify this with unwrapvalue() once the bug of templatefunc.join()
+# is fixed. we can't do that right now because join() has to take a generator
+# of byte strings as it is, not a lazy byte string.
+def _unwrapvalue(thing):
     thing = unwrapvalue(thing)
     # evalrawexp() may return string, generator of strings or arbitrary object
     # such as date tuple, but filter does not want generator.