diff mercurial/cmdutil.py @ 32969:050efe9a1644

changeset_templater: backport separator template from formatter As commented, this should be used with docheader and docfooter, not with header nor footer. That's one reason why no props are passed to templater when rendering a separator. (See map-cmdline.changelog to understand what the "header" is.)
author Yuya Nishihara <yuya@tcha.org>
date Sat, 17 Jun 2017 16:32:20 +0900
parents 3f07f12c6e10
children 6d79e9109908
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Sat Apr 22 21:50:51 2017 +0900
+++ b/mercurial/cmdutil.py	Sat Jun 17 16:32:20 2017 +0900
@@ -1587,7 +1587,8 @@
         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 @@
         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))