# HG changeset patch # User Boris Feld # Date 1494402922 -7200 # Node ID a5117a5becf84d31bc53408d95b703eeb0647d6d # Parent d49f376598f80f1b37dc451605f850eab7ea733b ui: Fix hg stack json output Previously 'hg stack -Tjson' generated invalid output like: [ { "isentry": true, "topic.stack.desc": "...", "topic.stack.index": 1, "topic.stack.state": "current", "topic.stack.state.symbol": "@" } ] , { "isentry": true, "topic.stack.desc": "...", "topic.stack.index": 1, "topic.stack.state": "current", "topic.stack.state.symbol": "@" }, { "isentry": false, "topic.stack.desc": "...", "topic.stack.state": "base", "topic.stack.state.symbol": "^" } ] I de-indented the fmt.end() to generate this output: [ { "isentry": true, "topic.stack.desc": "...", "topic.stack.index": 1, "topic.stack.state": "current", "topic.stack.state.symbol": "@" }, { "isentry": false, "topic.stack.desc": "...", "topic.stack.state": "base", "topic.stack.state.symbol": "^" } ] I've also added a test case. diff -r d49f376598f8 -r a5117a5becf8 README --- a/README Thu May 04 21:21:59 2017 +0200 +++ b/README Wed May 10 09:55:22 2017 +0200 @@ -116,6 +116,7 @@ ------------------- - also enable the new cache (from 6.1.0) for 'evolve.server-only', + - fix hg stack json output to be valid json 6.1.0 -- 2017-05-03 ------------------- diff -r d49f376598f8 -r a5117a5becf8 hgext3rd/topic/stack.py --- a/hgext3rd/topic/stack.py Thu May 04 21:21:59 2017 +0200 +++ b/hgext3rd/topic/stack.py Wed May 10 09:55:22 2017 +0200 @@ -87,7 +87,7 @@ ' (%s)', state, label='topic.stack.state topic.stack.state.%s' % state) fm.plain('\n') - fm.end() + fm.end() def stackdata(repo, topic): """get various data about a stack diff -r d49f376598f8 -r a5117a5becf8 tests/test-topic-stack.t --- a/tests/test-topic-stack.t Thu May 04 21:21:59 2017 +0200 +++ b/tests/test-topic-stack.t Wed May 10 09:55:22 2017 +0200 @@ -77,6 +77,43 @@ t2: c_d t1: c_c ^ c_b + $ hg stack -Tjson | python -m json.tool + [ + { + "isentry": true, + "topic.stack.desc": "c_f", + "topic.stack.index": 4, + "topic.stack.state": "current", + "topic.stack.state.symbol": "@" + }, + { + "isentry": true, + "topic.stack.desc": "c_e", + "topic.stack.index": 3, + "topic.stack.state": "clean", + "topic.stack.state.symbol": ":" + }, + { + "isentry": true, + "topic.stack.desc": "c_d", + "topic.stack.index": 2, + "topic.stack.state": "clean", + "topic.stack.state.symbol": ":" + }, + { + "isentry": true, + "topic.stack.desc": "c_c", + "topic.stack.index": 1, + "topic.stack.state": "clean", + "topic.stack.state.symbol": ":" + }, + { + "isentry": false, + "topic.stack.desc": "c_b", + "topic.stack.state": "base", + "topic.stack.state.symbol": "^" + } + ] error case, nothing to list