Mercurial > evolve
diff hgext3rd/topic/stack.py @ 1909:36112e361ee4
stack: display the base of the stack
Displaying the first parent of the stack seems useful. I'm even tempted to call
it 't0' and have the topic still active when 'hg up t0' is used to move to the
base.
As a side effect we gain a way to denote that the stack is not linear. I'm not
super convinced that it is the right way to display it, but this is better than
no information.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Mon, 14 Mar 2016 23:37:58 +0000 |
parents | 95874e8fc5f2 |
children | 17782631d7e8 |
line wrap: on
line diff
--- a/hgext3rd/topic/stack.py Mon Mar 14 19:22:21 2016 +0000 +++ b/hgext3rd/topic/stack.py Mon Mar 14 23:37:58 2016 +0000 @@ -19,7 +19,26 @@ if not topic: raise error.Abort(_('no active topic to list')) fm = ui.formatter('topicstack', opts) + prev = None for idx, r in enumerate(getstack(repo, topic)): + ctx = repo[r] + p1 = ctx.p1() + if p1.obsolete(): + p1 = repo[_singlesuccessor(repo, p1)] + if p1.rev() != prev: + # display the parent of the chanset + state = 'base' + 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' @@ -35,12 +54,13 @@ 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], + 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, label='topic.stack.state topic.stack.state.%s' % state) fm.plain('\n') fm.end() + prev = r # Copied from evolve 081605c2e9b6 @@ -64,11 +84,11 @@ # one depending on A) that we can remove from the dependency graph and add # to the ordering. We progress in a similar fashion until the ordering is # built - solvablerevs = collections.deque([r for r in sorted(dependencies.keys()) - if not dependencies[r]]) + solvablerevs = [r for r in sorted(dependencies.keys()) + if not dependencies[r]] ordering = [] while solvablerevs: - rev = solvablerevs.popleft() + rev = solvablerevs.pop() for dependent in rdependencies[rev]: dependencies[dependent].remove(rev) if not dependencies[dependent]: