comparison 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
comparison
equal deleted inserted replaced
28373:9a9dd71e882c 28374:af3bd9d1dbc1
545 automatic colorization.""" 545 automatic colorization."""
546 if len(args) != 2: 546 if len(args) != 2:
547 # i18n: "label" is a keyword 547 # i18n: "label" is a keyword
548 raise error.ParseError(_("label expects two arguments")) 548 raise error.ParseError(_("label expects two arguments"))
549 549
550 # ignore args[0] (the label string) since this is supposed to be a a no-op 550 thing = evalstring(context, mapping, args[1])
551 yield args[1][0](context, mapping, args[1][1]) 551
552 # apparently, repo could be a string that is the favicon?
553 repo = mapping.get('repo', '')
554 if isinstance(repo, str):
555 return thing
556
557 # preserve unknown symbol as literal so effects like 'red', 'bold',
558 # etc. don't need to be quoted
559 label = evalstringliteral(context, mapping, args[0])
560
561 return repo.ui.label(thing, label)
552 562
553 def latesttag(context, mapping, args): 563 def latesttag(context, mapping, args):
554 """:latesttag([pattern]): The global tags matching the given pattern on the 564 """:latesttag([pattern]): The global tags matching the given pattern on the
555 most recent globally tagged ancestor of this changeset.""" 565 most recent globally tagged ancestor of this changeset."""
556 if len(args) > 1: 566 if len(args) > 1: