Mercurial > evolve
changeset 2348:5737e0680f10 stable
ui: hg topic now display if current revision is in bad state (issue5533)
Previously, hg topic didn't showed the state of the current
revision. Now if show both informations.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Wed, 10 May 2017 14:46:01 +0200 |
parents | a5117a5becf8 |
children | 3be45918c7b5 |
files | README hgext3rd/topic/stack.py tests/test-topic-stack.t |
diffstat | 3 files changed, 62 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/README Wed May 10 09:55:22 2017 +0200 +++ b/README Wed May 10 14:46:01 2017 +0200 @@ -117,6 +117,7 @@ - also enable the new cache (from 6.1.0) for 'evolve.server-only', - fix hg stack json output to be valid json + - stack: now display if current revision is in bad state (issue5533) 6.1.0 -- 2017-05-03 -------------------
--- a/hgext3rd/topic/stack.py Wed May 10 09:55:22 2017 +0200 +++ b/hgext3rd/topic/stack.py Wed May 10 14:46:01 2017 +0200 @@ -15,6 +15,12 @@ trevs = repo.revs("topic(%s) - obsolete()", topic) return _orderrevs(repo, trevs) +def labelsgen(prefix, labelssuffix): + """ Takes a label prefix and a list of suffixes. Returns a string of the prefix + formatted with each suffix separated with a space. + """ + return ' '.join(prefix % suffix for suffix in labelssuffix) + def showstack(ui, repo, topic, opts): fm = ui.formatter('topicstack', opts) prev = None @@ -59,33 +65,42 @@ # super crude initial version for idx, isentry, ctx in entries[::-1]: + + states = [] + iscurrentrevision = repo.revs('%d and parents()', ctx.rev()) + + if iscurrentrevision: + states.append('current') + if not isentry: symbol = '^' - state = 'base' - elif repo.revs('%d and parents()', ctx.rev()): + # "base" is kind of a "ghost" entry + # skip other label for them (no current, no unstable) + states = ['base'] + elif iscurrentrevision: symbol = '@' - state = 'current' elif repo.revs('%d and unstable()', ctx.rev()): symbol = '$' - state = 'unstable' + states.append('unstable') else: symbol = ':' - state = 'clean' + states.append('clean') fm.startitem() fm.data(isentry=isentry) + if idx is None: fm.plain(' ') else: fm.write('topic.stack.index', 't%d', idx, - label='topic.stack.index topic.stack.index.%s' % state) + label='topic.stack.index ' + labelsgen('topic.stack.index.%s', states)) fm.write('topic.stack.state.symbol', '%s', symbol, - label='topic.stack.state topic.stack.state.%s' % state) + label='topic.stack.state ' + labelsgen('topic.stack.state.%s', states)) fm.plain(' ') fm.write('topic.stack.desc', '%s', ctx.description().splitlines()[0], - label='topic.stack.desc topic.stack.desc.%s' % state) - fm.condwrite(state != 'clean' and idx is not None, 'topic.stack.state', - ' (%s)', state, - label='topic.stack.state topic.stack.state.%s' % state) + label='topic.stack.desc ' + labelsgen('topic.stack.desc.%s', states)) + fm.condwrite(states != ['clean'] and idx is not None, 'topic.stack.state', + ' (%s)', fm.formatlist(states, 'topic.stack.state'), + label='topic.stack.state ' + labelsgen('topic.stack.state.%s', states)) fm.plain('\n') fm.end()
--- a/tests/test-topic-stack.t Wed May 10 09:55:22 2017 +0200 +++ b/tests/test-topic-stack.t Wed May 10 14:46:01 2017 +0200 @@ -83,34 +83,44 @@ "isentry": true, "topic.stack.desc": "c_f", "topic.stack.index": 4, - "topic.stack.state": "current", + "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": [ + "clean" + ], "topic.stack.state.symbol": ":" }, { "isentry": true, "topic.stack.desc": "c_d", "topic.stack.index": 2, - "topic.stack.state": "clean", + "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": [ + "clean" + ], "topic.stack.state.symbol": ":" }, { "isentry": false, "topic.stack.desc": "c_b", - "topic.stack.state": "base", + "topic.stack.state": [ + "base" + ], "topic.stack.state.symbol": "^" } ] @@ -172,6 +182,26 @@ t2@ c_d (current) t1: c_c ^ c_b + $ hg up t3 + 2 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ hg topic --list + ### topic: foo + ### branch: default + t4$ c_f (unstable) + t3@ c_e (current) + t2: c_d + t1: c_c + ^ c_b + $ hg topic --list --color=debug + [topic.stack.summary.topic|### topic: [topic.active|foo]] + [topic.stack.summary.branches|### branch: default] + [topic.stack.index topic.stack.index.unstable|t4][topic.stack.state topic.stack.state.unstable|$] [topic.stack.desc topic.stack.desc.unstable|c_f][topic.stack.state topic.stack.state.unstable| (unstable)] + [topic.stack.index topic.stack.index.current|t3][topic.stack.state topic.stack.state.current|@] [topic.stack.desc topic.stack.desc.current|c_e][topic.stack.state topic.stack.state.current| (current)] + [topic.stack.index topic.stack.index.clean|t2][topic.stack.state topic.stack.state.clean|:] [topic.stack.desc topic.stack.desc.clean|c_d] + [topic.stack.index topic.stack.index.clean|t1][topic.stack.state topic.stack.state.clean|:] [topic.stack.desc topic.stack.desc.clean|c_c] + [topic.stack.state topic.stack.state.base|^] [topic.stack.desc topic.stack.desc.base|c_b] + $ hg up t2 + 1 files updated, 0 files merged, 1 files removed, 0 files unresolved Also test the revset: