Mercurial > hg
changeset 22475:17eeda31e52b
formatter: have jsonformatter accept tuple as value
This is necessary for "annotate" to encode ctx.date() in the same manner
as jsonchangeset printer.
It doesn't support list object because keeping mutable object in _item could
be a source of hidden bugs. Also, I can't think of the use case.
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Wed, 17 Sep 2014 21:30:22 +0900 |
parents | 9da0ef363861 |
children | a0829ec34dbd |
files | mercurial/formatter.py |
diffstat | 1 files changed, 3 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/formatter.py Wed Sep 17 21:15:43 2014 +0900 +++ b/mercurial/formatter.py Wed Sep 17 21:30:22 2014 +0900 @@ -89,7 +89,9 @@ self._ui.write(cPickle.dumps(self._data)) def _jsonifyobj(v): - if isinstance(v, int): + if isinstance(v, tuple): + return '[' + ', '.join(_jsonifyobj(e) for e in v) + ']' + elif isinstance(v, int): return '%d' % v else: return '"%s"' % encoding.jsonescape(v)