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