# HG changeset patch # User Robert Bachmann # Date 2009-12-28 16:55:52 # Node ID 56284451a22c47995d8d2fac6d40722e14a7ac05 # Parent c7355a0e1f39968ab39a62e9bf059e5129a61497 Added support for templatevar "footer" to cmdutil.py diff --git a/hgext/children.py b/hgext/children.py --- a/hgext/children.py +++ b/hgext/children.py @@ -33,7 +33,7 @@ def children(ui, repo, file_=None, **opt displayer = cmdutil.show_changeset(ui, repo, opts) for cctx in ctx.children(): displayer.show(cctx) - + displayer.close() cmdtable = { "children": diff --git a/hgext/transplant.py b/hgext/transplant.py --- a/hgext/transplant.py +++ b/hgext/transplant.py @@ -430,6 +430,7 @@ def browserevs(ui, repo, nodes, opts): transplants = () merges = () break + displayer.close() return (transplants, merges) def transplant(ui, repo, *revs, **opts): diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -637,6 +637,7 @@ class changeset_printer(object): self.header = {} self.hunk = {} self.lastheader = None + self.footer = None def flush(self, rev): if rev in self.header: @@ -651,6 +652,10 @@ class changeset_printer(object): 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 @@ class changeset_templater(changeset_prin (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 @@ class changeset_templater(changeset_prin 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])) diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -306,6 +306,7 @@ def bisect(ui, repo, rev=None, extra=Non "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 @@ def heads(ui, repo, *branchrevs, **opts) 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 @@ def incoming(ui, repo, source="default", continue count += 1 displayer.show(other[n]) + displayer.close() finally: if hasattr(other, 'close'): other.close() @@ -2066,6 +2069,7 @@ def log(ui, repo, *pats, **opts): 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 @@ def merge(ui, repo, node=None, **opts): 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 @@ def outgoing(ui, repo, dest=None, **opts 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 @@ def parents(ui, repo, file_=None, **opts 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 @@ def tip(ui, repo, **opts): 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