Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/formatter.py @ 46782:67a2ecea8bd9
debugdiscovery: also integrate the discovery output in the json one
We add a way for formatter to informs code that free output is unwanted, and we
incorporate it in the json output.
Differential Revision: https://phab.mercurial-scm.org/D10224
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 15 Mar 2021 17:09:42 +0100 |
parents | 4aa484efc926 |
children | d4ba4d51f85f |
comparison
equal
deleted
inserted
replaced
46781:3a8cf5b9c820 | 46782:67a2ecea8bd9 |
---|---|
176 '''convert iterable to appropriate list format''' | 176 '''convert iterable to appropriate list format''' |
177 return list(data) | 177 return list(data) |
178 | 178 |
179 | 179 |
180 class baseformatter(object): | 180 class baseformatter(object): |
181 | |
182 # set to True if the formater output a strict format that does not support | |
183 # arbitrary output in the stream. | |
184 strict_format = False | |
185 | |
181 def __init__(self, ui, topic, opts, converter): | 186 def __init__(self, ui, topic, opts, converter): |
182 self._ui = ui | 187 self._ui = ui |
183 self._topic = topic | 188 self._topic = topic |
184 self._opts = opts | 189 self._opts = opts |
185 self._converter = converter | 190 self._converter = converter |
416 baseformatter.end(self) | 421 baseformatter.end(self) |
417 self._out.write(cborutil.BREAK) | 422 self._out.write(cborutil.BREAK) |
418 | 423 |
419 | 424 |
420 class jsonformatter(baseformatter): | 425 class jsonformatter(baseformatter): |
426 | |
427 strict_format = True | |
428 | |
421 def __init__(self, ui, out, topic, opts): | 429 def __init__(self, ui, out, topic, opts): |
422 baseformatter.__init__(self, ui, topic, opts, _nullconverter) | 430 baseformatter.__init__(self, ui, topic, opts, _nullconverter) |
423 self._out = out | 431 self._out = out |
424 self._out.write(b"[") | 432 self._out.write(b"[") |
425 self._first = True | 433 self._first = True |