Patchwork [3,of,4,RFC,V2] formatter: convert None to json null

login
register
mail settings
Submitter Yuya Nishihara
Date March 16, 2015, 2:04 p.m.
Message ID <cdf011561f3cac5e4f44.1426514672@mimosa>
Download mbox | patch
Permalink /patch/8094/
State Accepted
Commit 0a714a1f7d5c0d754e4c566a4372e391144854f8
Headers show

Comments

Yuya Nishihara - March 16, 2015, 2:04 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1410960874 -32400
#      Wed Sep 17 22:34:34 2014 +0900
# Node ID cdf011561f3cac5e4f44a9811ec4354ebb471867
# Parent  3e97838d4eaa3f4f5131f1f1997ead72acc81aad
formatter: convert None to json null

It will be used by "annotate" command to represent the workingctx revision.
Matt Mackall - March 16, 2015, 7:11 p.m.
On Mon, 2015-03-16 at 23:04 +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1410960874 -32400
> #      Wed Sep 17 22:34:34 2014 +0900
> # Node ID cdf011561f3cac5e4f44a9811ec4354ebb471867
> # Parent  3e97838d4eaa3f4f5131f1f1997ead72acc81aad
> formatter: convert None to json null

I've queued 1 and 3 for default, thanks.

Patch

diff --git a/mercurial/formatter.py b/mercurial/formatter.py
--- a/mercurial/formatter.py
+++ b/mercurial/formatter.py
@@ -98,6 +98,8 @@  class pickleformatter(baseformatter):
 def _jsonifyobj(v):
     if isinstance(v, tuple):
         return '[' + ', '.join(_jsonifyobj(e) for e in v) + ']'
+    elif v is None:
+        return 'null'
     elif v is True:
         return 'true'
     elif v is False: