Mercurial > public > mercurial-scm > hg
comparison mercurial/cmdutil.py @ 10152:56284451a22c
Added support for templatevar "footer" to cmdutil.py
author | Robert Bachmann <rbachm@gmail.com> |
---|---|
date | Mon, 28 Dec 2009 17:55:52 +0100 |
parents | 27457d31ae3f |
children | 48653dea23dd |
comparison
equal
deleted
inserted
replaced
10151:c7355a0e1f39 | 10152:56284451a22c |
---|---|
635 self.patch = patch | 635 self.patch = patch |
636 self.diffopts = diffopts | 636 self.diffopts = diffopts |
637 self.header = {} | 637 self.header = {} |
638 self.hunk = {} | 638 self.hunk = {} |
639 self.lastheader = None | 639 self.lastheader = None |
640 self.footer = None | |
640 | 641 |
641 def flush(self, rev): | 642 def flush(self, rev): |
642 if rev in self.header: | 643 if rev in self.header: |
643 h = self.header[rev] | 644 h = self.header[rev] |
644 if h != self.lastheader: | 645 if h != self.lastheader: |
648 if rev in self.hunk: | 649 if rev in self.hunk: |
649 self.ui.write(self.hunk[rev]) | 650 self.ui.write(self.hunk[rev]) |
650 del self.hunk[rev] | 651 del self.hunk[rev] |
651 return 1 | 652 return 1 |
652 return 0 | 653 return 0 |
654 | |
655 def close(self): | |
656 if self.footer: | |
657 self.ui.write(self.footer) | |
653 | 658 |
654 def show(self, ctx, copies=None, **props): | 659 def show(self, ctx, copies=None, **props): |
655 if self.buffered: | 660 if self.buffered: |
656 self.ui.pushbuffer() | 661 self.ui.pushbuffer() |
657 self._show(ctx, copies, props) | 662 self._show(ctx, copies, props) |
815 (self.ui.verbose, 'verbose'), | 820 (self.ui.verbose, 'verbose'), |
816 (self.ui.quiet, 'quiet'), | 821 (self.ui.quiet, 'quiet'), |
817 (self.ui.debugflag, 'debug'), | 822 (self.ui.debugflag, 'debug'), |
818 ] | 823 ] |
819 | 824 |
820 types = {'header': '', 'changeset': 'changeset'} | 825 types = {'header': '', 'footer':'', 'changeset': 'changeset'} |
821 for mode, postfix in tmplmodes: | 826 for mode, postfix in tmplmodes: |
822 for type in types: | 827 for type in types: |
823 cur = postfix and ('%s_%s' % (type, postfix)) or type | 828 cur = postfix and ('%s_%s' % (type, postfix)) or type |
824 if mode and cur in self.t: | 829 if mode and cur in self.t: |
825 types[type] = cur | 830 types[type] = cur |
836 | 841 |
837 # write changeset metadata, then patch if requested | 842 # write changeset metadata, then patch if requested |
838 key = types['changeset'] | 843 key = types['changeset'] |
839 self.ui.write(templater.stringify(self.t(key, **props))) | 844 self.ui.write(templater.stringify(self.t(key, **props))) |
840 self.showpatch(ctx.node()) | 845 self.showpatch(ctx.node()) |
846 | |
847 if types['header']: | |
848 if not self.footer: | |
849 self.footer = templater.stringify(self.t(types['footer'], | |
850 **props)) | |
841 | 851 |
842 except KeyError, inst: | 852 except KeyError, inst: |
843 msg = _("%s: no key named '%s'") | 853 msg = _("%s: no key named '%s'") |
844 raise util.Abort(msg % (self.t.mapfile, inst.args[0])) | 854 raise util.Abort(msg % (self.t.mapfile, inst.args[0])) |
845 except SyntaxError, inst: | 855 except SyntaxError, inst: |