comparison 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
comparison
equal deleted inserted replaced
32968:5100ce217dfa 32969:050efe9a1644
1585 self.cache = {} 1585 self.cache = {}
1586 1586
1587 self._tref = tmplspec.ref 1587 self._tref = tmplspec.ref
1588 self._parts = {'header': '', 'footer': '', 1588 self._parts = {'header': '', 'footer': '',
1589 tmplspec.ref: tmplspec.ref, 1589 tmplspec.ref: tmplspec.ref,
1590 'docheader': '', 'docfooter': ''} 1590 'docheader': '', 'docfooter': '',
1591 'separator': ''}
1591 if tmplspec.mapfile: 1592 if tmplspec.mapfile:
1592 # find correct templates for current mode, for backward 1593 # find correct templates for current mode, for backward
1593 # compatibility with 'log -v/-q/--debug' using a mapfile 1594 # compatibility with 'log -v/-q/--debug' using a mapfile
1594 tmplmodes = [ 1595 tmplmodes = [
1595 (True, ''), 1596 (True, ''),
1619 props.update(templatekw.keywords) 1620 props.update(templatekw.keywords)
1620 props['templ'] = self.t 1621 props['templ'] = self.t
1621 props['ctx'] = ctx 1622 props['ctx'] = ctx
1622 props['repo'] = self.repo 1623 props['repo'] = self.repo
1623 props['ui'] = self.repo.ui 1624 props['ui'] = self.repo.ui
1624 props['index'] = next(self._counter) 1625 props['index'] = index = next(self._counter)
1625 props['revcache'] = {'copies': copies} 1626 props['revcache'] = {'copies': copies}
1626 props['cache'] = self.cache 1627 props['cache'] = self.cache
1627 props = pycompat.strkwargs(props) 1628 props = pycompat.strkwargs(props)
1629
1630 # write separator, which wouldn't work well with the header part below
1631 # since there's inherently a conflict between header (across items) and
1632 # separator (per item)
1633 if self._parts['separator'] and index > 0:
1634 self.ui.write(templater.stringify(self.t(self._parts['separator'])))
1628 1635
1629 # write header 1636 # write header
1630 if self._parts['header']: 1637 if self._parts['header']:
1631 h = templater.stringify(self.t(self._parts['header'], **props)) 1638 h = templater.stringify(self.t(self._parts['header'], **props))
1632 if self.buffered: 1639 if self.buffered: