##// END OF EJS Templates
Added support for templatevar "footer" to cmdutil.py
Robert Bachmann -
r10152:56284451 default
parent child Browse files
Show More
@@ -33,7 +33,7 b' def children(ui, repo, file_=None, **opt'
33 displayer = cmdutil.show_changeset(ui, repo, opts)
33 displayer = cmdutil.show_changeset(ui, repo, opts)
34 for cctx in ctx.children():
34 for cctx in ctx.children():
35 displayer.show(cctx)
35 displayer.show(cctx)
36
36 displayer.close()
37
37
38 cmdtable = {
38 cmdtable = {
39 "children":
39 "children":
@@ -430,6 +430,7 b' def browserevs(ui, repo, nodes, opts):'
430 transplants = ()
430 transplants = ()
431 merges = ()
431 merges = ()
432 break
432 break
433 displayer.close()
433 return (transplants, merges)
434 return (transplants, merges)
434
435
435 def transplant(ui, repo, *revs, **opts):
436 def transplant(ui, repo, *revs, **opts):
@@ -637,6 +637,7 b' class changeset_printer(object):'
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:
@@ -651,6 +652,10 b' class changeset_printer(object):'
651 return 1
652 return 1
652 return 0
653 return 0
653
654
655 def close(self):
656 if self.footer:
657 self.ui.write(self.footer)
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()
@@ -817,7 +822,7 b' class changeset_templater(changeset_prin'
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
@@ -839,6 +844,11 b' class changeset_templater(changeset_prin'
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())
841
846
847 if types['header']:
848 if not self.footer:
849 self.footer = templater.stringify(self.t(types['footer'],
850 **props))
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]))
@@ -306,6 +306,7 b' def bisect(ui, repo, rev=None, extra=Non'
306 "bad revision could be any of:\n"))
306 "bad revision could be any of:\n"))
307 for n in nodes:
307 for n in nodes:
308 displayer.show(repo[n])
308 displayer.show(repo[n])
309 displayer.close()
309
310
310 def check_state(state, interactive=True):
311 def check_state(state, interactive=True):
311 if not state['good'] or not state['bad']:
312 if not state['good'] or not state['bad']:
@@ -1443,6 +1444,7 b' def heads(ui, repo, *branchrevs, **opts)'
1443 displayer = cmdutil.show_changeset(ui, repo, opts)
1444 displayer = cmdutil.show_changeset(ui, repo, opts)
1444 for n in heads:
1445 for n in heads:
1445 displayer.show(repo[n])
1446 displayer.show(repo[n])
1447 displayer.close()
1446
1448
1447 def help_(ui, name=None, with_version=False):
1449 def help_(ui, name=None, with_version=False):
1448 """show help for a given topic or a help overview
1450 """show help for a given topic or a help overview
@@ -1931,6 +1933,7 b' def incoming(ui, repo, source="default",'
1931 continue
1933 continue
1932 count += 1
1934 count += 1
1933 displayer.show(other[n])
1935 displayer.show(other[n])
1936 displayer.close()
1934 finally:
1937 finally:
1935 if hasattr(other, 'close'):
1938 if hasattr(other, 'close'):
1936 other.close()
1939 other.close()
@@ -2066,6 +2069,7 b' def log(ui, repo, *pats, **opts):'
2066 break
2069 break
2067 if displayer.flush(ctx.rev()):
2070 if displayer.flush(ctx.rev()):
2068 count += 1
2071 count += 1
2072 displayer.close()
2069
2073
2070 def manifest(ui, repo, node=None, rev=None):
2074 def manifest(ui, repo, node=None, rev=None):
2071 """output the current or given revision of the project manifest
2075 """output the current or given revision of the project manifest
@@ -2148,6 +2152,7 b' def merge(ui, repo, node=None, **opts):'
2148 for node in repo.changelog.nodesbetween(roots=roots, heads=heads)[0]:
2152 for node in repo.changelog.nodesbetween(roots=roots, heads=heads)[0]:
2149 if node not in roots:
2153 if node not in roots:
2150 displayer.show(repo[node])
2154 displayer.show(repo[node])
2155 displayer.close()
2151 return 0
2156 return 0
2152
2157
2153 return hg.merge(repo, node, force=opts.get('force'))
2158 return hg.merge(repo, node, force=opts.get('force'))
@@ -2186,6 +2191,7 b' def outgoing(ui, repo, dest=None, **opts'
2186 continue
2191 continue
2187 count += 1
2192 count += 1
2188 displayer.show(repo[n])
2193 displayer.show(repo[n])
2194 displayer.close()
2189
2195
2190 def parents(ui, repo, file_=None, **opts):
2196 def parents(ui, repo, file_=None, **opts):
2191 """show the parents of the working directory or revision
2197 """show the parents of the working directory or revision
@@ -2226,6 +2232,7 b' def parents(ui, repo, file_=None, **opts'
2226 for n in p:
2232 for n in p:
2227 if n != nullid:
2233 if n != nullid:
2228 displayer.show(repo[n])
2234 displayer.show(repo[n])
2235 displayer.close()
2229
2236
2230 def paths(ui, repo, search=None):
2237 def paths(ui, repo, search=None):
2231 """show aliases for remote repositories
2238 """show aliases for remote repositories
@@ -3106,7 +3113,9 b' def tip(ui, repo, **opts):'
3106 that repository becomes the current tip. The "tip" tag is special
3113 that repository becomes the current tip. The "tip" tag is special
3107 and cannot be renamed or assigned to a different changeset.
3114 and cannot be renamed or assigned to a different changeset.
3108 """
3115 """
3109 cmdutil.show_changeset(ui, repo, opts).show(repo[len(repo) - 1])
3116 displayer = cmdutil.show_changeset(ui, repo, opts)
3117 displayer.show(repo[len(repo) - 1])
3118 displayer.close()
3110
3119
3111 def unbundle(ui, repo, fname1, *fnames, **opts):
3120 def unbundle(ui, repo, fname1, *fnames, **opts):
3112 """apply one or more changegroup files
3121 """apply one or more changegroup files
General Comments 0
You need to be logged in to leave comments. Login now