Mercurial > evolve
changeset 1955:5452a575b4e5
topic: extract display from entry computation
We are about to reverse the order of the output (most recent first) so it will
be useful.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Fri, 01 Apr 2016 16:55:24 -0700 |
parents | 61f36480740f |
children | d8f1e432b16a |
files | hgext3rd/topic/stack.py |
diffstat | 1 files changed, 21 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/topic/stack.py Fri Apr 01 16:40:19 2016 -0700 +++ b/hgext3rd/topic/stack.py Fri Apr 01 16:55:24 2016 -0700 @@ -21,47 +21,47 @@ raise error.Abort(_('no active topic to list')) fm = ui.formatter('topicstack', opts) prev = None + entries = [] for idx, r in enumerate(getstack(repo, topic), 1): ctx = repo[r] p1 = ctx.p1() if p1.obsolete(): p1 = repo[_singlesuccessor(repo, p1)] if p1.rev() != prev: - # display the parent of the changeset - state = 'base' + entries.append((None, p1)) + entries.append((idx, ctx)) + prev = r + + # super crude initial version + for idx, ctx in entries: + if idx is None: symbol = '_' - fm.startitem() - fm.plain(' ') # XXX 2 is the right padding by chance - fm.write('topic.stack.state', '%s', symbol, - label='topic.stack.state topic.stack.state.%s' % state) - fm.plain(' ') - fm.write('topic.stack.desc', '%s', - p1.description().splitlines()[0], - label='topic.stack.desc topic.stack.desc.%s' % state) - fm.plain('\n') - fm.end() - # super crude initial version - symbol = ':' - state = 'clean' - if repo.revs('%d and parents()', r): + state = 'base' + elif repo.revs('%d and parents()', ctx.rev()): symbol = '@' state = 'current' - if repo.revs('%d and unstable()', r): + elif repo.revs('%d and unstable()', ctx.rev()): symbol = '$' state = 'unstable' + else: + symbol = ':' + state = 'clean' fm.startitem() - fm.write('topic.stack.index', 't%d', idx, - label='topic.stack.index topic.stack.index.%s' % state) + if idx is None: + fm.plain(' ') + else: + fm.write('topic.stack.index', 't%d', idx, + label='topic.stack.index topic.stack.index.%s' % state) fm.write('topic.stack.state.symbol', '%s', symbol, label='topic.stack.state topic.stack.state.%s' % state) 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', 'topic.stack.state', ' (%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) fm.plain('\n') fm.end() - prev = r # Copied from evolve 081605c2e9b6