[PATCH 5 of 7] color: make label() template function stringify "expr" argument first

Yuya Nishihara yuya at tcha.org
Fri Mar 4 10:48:47 EST 2016


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1457103696 -32400
#      Sat Mar 05 00:01:36 2016 +0900
# Node ID 7b3020f224417ca1e34efcab5c71edb545a1bedb
# Parent  6914e9e8b8e547b56bdc4416c89b1b873d6074a9
color: make label() template function stringify "expr" argument first

Since label() should return a string (or a thunk to be evaluated to a string),
this change is okay. This helps porting to evalstring() helper. See the next
patch for details.

diff --git a/hgext/color.py b/hgext/color.py
--- a/hgext/color.py
+++ b/hgext/color.py
@@ -490,6 +490,7 @@ def templatelabel(context, mapping, args
     mapping.update(dict([(k, k) for k in _effects]))
 
     thing = args[1][0](context, mapping, args[1][1])
+    thing = templater.stringify(thing)
 
     # apparently, repo could be a string that is the favicon?
     repo = mapping.get('repo', '')
@@ -497,8 +498,6 @@ def templatelabel(context, mapping, args
         return thing
 
     label = args[0][0](context, mapping, args[0][1])
-
-    thing = templater.stringify(thing)
     label = templater.stringify(label)
 
     return repo.ui.label(thing, label)


More information about the Mercurial-devel mailing list