Comments
Patch
@@ -1587,7 +1587,8 @@ class changeset_templater(changeset_prin
self._tref = tmplspec.ref
self._parts = {'header': '', 'footer': '',
tmplspec.ref: tmplspec.ref,
- 'docheader': '', 'docfooter': ''}
+ 'docheader': '', 'docfooter': '',
+ 'separator': ''}
if tmplspec.mapfile:
# find correct templates for current mode, for backward
# compatibility with 'log -v/-q/--debug' using a mapfile
@@ -1621,11 +1622,17 @@ class changeset_templater(changeset_prin
props['ctx'] = ctx
props['repo'] = self.repo
props['ui'] = self.repo.ui
- props['index'] = next(self._counter)
+ props['index'] = index = next(self._counter)
props['revcache'] = {'copies': copies}
props['cache'] = self.cache
props = pycompat.strkwargs(props)
+ # write separator, which wouldn't work well with the header part below
+ # since there's inherently a conflict between header (across items) and
+ # separator (per item)
+ if self._parts['separator'] and index > 0:
+ self.ui.write(templater.stringify(self.t(self._parts['separator'])))
+
# write header
if self._parts['header']:
h = templater.stringify(self.t(self._parts['header'], **props))
@@ -257,6 +257,20 @@ Test template map inheritance
summary: third
+Test docheader, docfooter and separator in template map
+
+ $ cat <<'EOF' > map-myjson
+ > docheader = '\{\n'
+ > docfooter = '\n}\n'
+ > separator = ',\n'
+ > changeset = ' {dict(rev, node|short)|json}'
+ > EOF
+ $ hg log -l2 -T./map-myjson
+ {
+ {"node": "95c24699272e", "rev": 8},
+ {"node": "29114dbae42b", "rev": 7}
+ }
+
Template should precede style option
$ hg log -l1 --style default -T '{rev}\n'