Mercurial > hg
diff mercurial/cmdutil.py @ 27216:8117e2cd959e
graphlog: make node symbol templatable by ui.graphnodetemplate option
New ui.graphnodetemplate option allows us to colorize a node symbol by phase
or branch,
[ui]
graphnodetemplate = {label('graphnode.{phase}', graphnode)}
[color]
graphnode.draft = yellow bold
or use a variety of unicode emoji characters, and so on. (You'll need less-481
to display non-BMP unicode character.)
[ui]
graphnodetemplate = {ifeq(obsolete, 'stable', graphnode, '\xf0\x9f\x92\xa9')}
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Sat, 14 Nov 2015 17:25:43 +0900 |
parents | 60af96494a76 |
children | 43c00ca887d1 |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Sat Nov 14 17:02:57 2015 +0900 +++ b/mercurial/cmdutil.py Sat Nov 14 17:25:43 2015 +0900 @@ -2159,11 +2159,31 @@ return revs, expr, filematcher +def _graphnodeformatter(ui, displayer): + spec = ui.config('ui', 'graphnodetemplate') + if not spec: + return templatekw.showgraphnode # fast path for "{graphnode}" + + templ = formatter.gettemplater(ui, 'graphnode', spec) + cache = {} + if isinstance(displayer, changeset_templater): + cache = displayer.cache # reuse cache of slow templates + props = templatekw.keywords.copy() + props['templ'] = templ + props['cache'] = cache + def formatnode(repo, ctx): + props['ctx'] = ctx + props['repo'] = repo + props['revcache'] = {} + return templater.stringify(templ('graphnode', **props)) + return formatnode + def displaygraph(ui, repo, dag, displayer, edgefn, getrenamed=None, filematcher=None): + formatnode = _graphnodeformatter(ui, displayer) seen, state = [], graphmod.asciistate() for rev, type, ctx, parents in dag: - char = templatekw.showgraphnode(repo, ctx) + char = formatnode(repo, ctx) copies = None if getrenamed and ctx.rev(): copies = []