Mercurial > hg
changeset 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 | c7355a0e1f39 |
children | 000546ec7ced |
files | hgext/children.py hgext/transplant.py mercurial/cmdutil.py mercurial/commands.py |
diffstat | 4 files changed, 23 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/children.py Tue Dec 29 16:00:38 2009 +0100 +++ b/hgext/children.py Mon Dec 28 17:55:52 2009 +0100 @@ -33,7 +33,7 @@ displayer = cmdutil.show_changeset(ui, repo, opts) for cctx in ctx.children(): displayer.show(cctx) - + displayer.close() cmdtable = { "children":
--- a/hgext/transplant.py Tue Dec 29 16:00:38 2009 +0100 +++ b/hgext/transplant.py Mon Dec 28 17:55:52 2009 +0100 @@ -430,6 +430,7 @@ transplants = () merges = () break + displayer.close() return (transplants, merges) def transplant(ui, repo, *revs, **opts):
--- a/mercurial/cmdutil.py Tue Dec 29 16:00:38 2009 +0100 +++ b/mercurial/cmdutil.py Mon Dec 28 17:55:52 2009 +0100 @@ -637,6 +637,7 @@ self.header = {} self.hunk = {} self.lastheader = None + self.footer = None def flush(self, rev): if rev in self.header: @@ -651,6 +652,10 @@ return 1 return 0 + def close(self): + if self.footer: + self.ui.write(self.footer) + def show(self, ctx, copies=None, **props): if self.buffered: self.ui.pushbuffer() @@ -817,7 +822,7 @@ (self.ui.debugflag, 'debug'), ] - types = {'header': '', 'changeset': 'changeset'} + types = {'header': '', 'footer':'', 'changeset': 'changeset'} for mode, postfix in tmplmodes: for type in types: cur = postfix and ('%s_%s' % (type, postfix)) or type @@ -839,6 +844,11 @@ self.ui.write(templater.stringify(self.t(key, **props))) self.showpatch(ctx.node()) + if types['header']: + if not self.footer: + self.footer = templater.stringify(self.t(types['footer'], + **props)) + except KeyError, inst: msg = _("%s: no key named '%s'") raise util.Abort(msg % (self.t.mapfile, inst.args[0]))
--- a/mercurial/commands.py Tue Dec 29 16:00:38 2009 +0100 +++ b/mercurial/commands.py Mon Dec 28 17:55:52 2009 +0100 @@ -306,6 +306,7 @@ "bad revision could be any of:\n")) for n in nodes: displayer.show(repo[n]) + displayer.close() def check_state(state, interactive=True): if not state['good'] or not state['bad']: @@ -1443,6 +1444,7 @@ displayer = cmdutil.show_changeset(ui, repo, opts) for n in heads: displayer.show(repo[n]) + displayer.close() def help_(ui, name=None, with_version=False): """show help for a given topic or a help overview @@ -1931,6 +1933,7 @@ continue count += 1 displayer.show(other[n]) + displayer.close() finally: if hasattr(other, 'close'): other.close() @@ -2066,6 +2069,7 @@ break if displayer.flush(ctx.rev()): count += 1 + displayer.close() def manifest(ui, repo, node=None, rev=None): """output the current or given revision of the project manifest @@ -2148,6 +2152,7 @@ for node in repo.changelog.nodesbetween(roots=roots, heads=heads)[0]: if node not in roots: displayer.show(repo[node]) + displayer.close() return 0 return hg.merge(repo, node, force=opts.get('force')) @@ -2186,6 +2191,7 @@ continue count += 1 displayer.show(repo[n]) + displayer.close() def parents(ui, repo, file_=None, **opts): """show the parents of the working directory or revision @@ -2226,6 +2232,7 @@ for n in p: if n != nullid: displayer.show(repo[n]) + displayer.close() def paths(ui, repo, search=None): """show aliases for remote repositories @@ -3106,7 +3113,9 @@ that repository becomes the current tip. The "tip" tag is special and cannot be renamed or assigned to a different changeset. """ - cmdutil.show_changeset(ui, repo, opts).show(repo[len(repo) - 1]) + displayer = cmdutil.show_changeset(ui, repo, opts) + displayer.show(repo[len(repo) - 1]) + displayer.close() def unbundle(ui, repo, fname1, *fnames, **opts): """apply one or more changegroup files