Mercurial > evolve
diff hgext3rd/topic/stack.py @ 1907:95874e8fc5f2
stack: add basic formatter and label support
This still is not great, especially I would like '-T' to be able to control how
we display the changeset, but this is useful progress.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Mon, 14 Mar 2016 19:03:32 +0000 |
parents | 5e9ce6310720 |
children | 36112e361ee4 |
line wrap: on
line diff
--- a/hgext3rd/topic/stack.py Mon Mar 14 18:43:23 2016 +0000 +++ b/hgext3rd/topic/stack.py Mon Mar 14 19:03:32 2016 +0000 @@ -13,11 +13,12 @@ trevs = repo.revs("topic(%s) - obsolete()", topic) return _orderrevs(repo, trevs) -def showstack(ui, repo, topic): +def showstack(ui, repo, topic, opts): if not topic: topic = repo.currenttopic if not topic: raise error.Abort(_('no active topic to list')) + fm = ui.formatter('topicstack', opts) for idx, r in enumerate(getstack(repo, topic)): # super crude initial version symbol = ':' @@ -28,14 +29,18 @@ if repo.revs('%d and unstable()', r): symbol = '$' state = 'unstable' - if state == 'clean': - l = "t%d%s %s\n" % (idx, symbol, - repo[r].description().splitlines()[0]) - else: - l = "t%d%s %s (%s)\n" % (idx, symbol, - repo[r].description().splitlines()[0], - state) - ui.write(l) + fm.startitem() + 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', repo[r].description().splitlines()[0], + label='topic.stack.desc topic.stack.desc.%s' % state) + fm.condwrite(state != 'clean', 'topic.stack.state', ' (%s)', state, + label='topic.stack.state topic.stack.state.%s' % state) + fm.plain('\n') + fm.end() # Copied from evolve 081605c2e9b6