Mercurial > evolve
comparison hgext3rd/topic/stack.py @ 2341:a5117a5becf8 stable
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.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Wed, 10 May 2017 09:55:22 +0200 |
parents | 61d595ce8994 |
children | 5737e0680f10 |
comparison
equal
deleted
inserted
replaced
2331:d49f376598f8 | 2341:a5117a5becf8 |
---|---|
85 label='topic.stack.desc topic.stack.desc.%s' % state) | 85 label='topic.stack.desc topic.stack.desc.%s' % state) |
86 fm.condwrite(state != 'clean' and idx is not None, 'topic.stack.state', | 86 fm.condwrite(state != 'clean' and idx is not None, 'topic.stack.state', |
87 ' (%s)', state, | 87 ' (%s)', state, |
88 label='topic.stack.state topic.stack.state.%s' % state) | 88 label='topic.stack.state topic.stack.state.%s' % state) |
89 fm.plain('\n') | 89 fm.plain('\n') |
90 fm.end() | 90 fm.end() |
91 | 91 |
92 def stackdata(repo, topic): | 92 def stackdata(repo, topic): |
93 """get various data about a stack | 93 """get various data about a stack |
94 | 94 |
95 :changesetcount: number of non-obsolete changesets in the stack | 95 :changesetcount: number of non-obsolete changesets in the stack |