##// 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 props['templ'] = self.t
1502 props['templ'] = self.t
1503 props['ctx'] = ctx
1503 props['ctx'] = ctx
1504 props['repo'] = self.repo
1504 props['repo'] = self.repo
1505 props['ui'] = self.repo.ui
1505 props['revcache'] = {'copies': copies}
1506 props['revcache'] = {'copies': copies}
1506 props['cache'] = self.cache
1507 props['cache'] = self.cache
1507
1508
@@ -153,7 +153,7 b' class templateformatter(baseformatter):'
153 self._topic = topic
153 self._topic = topic
154 self._t = gettemplater(ui, topic, opts.get('template', ''))
154 self._t = gettemplater(ui, topic, opts.get('template', ''))
155 def _showitem(self):
155 def _showitem(self):
156 g = self._t(self._topic, **self._item)
156 g = self._t(self._topic, ui=self._ui, **self._item)
157 self._ui.write(templater.stringify(g))
157 self._ui.write(templater.stringify(g))
158
158
159 def lookuptemplate(ui, topic, tmpl):
159 def lookuptemplate(ui, topic, tmpl):
@@ -549,16 +549,15 b' def label(context, mapping, args):'
549
549
550 thing = evalstring(context, mapping, args[1])
550 thing = evalstring(context, mapping, args[1])
551
551
552 # apparently, repo could be a string that is the favicon?
552 ui = mapping.get('ui', '')
553 repo = mapping.get('repo', '')
553 if isinstance(ui, str):
554 if isinstance(repo, str):
555 return thing
554 return thing
556
555
557 # preserve unknown symbol as literal so effects like 'red', 'bold',
556 # preserve unknown symbol as literal so effects like 'red', 'bold',
558 # etc. don't need to be quoted
557 # etc. don't need to be quoted
559 label = evalstringliteral(context, mapping, args[0])
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 def latesttag(context, mapping, args):
562 def latesttag(context, mapping, args):
564 """:latesttag([pattern]): The global tags matching the given pattern on the
563 """:latesttag([pattern]): The global tags matching the given pattern on the
@@ -30,6 +30,15 b' hg status in repo root:'
30 [status.unknown|? ][status.unknown|b/in_b]
30 [status.unknown|? ][status.unknown|b/in_b]
31 [status.unknown|? ][status.unknown|in_root]
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 hg status . in repo root:
42 hg status . in repo root:
34
43
35 $ hg status --color=always .
44 $ hg status --color=always .
General Comments 0
You need to be logged in to leave comments. Login now