Mercurial > hg
comparison mercurial/cmdutil.py @ 26222:3095b1027661
templater: add new docheader/footer components for XML (issue4135)
The existing header/footer components were templated per-changeset,
and thus couldn't be correctly printed for an empty log
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Wed, 26 Aug 2015 16:27:14 -0500 |
parents | ab1c6e4efda4 |
children | d1530c6e8613 |
comparison
equal
deleted
inserted
replaced
26221:ae65b1b4cb46 | 26222:3095b1027661 |
---|---|
1420 (self.ui.verbose, 'verbose'), | 1420 (self.ui.verbose, 'verbose'), |
1421 (self.ui.quiet, 'quiet'), | 1421 (self.ui.quiet, 'quiet'), |
1422 (self.ui.debugflag, 'debug'), | 1422 (self.ui.debugflag, 'debug'), |
1423 ] | 1423 ] |
1424 | 1424 |
1425 self._parts = {'header': '', 'footer': '', 'changeset': 'changeset'} | 1425 self._parts = {'header': '', 'footer': '', 'changeset': 'changeset', |
1426 'docheader': '', 'docfooter': ''} | |
1426 for mode, postfix in tmplmodes: | 1427 for mode, postfix in tmplmodes: |
1427 for t in self._parts: | 1428 for t in self._parts: |
1428 cur = t | 1429 cur = t |
1429 if postfix: | 1430 if postfix: |
1430 cur += "_" + postfix | 1431 cur += "_" + postfix |
1431 if mode and cur in self.t: | 1432 if mode and cur in self.t: |
1432 self._parts[t] = cur | 1433 self._parts[t] = cur |
1434 | |
1435 if self._parts['docheader']: | |
1436 self.ui.write(templater.stringify(self.t(self._parts['docheader']))) | |
1437 | |
1438 def close(self): | |
1439 if self._parts['docfooter']: | |
1440 if not self.footer: | |
1441 self.footer = "" | |
1442 self.footer += templater.stringify(self.t(self._parts['docfooter'])) | |
1443 return super(changeset_templater, self).close() | |
1433 | 1444 |
1434 def _show(self, ctx, copies, matchfn, props): | 1445 def _show(self, ctx, copies, matchfn, props): |
1435 '''show a single changeset or file revision''' | 1446 '''show a single changeset or file revision''' |
1436 | 1447 |
1437 showlist = templatekw.showlist | 1448 showlist = templatekw.showlist |