comparison mercurial/cmdutil.py @ 20667:e96e9f805c19

changeset_templater: remove use_template method
author Matt Mackall <mpm@selenic.com>
date Sat, 08 Mar 2014 16:14:08 -0600
parents e3eb480a9391
children 3a35ba2681ec
comparison
equal deleted inserted replaced
20666:e3eb480a9391 20667:e96e9f805c19
946 946
947 947
948 class changeset_templater(changeset_printer): 948 class changeset_templater(changeset_printer):
949 '''format changeset information.''' 949 '''format changeset information.'''
950 950
951 def __init__(self, ui, repo, patch, diffopts, mapfile, buffered): 951 def __init__(self, ui, repo, patch, diffopts, tmpl, mapfile, buffered):
952 changeset_printer.__init__(self, ui, repo, patch, diffopts, buffered) 952 changeset_printer.__init__(self, ui, repo, patch, diffopts, buffered)
953 formatnode = ui.debugflag and (lambda x: x) or (lambda x: x[:12]) 953 formatnode = ui.debugflag and (lambda x: x) or (lambda x: x[:12])
954 defaulttempl = { 954 defaulttempl = {
955 'parent': '{rev}:{node|formatnode} ', 955 'parent': '{rev}:{node|formatnode} ',
956 'manifest': '{rev}:{node|formatnode}', 956 'manifest': '{rev}:{node|formatnode}',
959 } 959 }
960 # filecopy is preserved for compatibility reasons 960 # filecopy is preserved for compatibility reasons
961 defaulttempl['filecopy'] = defaulttempl['file_copy'] 961 defaulttempl['filecopy'] = defaulttempl['file_copy']
962 self.t = templater.templater(mapfile, {'formatnode': formatnode}, 962 self.t = templater.templater(mapfile, {'formatnode': formatnode},
963 cache=defaulttempl) 963 cache=defaulttempl)
964 if tmpl:
965 self.t.cache['changeset'] = tmpl
966
964 self.cache = {} 967 self.cache = {}
965
966 def use_template(self, t):
967 '''set template string to use'''
968 self.t.cache['changeset'] = t
969 968
970 def _meaningful_parentrevs(self, ctx): 969 def _meaningful_parentrevs(self, ctx):
971 """Return list of meaningful (or all if debug) parentrevs for rev. 970 """Return list of meaningful (or all if debug) parentrevs for rev.
972 """ 971 """
973 parents = ctx.parents() 972 parents = ctx.parents()
1094 1093
1095 if not tmpl and not mapfile: 1094 if not tmpl and not mapfile:
1096 return changeset_printer(ui, repo, patch, opts, buffered) 1095 return changeset_printer(ui, repo, patch, opts, buffered)
1097 1096
1098 try: 1097 try:
1099 t = changeset_templater(ui, repo, patch, opts, mapfile, buffered) 1098 t = changeset_templater(ui, repo, patch, opts, tmpl, mapfile, buffered)
1100 except SyntaxError, inst: 1099 except SyntaxError, inst:
1101 raise util.Abort(inst.args[0]) 1100 raise util.Abort(inst.args[0])
1102 if tmpl:
1103 t.use_template(tmpl)
1104 return t 1101 return t
1105 1102
1106 def showmarker(ui, marker): 1103 def showmarker(ui, marker):
1107 """utility function to display obsolescence marker in a readable way 1104 """utility function to display obsolescence marker in a readable way
1108 1105