From patchwork Sun Apr 2 03:28:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2,of,4] templatefilters: unroll handling of None/False/True From: Yuya Nishihara X-Patchwork-Id: 19902 Message-Id: <54017aea6a3b5c7a668f.1491103702@mimosa> To: mercurial-devel@mercurial-scm.org Date: Sun, 02 Apr 2017 12:28:22 +0900 # HG changeset patch # User Yuya Nishihara # Date 1491101485 -32400 # Sun Apr 02 11:51:25 2017 +0900 # Node ID 54017aea6a3b5c7a668f44df4399102b94a9eecd # Parent 80483134bdbaeb72809a3e9683a263c7e166b3c8 templatefilters: unroll handling of None/False/True It doesn't make sense to use a dict here. diff --git a/mercurial/templatefilters.py b/mercurial/templatefilters.py --- a/mercurial/templatefilters.py +++ b/mercurial/templatefilters.py @@ -219,8 +219,12 @@ def indent(text, prefix): @templatefilter('json') def json(obj): - if obj is None or obj is False or obj is True: - return {None: 'null', False: 'false', True: 'true'}[obj] + if obj is None: + return 'null' + elif obj is False: + return 'false' + elif obj is True: + return 'true' elif isinstance(obj, (int, long, float)): return str(obj) elif isinstance(obj, str):