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.
--- 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)