##// END OF EJS Templates
formatter: make labels work with templated output...
Kostia Balytskyi -
r28384:3356bf61 default
parent child Browse files
Show More
@@ -1502,6 +1502,7 b' class changeset_templater(changeset_prin'
1502 1502 props['templ'] = self.t
1503 1503 props['ctx'] = ctx
1504 1504 props['repo'] = self.repo
1505 props['ui'] = self.repo.ui
1505 1506 props['revcache'] = {'copies': copies}
1506 1507 props['cache'] = self.cache
1507 1508
@@ -153,7 +153,7 b' class templateformatter(baseformatter):'
153 153 self._topic = topic
154 154 self._t = gettemplater(ui, topic, opts.get('template', ''))
155 155 def _showitem(self):
156 g = self._t(self._topic, **self._item)
156 g = self._t(self._topic, ui=self._ui, **self._item)
157 157 self._ui.write(templater.stringify(g))
158 158
159 159 def lookuptemplate(ui, topic, tmpl):
@@ -549,16 +549,15 b' def label(context, mapping, args):'
549 549
550 550 thing = evalstring(context, mapping, args[1])
551 551
552 # apparently, repo could be a string that is the favicon?
553 repo = mapping.get('repo', '')
554 if isinstance(repo, str):
552 ui = mapping.get('ui', '')
553 if isinstance(ui, str):
555 554 return thing
556 555
557 556 # preserve unknown symbol as literal so effects like 'red', 'bold',
558 557 # etc. don't need to be quoted
559 558 label = evalstringliteral(context, mapping, args[0])
560 559
561 return repo.ui.label(thing, label)
560 return ui.label(thing, label)
562 561
563 562 def latesttag(context, mapping, args):
564 563 """:latesttag([pattern]): The global tags matching the given pattern on the
@@ -30,6 +30,15 b' hg status in repo root:'
30 30 [status.unknown|? ][status.unknown|b/in_b]
31 31 [status.unknown|? ][status.unknown|in_root]
32 32
33 hg status with template
34 $ hg status -T "{label('red', path)}\n" --color=debug
35 [red|a/1/in_a_1]
36 [red|a/in_a]
37 [red|b/1/in_b_1]
38 [red|b/2/in_b_2]
39 [red|b/in_b]
40 [red|in_root]
41
33 42 hg status . in repo root:
34 43
35 44 $ hg status --color=always .
General Comments 0
You need to be logged in to leave comments. Login now