Mercurial > hg
diff hgext/color.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 | e35d7f131483 |
line wrap: on
line diff
--- a/hgext/color.py Thu Jun 11 22:58:27 2015 +0900 +++ b/hgext/color.py Thu Jun 11 23:04:14 2015 +0900 @@ -157,7 +157,6 @@ from mercurial import cmdutil, commands, dispatch, extensions, subrepo, util from mercurial import ui as uimod -from mercurial import templater, error from mercurial.i18n import _ cmdtable = {} @@ -480,24 +479,6 @@ for s in msg.split('\n')]) return msg -def templatelabel(context, mapping, args): - if len(args) != 2: - # i18n: "label" is a keyword - raise error.ParseError(_("label expects two arguments")) - - thing = templater.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 = templater.evalstringliteral(context, mapping, args[0]) - - return repo.ui.label(thing, label) - def uisetup(ui): if ui.plain(): return @@ -519,8 +500,6 @@ return orig(gitsub, commands, env, stream, cwd) extensions.wrapfunction(dispatch, '_runcommand', colorcmd) extensions.wrapfunction(subrepo.gitsubrepo, '_gitnodir', colorgit) - templatelabel.__doc__ = templater.funcs['label'].__doc__ - templater.funcs['label'] = templatelabel def extsetup(ui): commands.globalopts.append(