# HG changeset patch # User Pierre-Yves David # Date 1457998678 0 # Node ID 36112e361ee4f2a7b9aa56557e031d3013ff4943 # Parent dbd6d51e63f1842bce3f6e188135493a0fbfe624 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. diff --git a/hgext3rd/topic/__init__.py b/hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py +++ b/hgext3rd/topic/__init__.py @@ -46,7 +46,8 @@ cmdtable = {} command = cmdutil.command(cmdtable) colortable = {'topic.stack.index': 'yellow', - 'topic.stack.state.clean': 'dim', + 'topic.stack.state.base': 'dim', + 'topic.stack.state.clean': 'green', 'topic.stack.index.current': 'cyan', # random pick 'topic.stack.state.current': 'cyan bold', # random pick 'topic.stack.desc.current': 'cyan', # random pick diff --git a/hgext3rd/topic/stack.py b/hgext3rd/topic/stack.py --- a/hgext3rd/topic/stack.py +++ b/hgext3rd/topic/stack.py @@ -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]: diff --git a/tests/test-topic-stack.t b/tests/test-topic-stack.t --- a/tests/test-topic-stack.t +++ b/tests/test-topic-stack.t @@ -57,6 +57,7 @@ $ hg topic * foo $ hg topic --list + _ c_b t0: c_c t1: c_d t2: c_e @@ -104,7 +105,115 @@ o 0 default {} draft c_a $ hg topic --list + _ c_b t0: c_c t1@ c_d (current) t2$ c_e (unstable) t3$ c_f (unstable) + +Case with multiple heads on the topic +------------------------------------- + +Make things linear again + + $ hg rebase -s 'desc(c_e)' -d 'desc(c_d) - obsolete()' + rebasing 4:91fa8808d101 "c_e" + rebasing 5:4ec5094907b7 "c_f" + $ hg log -G + o 9 default {foo} draft c_f + | + o 8 default {foo} draft c_e + | + @ 7 default {foo} draft c_d + | + o 2 default {foo} draft c_c + | + o 1 default {} draft c_b + | + o 0 default {} draft c_a + + + +Create the second branch + + $ hg up 'desc(c_d)' + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ echo aaa > ggg + $ hg add ggg + $ hg commit -m c_g + created new head + $ echo aaa > hhh + $ hg add hhh + $ hg commit -m c_h + created new head + $ hg log -G + @ 11 default {foo} draft c_h + | + o 10 default {foo} draft c_g + | + | o 9 default {foo} draft c_f + | | + | o 8 default {foo} draft c_e + |/ + o 7 default {foo} draft c_d + | + o 2 default {foo} draft c_c + | + o 1 default {} draft c_b + | + o 0 default {} draft c_a + + +Test output + + $ hg top -l + _ c_b + t0: c_c + t1: c_d + t2: c_g + t3@ c_h (current) + _ c_d + t4: c_e + t5: c_f + +Case with multiple heads on the topic with unstability involved +--------------------------------------------------------------- + +We amend the message to make sure the display base pick the right changeset + + $ hg up 'desc(c_d)' + 0 files updated, 0 files merged, 2 files removed, 0 files unresolved + $ echo ccc > ddd + $ hg commit --amend -m 'c_D' + $ hg rebase -d . -s 'desc(c_g)' + rebasing 10:11286b4fcb3d "c_g" + rebasing 11:3ad57527186d "c_h" + $ hg log -G + o 15 default {foo} draft c_h + | + o 14 default {foo} draft c_g + | + @ 13 default {foo} draft c_D + | + | o 9 default {foo} draft c_f + | | + | o 8 default {foo} draft c_e + | | + | x 7 default {foo} draft c_d + |/ + o 2 default {foo} draft c_c + | + o 1 default {} draft c_b + | + o 0 default {} draft c_a + + + $ hg topic --list + _ c_b + t0: c_c + t1@ c_D (current) + t2: c_g + t3: c_h + _ c_D + t4$ c_e (unstable) + t5$ c_f (unstable)