Show More
@@ -94,14 +94,14 b' Nested example:' | |||||
94 |
|
94 | |||
95 | >>> def subrepos(ui, fm): |
|
95 | >>> def subrepos(ui, fm): | |
96 | ... fm.startitem() |
|
96 | ... fm.startitem() | |
97 | ... fm.write(b'repo', b'[%s]\\n', b'baz') |
|
97 | ... fm.write(b'reponame', b'[%s]\\n', b'baz') | |
98 | ... files(ui, fm.nested(b'files')) |
|
98 | ... files(ui, fm.nested(b'files')) | |
99 | ... fm.end() |
|
99 | ... fm.end() | |
100 | >>> show(subrepos) |
|
100 | >>> show(subrepos) | |
101 | [baz] |
|
101 | [baz] | |
102 | foo |
|
102 | foo | |
103 | bar |
|
103 | bar | |
104 | >>> show(subrepos, template=b'{repo}: {join(files % "{path}", ", ")}\\n') |
|
104 | >>> show(subrepos, template=b'{reponame}: {join(files % "{path}", ", ")}\\n') | |
105 | baz: foo, bar |
|
105 | baz: foo, bar | |
106 | """ |
|
106 | """ | |
107 |
|
107 | |||
@@ -491,7 +491,9 b' def templateresources(ui, repo=None):' | |||||
491 | and function""" |
|
491 | and function""" | |
492 | return { |
|
492 | return { | |
493 | 'cache': {}, # for templatekw/funcs to store reusable data |
|
493 | 'cache': {}, # for templatekw/funcs to store reusable data | |
|
494 | 'ctx': None, | |||
494 | 'repo': repo, |
|
495 | 'repo': repo, | |
|
496 | 'revcache': None, # per-ctx cache; set later | |||
495 | 'ui': ui, |
|
497 | 'ui': ui, | |
496 | } |
|
498 | } | |
497 |
|
499 |
@@ -1320,7 +1320,9 b' class engine(object):' | |||||
1320 |
|
1320 | |||
1321 | def symbol(self, mapping, key): |
|
1321 | def symbol(self, mapping, key): | |
1322 | """Resolve symbol to value or function; None if nothing found""" |
|
1322 | """Resolve symbol to value or function; None if nothing found""" | |
1323 |
v = |
|
1323 | v = None | |
|
1324 | if key not in self._resources: | |||
|
1325 | v = mapping.get(key) | |||
1324 | if v is None: |
|
1326 | if v is None: | |
1325 | v = self._defaults.get(key) |
|
1327 | v = self._defaults.get(key) | |
1326 | return v |
|
1328 | return v | |
@@ -1328,11 +1330,13 b' class engine(object):' | |||||
1328 | def resource(self, mapping, key): |
|
1330 | def resource(self, mapping, key): | |
1329 | """Return internal data (e.g. cache) used for keyword/function |
|
1331 | """Return internal data (e.g. cache) used for keyword/function | |
1330 | evaluation""" |
|
1332 | evaluation""" | |
1331 |
v = |
|
1333 | v = None | |
|
1334 | if key in self._resources: | |||
|
1335 | v = mapping.get(key) | |||
1332 | if v is None: |
|
1336 | if v is None: | |
1333 | v = self._resources.get(key) |
|
1337 | v = self._resources.get(key) | |
1334 | if v is None: |
|
1338 | if v is None: | |
1335 | raise KeyError |
|
1339 | raise error.Abort(_('template resource not available: %s') % key) | |
1336 | return v |
|
1340 | return v | |
1337 |
|
1341 | |||
1338 | def _load(self, t): |
|
1342 | def _load(self, t): |
@@ -206,7 +206,13 b' never cause crash:' | |||||
206 |
|
206 | |||
207 | Internal resources shouldn't be exposed (issue5699): |
|
207 | Internal resources shouldn't be exposed (issue5699): | |
208 |
|
208 | |||
209 | $ hg log -r. -T '{cache}{repo}{templ}{ui}' |
|
209 | $ hg log -r. -T '{cache}{ctx}{repo}{revcache}{templ}{ui}' | |
|
210 | ||||
|
211 | Never crash on internal resource not available: | |||
|
212 | ||||
|
213 | $ hg --cwd .. debugtemplate '{"c0bebeef"|shortest}\n' | |||
|
214 | abort: template resource not available: ctx | |||
|
215 | [255] | |||
210 |
|
216 | |||
211 | Quoting for ui.logtemplate |
|
217 | Quoting for ui.logtemplate | |
212 |
|
218 |
General Comments 0
You need to be logged in to leave comments.
Login now