[PATCH 3 of 5] templatekw: move defaulttmpl constant from changeset_templater
Yuya Nishihara
yuya at tcha.org
Sat Feb 25 09:51:32 EST 2017
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1488008306 -32400
# Sat Feb 25 16:38:26 2017 +0900
# Node ID f8d8d68b01c7b60dea259716e5a675488e68ca3d
# Parent 67e5135769cfbe56bc9d943d6efcb9e347245427
# EXP-Topic formatter
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.
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1442,16 +1442,8 @@ class changeset_templater(changeset_prin
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)
diff --git a/mercurial/templatekw.py b/mercurial/templatekw.py
--- a/mercurial/templatekw.py
+++ b/mercurial/templatekw.py
@@ -204,6 +204,17 @@ def getrenamedfn(repo, endrev=None):
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:
More information about the Mercurial-devel
mailing list