hgext3rd/topic/stack.py
changeset 1909 36112e361ee4
parent 1907 95874e8fc5f2
child 1914 17782631d7e8
--- 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]: