Mercurial > public > mercurial-scm > hg-stable
comparison 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 |
comparison
equal
deleted
inserted
replaced
27215:5b8da5643a8a | 27216:8117e2cd959e |
---|---|
2157 limitedrevs.append(r) | 2157 limitedrevs.append(r) |
2158 revs = revset.baseset(limitedrevs) | 2158 revs = revset.baseset(limitedrevs) |
2159 | 2159 |
2160 return revs, expr, filematcher | 2160 return revs, expr, filematcher |
2161 | 2161 |
2162 def _graphnodeformatter(ui, displayer): | |
2163 spec = ui.config('ui', 'graphnodetemplate') | |
2164 if not spec: | |
2165 return templatekw.showgraphnode # fast path for "{graphnode}" | |
2166 | |
2167 templ = formatter.gettemplater(ui, 'graphnode', spec) | |
2168 cache = {} | |
2169 if isinstance(displayer, changeset_templater): | |
2170 cache = displayer.cache # reuse cache of slow templates | |
2171 props = templatekw.keywords.copy() | |
2172 props['templ'] = templ | |
2173 props['cache'] = cache | |
2174 def formatnode(repo, ctx): | |
2175 props['ctx'] = ctx | |
2176 props['repo'] = repo | |
2177 props['revcache'] = {} | |
2178 return templater.stringify(templ('graphnode', **props)) | |
2179 return formatnode | |
2180 | |
2162 def displaygraph(ui, repo, dag, displayer, edgefn, getrenamed=None, | 2181 def displaygraph(ui, repo, dag, displayer, edgefn, getrenamed=None, |
2163 filematcher=None): | 2182 filematcher=None): |
2183 formatnode = _graphnodeformatter(ui, displayer) | |
2164 seen, state = [], graphmod.asciistate() | 2184 seen, state = [], graphmod.asciistate() |
2165 for rev, type, ctx, parents in dag: | 2185 for rev, type, ctx, parents in dag: |
2166 char = templatekw.showgraphnode(repo, ctx) | 2186 char = formatnode(repo, ctx) |
2167 copies = None | 2187 copies = None |
2168 if getrenamed and ctx.rev(): | 2188 if getrenamed and ctx.rev(): |
2169 copies = [] | 2189 copies = [] |
2170 for fn in ctx.files(): | 2190 for fn in ctx.files(): |
2171 rename = getrenamed(fn, ctx.rev()) | 2191 rename = getrenamed(fn, ctx.rev()) |