# HG changeset patch # User Pierre-Yves David # Date 1472208726 -7200 # Node ID ba79d23594d668a852bcfc1b796a5e78b26197ac # Parent 71410fa2c253a3b0a9050fb8bf310eff014d2d48 stack: reusing the index number in base when applicable This clarify the branching when it is easy to track back the branching point. This does not takes the evolution graph into account yet. diff -r 71410fa2c253 -r ba79d23594d6 hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py Fri Aug 26 12:37:52 2016 +0200 +++ b/hgext3rd/topic/__init__.py Fri Aug 26 12:52:06 2016 +0200 @@ -50,6 +50,7 @@ 'topic.list.behindcount': 'cyan', 'topic.list.behinderror': 'red', 'topic.stack.index': 'yellow', + 'topic.stack.index.base': 'none dim', 'topic.stack.state.base': 'dim', 'topic.stack.state.clean': 'green', 'topic.stack.index.current': 'cyan', # random pick diff -r 71410fa2c253 -r ba79d23594d6 hgext3rd/topic/stack.py --- a/hgext3rd/topic/stack.py Fri Aug 26 12:37:52 2016 +0200 +++ b/hgext3rd/topic/stack.py Fri Aug 26 12:52:06 2016 +0200 @@ -18,19 +18,21 @@ fm = ui.formatter('topicstack', opts) prev = None entries = [] + idxmap = {} 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 and p1.node() != node.nullid: - entries.append((None, p1)) - entries.append((idx, ctx)) + entries.append((idxmap.get(p1.rev()), False, p1)) + entries.append((idx, True, ctx)) + idxmap[ctx.rev()] = idx prev = r # super crude initial version - for idx, ctx in entries[::-1]: - if idx is None: + for idx, isentry, ctx in entries[::-1]: + if not isentry: symbol = '^' state = 'base' elif repo.revs('%d and parents()', ctx.rev()): @@ -43,6 +45,7 @@ symbol = ':' state = 'clean' fm.startitem() + fm.data(isentry=isentry) if idx is None: fm.plain(' ') else: diff -r 71410fa2c253 -r ba79d23594d6 tests/test-topic-stack.t --- a/tests/test-topic-stack.t Fri Aug 26 12:37:52 2016 +0200 +++ b/tests/test-topic-stack.t Fri Aug 26 12:52:06 2016 +0200 @@ -194,7 +194,7 @@ $ hg top -l t6: c_f t5: c_e - ^ c_d + t2^ c_d (base) t4@ c_h (current) t3: c_g t2: c_d @@ -236,7 +236,7 @@ $ hg topic --list t6$ c_f (unstable) t5$ c_e (unstable) - ^ c_D + t2^ c_D (base) t4: c_h t3: c_g t2@ c_D (current)