diff hgext3rd/topic/stack.py @ 1991:ba79d23594d6

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.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Fri, 26 Aug 2016 12:52:06 +0200
parents 71410fa2c253
children 54d6dff699f0
line wrap: on
line diff
--- 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: