Patchwork [5,of,6] formatter: convert booleans to json

login
register
mail settings
Submitter Yuya Nishihara
Date Oct. 2, 2014, 2:59 p.m.
Message ID <356766f9b906dea2d322.1412261947@mimosa>
Download mbox | patch
Permalink /patch/6087/
State Accepted
Headers show

Comments

Yuya Nishihara - Oct. 2, 2014, 2:59 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1412259659 -32400
#      Thu Oct 02 23:20:59 2014 +0900
# Node ID 356766f9b906dea2d3224309695edfec76f14426
# Parent  2b3a3dad49f22eade2dd8576aa8374f175f71de5
formatter: convert booleans to json

It will be used in branches output.
Matt Mackall - Oct. 2, 2014, 10:54 p.m.
On Thu, 2014-10-02 at 23:59 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1412259659 -32400
> #      Thu Oct 02 23:20:59 2014 +0900
> # Node ID 356766f9b906dea2d3224309695edfec76f14426
> # Parent  2b3a3dad49f22eade2dd8576aa8374f175f71de5
> formatter: convert booleans to json

I've queued this one too.

Patch

diff --git a/mercurial/formatter.py b/mercurial/formatter.py
--- a/mercurial/formatter.py
+++ b/mercurial/formatter.py
@@ -91,6 +91,10 @@  class pickleformatter(baseformatter):
 def _jsonifyobj(v):
     if isinstance(v, tuple):
         return '[' + ', '.join(_jsonifyobj(e) for e in v) + ']'
+    elif v is True:
+        return 'true'
+    elif v is False:
+        return 'false'
     elif isinstance(v, (int, float)):
         return str(v)
     else: