##// END OF EJS Templates
formatter: add general way to switch hex/short functions...
Yuya Nishihara -
r22701:cb28d2b3 default
parent child Browse files
Show More
@@ -276,10 +276,7 b' def annotate(ui, repo, *pats, **opts):'
276 276
277 277 fm = ui.formatter('annotate', opts)
278 278 datefunc = ui.quiet and util.shortdate or util.datestr
279 if fm or ui.debugflag:
280 hexfn = hex
281 else:
282 hexfn = short
279 hexfn = fm.hexfunc
283 280
284 281 opmap = [('user', ' ', lambda x: x[0].user(), ui.shortuser),
285 282 ('number', ' ', lambda x: x[0].rev(), str),
@@ -6086,10 +6083,7 b' def tags(ui, repo, **opts):'
6086 6083 """
6087 6084
6088 6085 fm = ui.formatter('tags', opts)
6089 if fm or ui.debugflag:
6090 hexfunc = hex
6091 else:
6092 hexfunc = short
6086 hexfunc = fm.hexfunc
6093 6087 tagtype = ""
6094 6088
6095 6089 for t, n in reversed(repo.tagslist()):
@@ -6,6 +6,7 b''
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 import cPickle
9 from node import hex, short
9 10 from i18n import _
10 11 import encoding, util
11 12
@@ -16,6 +17,8 b' class baseformatter(object):'
16 17 self._style = opts.get("style")
17 18 self._template = opts.get("template")
18 19 self._item = None
20 # function to convert node to string suitable for this output
21 self.hexfunc = hex
19 22 def __nonzero__(self):
20 23 '''return False if we're not doing real templating so we can
21 24 skip extra work'''
@@ -51,6 +54,10 b' class plainformatter(baseformatter):'
51 54 '''the default text output scheme'''
52 55 def __init__(self, ui, topic, opts):
53 56 baseformatter.__init__(self, ui, topic, opts)
57 if ui.debugflag:
58 self.hexfunc = hex
59 else:
60 self.hexfunc = short
54 61 def __nonzero__(self):
55 62 return False
56 63 def startitem(self):
General Comments 0
You need to be logged in to leave comments. Login now