stack: add warning about multiple heads
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Fri, 26 Aug 2016 21:57:48 +0200
changeset 1998 302be26a3fd8
parent 1997 ce86f7bb4b7b
child 1999 fe76e9c92fff
stack: add warning about multiple heads This seems a good spot to nudge people toward reducing there head count.
hgext3rd/topic/__init__.py
hgext3rd/topic/stack.py
tests/test-topic-stack-data.t
tests/test-topic-stack.t
--- a/hgext3rd/topic/__init__.py	Fri Aug 26 14:55:58 2016 +0200
+++ b/hgext3rd/topic/__init__.py	Fri Aug 26 21:57:48 2016 +0200
@@ -60,6 +60,7 @@
               'topic.stack.state.unstable': 'red',
               'topic.stack.summary.behindcount': 'cyan',
               'topic.stack.summary.behinderror': 'red',
+              'topic.stack.summary.headcount.multiple': 'yellow',
              }
 
 testedwith = '3.9'
--- a/hgext3rd/topic/stack.py	Fri Aug 26 14:55:58 2016 +0200
+++ b/hgext3rd/topic/stack.py	Fri Aug 26 21:57:48 2016 +0200
@@ -26,8 +26,15 @@
         label = 'topic.active'
 
     data = stackdata(repo, topic)
-    fm.plain(_('### topic: %s\n') % ui.label(topic, label),
+    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')
     fm.plain(_('### branch: %s')
              % '+'.join(data['branches']), # XXX handle multi branches
              label='topic.stack.summary.branches')
--- a/tests/test-topic-stack-data.t	Fri Aug 26 14:55:58 2016 +0200
+++ b/tests/test-topic-stack-data.t	Fri Aug 26 21:57:48 2016 +0200
@@ -240,7 +240,7 @@
 =======================================
 
   $ hg stack bar
-  ### topic: bar
+  ### topic: bar (2 heads)
   ### branch: default
   t5: add bar_c
   t2^ add bar_b (base)
--- a/tests/test-topic-stack.t	Fri Aug 26 14:55:58 2016 +0200
+++ b/tests/test-topic-stack.t	Fri Aug 26 21:57:48 2016 +0200
@@ -198,7 +198,7 @@
 Test output
 
   $ hg top -l
-  ### topic: foo
+  ### topic: foo (2 heads)
   ### branch: default
   t6: c_f
   t5: c_e
@@ -242,7 +242,7 @@
   
 
   $ hg topic --list
-  ### topic: foo
+  ### topic: foo (2 heads)
   ### branch: default
   t6$ c_f (unstable)
   t5$ c_e (unstable)