1578 class changeset_templater(changeset_printer): |
1578 class changeset_templater(changeset_printer): |
1579 '''format changeset information.''' |
1579 '''format changeset information.''' |
1580 |
1580 |
1581 def __init__(self, ui, repo, matchfn, diffopts, tmpl, mapfile, buffered): |
1581 def __init__(self, ui, repo, matchfn, diffopts, tmpl, mapfile, buffered): |
1582 changeset_printer.__init__(self, ui, repo, matchfn, diffopts, buffered) |
1582 changeset_printer.__init__(self, ui, repo, matchfn, diffopts, buffered) |
1583 self.t = formatter.loadtemplater(ui, 'changeset', (tmpl, mapfile), |
1583 tmplspec = logtemplatespec(tmpl, mapfile) |
|
1584 self.t = formatter.loadtemplater(ui, 'changeset', tmplspec, |
1584 cache=templatekw.defaulttempl) |
1585 cache=templatekw.defaulttempl) |
1585 self._counter = itertools.count() |
1586 self._counter = itertools.count() |
1586 self.cache = {} |
1587 self.cache = {} |
1587 |
1588 |
1588 # find correct templates for current mode |
1589 # find correct templates for current mode |
1644 if self._parts['footer']: |
1645 if self._parts['footer']: |
1645 if not self.footer: |
1646 if not self.footer: |
1646 self.footer = templater.stringify( |
1647 self.footer = templater.stringify( |
1647 self.t(self._parts['footer'], **props)) |
1648 self.t(self._parts['footer'], **props)) |
1648 |
1649 |
|
1650 logtemplatespec = formatter.templatespec |
|
1651 |
1649 def _lookuplogtemplate(ui, tmpl, style): |
1652 def _lookuplogtemplate(ui, tmpl, style): |
1650 """Find the template matching the given template spec or style |
1653 """Find the template matching the given template spec or style |
1651 |
1654 |
1652 See formatter.lookuptemplate() for details. |
1655 See formatter.lookuptemplate() for details. |
1653 """ |
1656 """ |
1654 |
1657 |
1655 # ui settings |
1658 # ui settings |
1656 if not tmpl and not style: # template are stronger than style |
1659 if not tmpl and not style: # template are stronger than style |
1657 tmpl = ui.config('ui', 'logtemplate') |
1660 tmpl = ui.config('ui', 'logtemplate') |
1658 if tmpl: |
1661 if tmpl: |
1659 return templater.unquotestring(tmpl), None |
1662 return logtemplatespec(templater.unquotestring(tmpl), None) |
1660 else: |
1663 else: |
1661 style = util.expandpath(ui.config('ui', 'style', '')) |
1664 style = util.expandpath(ui.config('ui', 'style', '')) |
1662 |
1665 |
1663 if not tmpl and style: |
1666 if not tmpl and style: |
1664 mapfile = style |
1667 mapfile = style |
1665 if not os.path.split(mapfile)[0]: |
1668 if not os.path.split(mapfile)[0]: |
1666 mapname = (templater.templatepath('map-cmdline.' + mapfile) |
1669 mapname = (templater.templatepath('map-cmdline.' + mapfile) |
1667 or templater.templatepath(mapfile)) |
1670 or templater.templatepath(mapfile)) |
1668 if mapname: |
1671 if mapname: |
1669 mapfile = mapname |
1672 mapfile = mapname |
1670 return None, mapfile |
1673 return logtemplatespec(None, mapfile) |
1671 |
1674 |
1672 if not tmpl: |
1675 if not tmpl: |
1673 return None, None |
1676 return logtemplatespec(None, None) |
1674 |
1677 |
1675 return formatter.lookuptemplate(ui, 'changeset', tmpl) |
1678 return formatter.lookuptemplate(ui, 'changeset', tmpl) |
1676 |
1679 |
1677 def makelogtemplater(ui, repo, tmpl, buffered=False): |
1680 def makelogtemplater(ui, repo, tmpl, buffered=False): |
1678 """Create a changeset_templater from a literal template 'tmpl'""" |
1681 """Create a changeset_templater from a literal template 'tmpl'""" |