Patchwork [1,of,6] templater: inline unwrapvalue()

mail settings
Submitter Yuya Nishihara
Date June 4, 2018, 1:10 p.m.
Message ID <8cb8d0883f5f839ff664.1528117808@mimosa>
Download mbox | patch
Permalink /patch/31960/
State Accepted
Headers show


Yuya Nishihara - June 4, 2018, 1:10 p.m.
# HG changeset patch
# User Yuya Nishihara <>
# Date 1522843281 -32400
#      Wed Apr 04 21:01:21 2018 +0900
# Node ID 8cb8d0883f5f839ff66462f718f895e0d107ac34
# Parent  ee1f052b45efa0b35abc9b4f40b476bff10de772
templater: inline unwrapvalue()

The current unwrapvalue() will be superseded by _unwrapvalue().

Note that _unwrapvalue() can simply return thing.tovalue() if thing is a
wrapped object. That's because tovalue() is guaranteed to not return a
generator of strings.


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -461,7 +461,8 @@  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(context, mapping, thing)
+    if isinstance(thing, wrapped):
+        return thing.tovalue(context, mapping)
     # evalrawexp() may return string, generator of strings or arbitrary object
     # such as date tuple, but filter does not want generator.
     return _unthunk(context, mapping, thing)
@@ -476,7 +477,8 @@  def evalboolean(context, mapping, arg):
             thing = stringutil.parsebool(data)
         thing = func(context, mapping, data)
-    thing = unwrapvalue(context, mapping, thing)
+    if isinstance(thing, wrapped):
+        thing = thing.tovalue(context, mapping)
     if isinstance(thing, bool):
         return thing
     # other objects are evaluated as strings, which means 0 is True, but