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

login
register
mail settings
Submitter Yuya Nishihara
Date March 4, 2016, 3:48 p.m.
Message ID <7b3020f224417ca1e34e.1457106527@mimosa>
Download mbox | patch
Permalink /patch/13602/
State Accepted
Headers show

Comments

Yuya Nishihara - March 4, 2016, 3:48 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.

Patch

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)