diff mercurial/templater.py @ 28374:af3bd9d1dbc1

templater: move label() function from color extension ui.label() is no-op by default, so we can just call ui.label() by label() template function no matter if the color is enabled or not.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 11 Jun 2015 23:04:14 +0900
parents 9a9dd71e882c
children 3356bf61fa25
line wrap: on
line diff
--- a/mercurial/templater.py	Thu Jun 11 22:58:27 2015 +0900
+++ b/mercurial/templater.py	Thu Jun 11 23:04:14 2015 +0900
@@ -547,8 +547,18 @@
         # i18n: "label" is a keyword
         raise error.ParseError(_("label expects two arguments"))
 
-    # ignore args[0] (the label string) since this is supposed to be a a no-op
-    yield args[1][0](context, mapping, args[1][1])
+    thing = evalstring(context, mapping, args[1])
+
+    # apparently, repo could be a string that is the favicon?
+    repo = mapping.get('repo', '')
+    if isinstance(repo, str):
+        return thing
+
+    # preserve unknown symbol as literal so effects like 'red', 'bold',
+    # etc. don't need to be quoted
+    label = evalstringliteral(context, mapping, args[0])
+
+    return repo.ui.label(thing, label)
 
 def latesttag(context, mapping, args):
     """:latesttag([pattern]): The global tags matching the given pattern on the