Patchwork [6,of,8,V2] templater: pass (context, mapping) down to unwrapvalue()

login
register
mail settings
Submitter Yuya Nishihara
Date April 3, 2018, 3:40 p.m.
Message ID <df181b84d8341bd25609.1522770008@mimosa>
Download mbox | patch
Permalink /patch/30167/
State Accepted
Headers show

Comments

Yuya Nishihara - April 3, 2018, 3:40 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1521382461 -32400
#      Sun Mar 18 23:14:21 2018 +0900
# Node ID df181b84d8341bd2560964165624c04a1d5c84fe
# Parent  82d9c4a417c425734bb7db227d7c648be8b2d94a
templater: pass (context, mapping) down to unwrapvalue()

The same reason as why I made unwraphybrid() take a (context, mapping) pair.

Patch

diff --git a/mercurial/templatefuncs.py b/mercurial/templatefuncs.py
--- a/mercurial/templatefuncs.py
+++ b/mercurial/templatefuncs.py
@@ -319,7 +319,7 @@  def join(context, mapping, args):
     # TODO: perhaps this should be evalfuncarg(), but it can't because hgweb
     # abuses generator as a keyword that returns a list of dicts.
     joinset = evalrawexp(context, mapping, args[0])
-    joinset = templateutil.unwrapvalue(joinset)
+    joinset = templateutil.unwrapvalue(context, mapping, joinset)
     joinfmt = getattr(joinset, 'joinfmt', pycompat.identity)
     joiner = " "
     if len(args) > 1:
diff --git a/mercurial/templateutil.py b/mercurial/templateutil.py
--- a/mercurial/templateutil.py
+++ b/mercurial/templateutil.py
@@ -157,7 +157,7 @@  def unwraphybrid(context, mapping, thing
         return thing
     return thing.show(context, mapping)
 
-def unwrapvalue(thing):
+def unwrapvalue(context, mapping, thing):
     """Move the inner value object out of the wrapper"""
     if not util.safehasattr(thing, '_value'):
         return thing
@@ -327,7 +327,7 @@  def evalfuncarg(context, mapping, arg):
 # 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(context, mapping, thing):
-    thing = unwrapvalue(thing)
+    thing = unwrapvalue(context, mapping, thing)
     # evalrawexp() may return string, generator of strings or arbitrary object
     # such as date tuple, but filter does not want generator.
     if isinstance(thing, types.GeneratorType):
@@ -344,7 +344,7 @@  def evalboolean(context, mapping, arg):
             thing = stringutil.parsebool(data)
     else:
         thing = func(context, mapping, data)
-    thing = unwrapvalue(thing)
+    thing = unwrapvalue(context, mapping, thing)
     if isinstance(thing, bool):
         return thing
     # other objects are evaluated as strings, which means 0 is True, but