Show More
@@ -237,24 +237,28 b' class _plainconverter(object):' | |||||
237 |
|
237 | |||
238 | class plainformatter(baseformatter): |
|
238 | class plainformatter(baseformatter): | |
239 | '''the default text output scheme''' |
|
239 | '''the default text output scheme''' | |
240 | def __init__(self, ui, topic, opts): |
|
240 | def __init__(self, ui, out, topic, opts): | |
241 | baseformatter.__init__(self, ui, topic, opts, _plainconverter) |
|
241 | baseformatter.__init__(self, ui, topic, opts, _plainconverter) | |
242 | if ui.debugflag: |
|
242 | if ui.debugflag: | |
243 | self.hexfunc = hex |
|
243 | self.hexfunc = hex | |
244 | else: |
|
244 | else: | |
245 | self.hexfunc = short |
|
245 | self.hexfunc = short | |
|
246 | if ui is out: | |||
|
247 | self._write = ui.write | |||
|
248 | else: | |||
|
249 | self._write = lambda s, **opts: out.write(s) | |||
246 | def startitem(self): |
|
250 | def startitem(self): | |
247 | pass |
|
251 | pass | |
248 | def data(self, **data): |
|
252 | def data(self, **data): | |
249 | pass |
|
253 | pass | |
250 | def write(self, fields, deftext, *fielddata, **opts): |
|
254 | def write(self, fields, deftext, *fielddata, **opts): | |
251 |
self._ |
|
255 | self._write(deftext % fielddata, **opts) | |
252 | def condwrite(self, cond, fields, deftext, *fielddata, **opts): |
|
256 | def condwrite(self, cond, fields, deftext, *fielddata, **opts): | |
253 | '''do conditional write''' |
|
257 | '''do conditional write''' | |
254 | if cond: |
|
258 | if cond: | |
255 |
self._ |
|
259 | self._write(deftext % fielddata, **opts) | |
256 | def plain(self, text, **opts): |
|
260 | def plain(self, text, **opts): | |
257 |
self._ |
|
261 | self._write(text, **opts) | |
258 | def isplain(self): |
|
262 | def isplain(self): | |
259 | return True |
|
263 | return True | |
260 | def nested(self, field): |
|
264 | def nested(self, field): | |
@@ -411,20 +415,20 b' def maketemplater(ui, topic, tmpl, cache' | |||||
411 | t.cache[topic] = tmpl |
|
415 | t.cache[topic] = tmpl | |
412 | return t |
|
416 | return t | |
413 |
|
417 | |||
414 | def formatter(ui, topic, opts): |
|
418 | def formatter(ui, out, topic, opts): | |
415 | template = opts.get("template", "") |
|
419 | template = opts.get("template", "") | |
416 | if template == "json": |
|
420 | if template == "json": | |
417 |
return jsonformatter(ui, |
|
421 | return jsonformatter(ui, out, topic, opts) | |
418 | elif template == "pickle": |
|
422 | elif template == "pickle": | |
419 |
return pickleformatter(ui, |
|
423 | return pickleformatter(ui, out, topic, opts) | |
420 | elif template == "debug": |
|
424 | elif template == "debug": | |
421 |
return debugformatter(ui, |
|
425 | return debugformatter(ui, out, topic, opts) | |
422 | elif template != "": |
|
426 | elif template != "": | |
423 |
return templateformatter(ui, |
|
427 | return templateformatter(ui, out, topic, opts) | |
424 | # developer config: ui.formatdebug |
|
428 | # developer config: ui.formatdebug | |
425 | elif ui.configbool('ui', 'formatdebug'): |
|
429 | elif ui.configbool('ui', 'formatdebug'): | |
426 |
return debugformatter(ui, |
|
430 | return debugformatter(ui, out, topic, opts) | |
427 | # deprecated config: ui.formatjson |
|
431 | # deprecated config: ui.formatjson | |
428 | elif ui.configbool('ui', 'formatjson'): |
|
432 | elif ui.configbool('ui', 'formatjson'): | |
429 |
return jsonformatter(ui, |
|
433 | return jsonformatter(ui, out, topic, opts) | |
430 | return plainformatter(ui, topic, opts) |
|
434 | return plainformatter(ui, out, topic, opts) |
@@ -263,7 +263,7 b' class ui(object):' | |||||
263 | (util.timer() - starttime) * 1000 |
|
263 | (util.timer() - starttime) * 1000 | |
264 |
|
264 | |||
265 | def formatter(self, topic, opts): |
|
265 | def formatter(self, topic, opts): | |
266 | return formatter.formatter(self, topic, opts) |
|
266 | return formatter.formatter(self, self, topic, opts) | |
267 |
|
267 | |||
268 | def _trusted(self, fp, f): |
|
268 | def _trusted(self, fp, f): | |
269 | st = util.fstat(fp) |
|
269 | st = util.fstat(fp) |
General Comments 0
You need to be logged in to leave comments.
Login now