changeset 31171:1ec89cf0ea49

templatekw: move defaulttmpl constant from changeset_templater These templates are used when rendering inner lists of some template keywords, so it makes sense to define them in templatekw. This allows us to reuse them to create a templateformatter knowing changectx.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 25 Feb 2017 16:38:26 +0900
parents e64b70c96338
children 16272d8c24f6
files mercurial/cmdutil.py mercurial/templatekw.py
diffstat 2 files changed, 12 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Sat Feb 25 22:04:30 2017 +0900
+++ b/mercurial/cmdutil.py	Sat Feb 25 16:38:26 2017 +0900
@@ -1442,16 +1442,8 @@
 
     def __init__(self, ui, repo, matchfn, diffopts, tmpl, mapfile, buffered):
         changeset_printer.__init__(self, ui, repo, matchfn, diffopts, buffered)
-        defaulttempl = {
-            'parent': '{rev}:{node|formatnode} ',
-            'manifest': '{rev}:{node|formatnode}',
-            'file_copy': '{name} ({source})',
-            'envvar': '{key}={value}',
-            'extra': '{key}={value|stringescape}'
-            }
-        # filecopy is preserved for compatibility reasons
-        defaulttempl['filecopy'] = defaulttempl['file_copy']
         assert not (tmpl and mapfile)
+        defaulttempl = templatekw.defaulttempl
         if mapfile:
             self.t = templater.templater.frommapfile(mapfile,
                                                      cache=defaulttempl)
--- a/mercurial/templatekw.py	Sat Feb 25 22:04:30 2017 +0900
+++ b/mercurial/templatekw.py	Sat Feb 25 16:38:26 2017 +0900
@@ -204,6 +204,17 @@
 
     return getrenamed
 
+# default templates internally used for rendering of lists
+defaulttempl = {
+    'parent': '{rev}:{node|formatnode} ',
+    'manifest': '{rev}:{node|formatnode}',
+    'file_copy': '{name} ({source})',
+    'envvar': '{key}={value}',
+    'extra': '{key}={value|stringescape}'
+}
+# filecopy is preserved for compatibility reasons
+defaulttempl['filecopy'] = defaulttempl['file_copy']
+
 # keywords are callables like:
 # fn(repo, ctx, templ, cache, revcache, **args)
 # with: