changeset 38224:61cecab0cc20

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.
author Yuya Nishihara <yuya@tcha.org>
date Wed, 04 Apr 2018 21:01:21 +0900
parents b865bba56db1
children d48b80d58848
files mercurial/templateutil.py
diffstat 1 files changed, 4 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/templateutil.py	Sun May 13 23:18:26 2018 +0200
+++ b/mercurial/templateutil.py	Wed Apr 04 21:01:21 2018 +0900
@@ -461,7 +461,8 @@
 # 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 @@
             thing = stringutil.parsebool(data)
     else:
         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