--- a/mercurial/cmdutil.py Sat Apr 22 21:29:00 2017 +0900
+++ b/mercurial/cmdutil.py Sat Apr 22 21:16:08 2017 +0900
@@ -1603,6 +1603,10 @@
cur = t + postfix
if mode and cur in self.t:
self._parts[t] = cur
+ else:
+ partnames = [p for p in self._parts.keys() if p != tmplspec.ref]
+ m = formatter.templatepartsmap(tmplspec, self.t, partnames)
+ self._parts.update(m)
if self._parts['docheader']:
self.ui.write(templater.stringify(self.t(self._parts['docheader'])))
--- a/tests/test-command-template.t Sat Apr 22 21:29:00 2017 +0900
+++ b/tests/test-command-template.t Sat Apr 22 21:16:08 2017 +0900
@@ -271,6 +271,24 @@
{"node": "29114dbae42b", "rev": 7}
}
+Test docheader, docfooter and separator in [templates] section
+
+ $ cat <<'EOF' >> .hg/hgrc
+ > [templates]
+ > myjson = ' {dict(rev, node|short)|json}'
+ > myjson:docheader = '\{\n'
+ > myjson:docfooter = '\n}\n'
+ > myjson:separator = ',\n'
+ > :docheader = 'should not be selected as a docheader for literal templates\n'
+ > EOF
+ $ hg log -l2 -Tmyjson
+ {
+ {"node": "95c24699272e", "rev": 8},
+ {"node": "29114dbae42b", "rev": 7}
+ }
+ $ hg log -l1 -T'{rev}\n'
+ 8
+
Template should precede style option
$ hg log -l1 --style default -T '{rev}\n'