diff -r 5e9ce6310720 -r 95874e8fc5f2 hgext3rd/topic/stack.py --- 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