hgext3rd/topic/stack.py
changeset 2670 f5d52fa1cd55
parent 2669 b933a8068c17
child 2684 90e11985d0cc
--- a/hgext3rd/topic/stack.py	Wed Jun 28 02:45:57 2017 +0200
+++ b/hgext3rd/topic/stack.py	Wed Jun 28 01:53:21 2017 +0200
@@ -55,24 +55,33 @@
         label = 'topic.active'
 
     data = stackdata(repo, branch=branch, topic=topic)
-    fm.plain(_('### topic: %s') % ui.label(topic, label),
-             label='topic.stack.summary.topic')
+    if topic is not None:
+        fm.plain(_('### topic: %s')
+                 % ui.label(topic, label),
+                 label='topic.stack.summary.topic')
 
-    if 1 < data['headcount']:
-        fm.plain(' (')
-        fm.plain('%d heads' % data['headcount'],
-                 label='topic.stack.summary.headcount.multiple')
-        fm.plain(')')
-    fm.plain('\n')
+        if 1 < data['headcount']:
+            fm.plain(' (')
+            fm.plain('%d heads' % data['headcount'],
+                     label='topic.stack.summary.headcount.multiple')
+            fm.plain(')')
+        fm.plain('\n')
     fm.plain(_('### branch: %s')
              % '+'.join(data['branches']), # XXX handle multi branches
              label='topic.stack.summary.branches')
-    if data['behindcount'] == -1:
-        fm.plain(', ')
-        fm.plain('ambigious rebase destination', label='topic.stack.summary.behinderror')
-    elif data['behindcount']:
-        fm.plain(', ')
-        fm.plain('%d behind' % data['behindcount'], label='topic.stack.summary.behindcount')
+    if topic is None:
+        if 1 < data['headcount']:
+            fm.plain(' (')
+            fm.plain('%d heads' % data['headcount'],
+                     label='topic.stack.summary.headcount.multiple')
+            fm.plain(')')
+    else:
+        if data['behindcount'] == -1:
+            fm.plain(', ')
+            fm.plain('ambigious rebase destination', label='topic.stack.summary.behinderror')
+        elif data['behindcount']:
+            fm.plain(', ')
+            fm.plain('%d behind' % data['behindcount'], label='topic.stack.summary.behindcount')
     fm.plain('\n')
 
     for idx, r in enumerate(getstack(repo, branch=branch, topic=topic), 1):