diff mercurial/formatter.py @ 35470:a33be093ec62

templater: look up symbols/resources as if they were separated (issue5699) It wouldn't be easy to split the mapping dict into (symbols, resources). This patch instead rejects invalid lookup taking resources.keys() as source of truth. The doctest is updated since mapping['repo'] is now reserved for a repo object.
author Yuya Nishihara <yuya@tcha.org>
date Thu, 21 Dec 2017 22:17:39 +0900
parents f1c54d003327
children 817a3d20dd01
line wrap: on
line diff
--- a/mercurial/formatter.py	Thu Dec 21 22:05:30 2017 +0900
+++ b/mercurial/formatter.py	Thu Dec 21 22:17:39 2017 +0900
@@ -94,14 +94,14 @@
 
 >>> def subrepos(ui, fm):
 ...     fm.startitem()
-...     fm.write(b'repo', b'[%s]\\n', b'baz')
+...     fm.write(b'reponame', b'[%s]\\n', b'baz')
 ...     files(ui, fm.nested(b'files'))
 ...     fm.end()
 >>> show(subrepos)
 [baz]
 foo
 bar
->>> show(subrepos, template=b'{repo}: {join(files % "{path}", ", ")}\\n')
+>>> show(subrepos, template=b'{reponame}: {join(files % "{path}", ", ")}\\n')
 baz: foo, bar
 """
 
@@ -491,7 +491,9 @@
     and function"""
     return {
         'cache': {},  # for templatekw/funcs to store reusable data
+        'ctx': None,
         'repo': repo,
+        'revcache': None,  # per-ctx cache; set later
         'ui': ui,
     }