comparison mercurial/formatter.py @ 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
comparison
equal deleted inserted replaced
22474:9da0ef363861 22475:17eeda31e52b
87 def end(self): 87 def end(self):
88 baseformatter.end(self) 88 baseformatter.end(self)
89 self._ui.write(cPickle.dumps(self._data)) 89 self._ui.write(cPickle.dumps(self._data))
90 90
91 def _jsonifyobj(v): 91 def _jsonifyobj(v):
92 if isinstance(v, int): 92 if isinstance(v, tuple):
93 return '[' + ', '.join(_jsonifyobj(e) for e in v) + ']'
94 elif isinstance(v, int):
93 return '%d' % v 95 return '%d' % v
94 else: 96 else:
95 return '"%s"' % encoding.jsonescape(v) 97 return '"%s"' % encoding.jsonescape(v)
96 98
97 class jsonformatter(baseformatter): 99 class jsonformatter(baseformatter):