Show More
@@ -441,12 +441,12 b' def annotate(ui, repo, *pats, **opts):' | |||
|
441 | 441 | if linenumber and (not opts.get('changeset')) and (not opts.get('number')): |
|
442 | 442 | raise error.Abort(_('at least one of -n/-c is required for -l')) |
|
443 | 443 | |
|
444 | if fm: | |
|
444 | if fm.isplain(): | |
|
445 | def makefunc(get, fmt): | |
|
446 | return lambda x: fmt(get(x)) | |
|
447 | else: | |
|
445 | 448 | def makefunc(get, fmt): |
|
446 | 449 | return get |
|
447 | else: | |
|
448 | def makefunc(get, fmt): | |
|
449 | return lambda x: fmt(get(x)) | |
|
450 | 450 | funcmap = [(makefunc(get, fmt), sep) for op, sep, get, fmt in opmap |
|
451 | 451 | if opts.get(op)] |
|
452 | 452 | funcmap[0] = (funcmap[0][0], '') # no separator in front of first column |
@@ -476,12 +476,12 b' def annotate(ui, repo, *pats, **opts):' | |||
|
476 | 476 | |
|
477 | 477 | for f, sep in funcmap: |
|
478 | 478 | l = [f(n) for n, dummy in lines] |
|
479 | if fm: | |
|
480 | formats.append(['%s' for x in l]) | |
|
481 | else: | |
|
479 | if fm.isplain(): | |
|
482 | 480 | sizes = [encoding.colwidth(x) for x in l] |
|
483 | 481 | ml = max(sizes) |
|
484 | 482 | formats.append([sep + ' ' * (ml - w) + '%s' for w in sizes]) |
|
483 | else: | |
|
484 | formats.append(['%s' for x in l]) | |
|
485 | 485 | pieces.append(l) |
|
486 | 486 | |
|
487 | 487 | for f, p, l in zip(zip(*formats), zip(*pieces), lines): |
@@ -1185,7 +1185,7 b' def bookmark(ui, repo, *names, **opts):' | |||
|
1185 | 1185 | fm = ui.formatter('bookmarks', opts) |
|
1186 | 1186 | hexfn = fm.hexfunc |
|
1187 | 1187 | marks = repo._bookmarks |
|
1188 |
if len(marks) == 0 and |
|
|
1188 | if len(marks) == 0 and fm.isplain(): | |
|
1189 | 1189 | ui.status(_("no bookmarks set\n")) |
|
1190 | 1190 | for bmark, n in sorted(marks.iteritems()): |
|
1191 | 1191 | active = repo._activebookmark |
@@ -4442,10 +4442,10 b' def grep(ui, repo, pattern, *pats, **opt' | |||
|
4442 | 4442 | |
|
4443 | 4443 | def display(fm, fn, ctx, pstates, states): |
|
4444 | 4444 | rev = ctx.rev() |
|
4445 | if fm: | |
|
4445 | if fm.isplain(): | |
|
4446 | formatuser = ui.shortuser | |
|
4447 | else: | |
|
4446 | 4448 | formatuser = str |
|
4447 | else: | |
|
4448 | formatuser = ui.shortuser | |
|
4449 | 4449 | if ui.quiet: |
|
4450 | 4450 | datefmt = '%Y-%m-%d' |
|
4451 | 4451 | else: |
@@ -5695,10 +5695,10 b' def paths(ui, repo, search=None, **opts)' | |||
|
5695 | 5695 | pathitems = sorted(ui.paths.iteritems()) |
|
5696 | 5696 | |
|
5697 | 5697 | fm = ui.formatter('paths', opts) |
|
5698 | if fm: | |
|
5698 | if fm.isplain(): | |
|
5699 | hidepassword = util.hidepassword | |
|
5700 | else: | |
|
5699 | 5701 | hidepassword = str |
|
5700 | else: | |
|
5701 | hidepassword = util.hidepassword | |
|
5702 | 5702 | if ui.quiet: |
|
5703 | 5703 | namefmt = '%s\n' |
|
5704 | 5704 | else: |
@@ -57,10 +57,6 b' class baseformatter(object):' | |||
|
57 | 57 | def __exit__(self, exctype, excvalue, traceback): |
|
58 | 58 | if exctype is None: |
|
59 | 59 | self.end() |
|
60 | def __nonzero__(self): | |
|
61 | '''return False if we're not doing real templating so we can | |
|
62 | skip extra work''' | |
|
63 | return True | |
|
64 | 60 | def _showitem(self): |
|
65 | 61 | '''show a formatted item once all data is collected''' |
|
66 | 62 | pass |
@@ -96,6 +92,9 b' class baseformatter(object):' | |||
|
96 | 92 | def plain(self, text, **opts): |
|
97 | 93 | '''show raw text for non-templated mode''' |
|
98 | 94 | pass |
|
95 | def isplain(self): | |
|
96 | '''check for plain formatter usage''' | |
|
97 | return False | |
|
99 | 98 | def nested(self, field): |
|
100 | 99 | '''sub formatter to store nested data in the specified field''' |
|
101 | 100 | self._item[field] = data = [] |
@@ -142,8 +141,6 b' class plainformatter(baseformatter):' | |||
|
142 | 141 | self.hexfunc = hex |
|
143 | 142 | else: |
|
144 | 143 | self.hexfunc = short |
|
145 | def __nonzero__(self): | |
|
146 | return False | |
|
147 | 144 | def startitem(self): |
|
148 | 145 | pass |
|
149 | 146 | def data(self, **data): |
@@ -156,6 +153,8 b' class plainformatter(baseformatter):' | |||
|
156 | 153 | self._ui.write(deftext % fielddata, **opts) |
|
157 | 154 | def plain(self, text, **opts): |
|
158 | 155 | self._ui.write(text, **opts) |
|
156 | def isplain(self): | |
|
157 | return True | |
|
159 | 158 | def nested(self, field): |
|
160 | 159 | # nested data will be directly written to ui |
|
161 | 160 | return self |
General Comments 0
You need to be logged in to leave comments.
Login now