stack: add some behind information
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Fri, 26 Aug 2016 14:55:58 +0200
changeset 1997 ce86f7bb4b7b
parent 1996 5c40dd2cf131
child 1998 302be26a3fd8
stack: add some behind information This is the next useful thing after branch
hgext3rd/topic/__init__.py
hgext3rd/topic/stack.py
tests/test-topic-stack-data.t
--- a/hgext3rd/topic/__init__.py	Fri Aug 26 14:23:31 2016 +0200
+++ b/hgext3rd/topic/__init__.py	Fri Aug 26 14:55:58 2016 +0200
@@ -58,6 +58,8 @@
               'topic.stack.state.current': 'cyan bold',  # random pick
               'topic.stack.desc.current': 'cyan',        # random pick
               'topic.stack.state.unstable': 'red',
+              'topic.stack.summary.behindcount': 'cyan',
+              'topic.stack.summary.behinderror': 'red',
              }
 
 testedwith = '3.9'
--- a/hgext3rd/topic/stack.py	Fri Aug 26 14:23:31 2016 +0200
+++ b/hgext3rd/topic/stack.py	Fri Aug 26 14:55:58 2016 +0200
@@ -28,9 +28,16 @@
     data = stackdata(repo, topic)
     fm.plain(_('### topic: %s\n') % ui.label(topic, label),
              label='topic.stack.summary.topic')
-    fm.plain(_('### branch: %s\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')
+    fm.plain('\n')
 
     for idx, r in enumerate(getstack(repo, topic), 1):
         ctx = repo[r]
--- a/tests/test-topic-stack-data.t	Fri Aug 26 14:23:31 2016 +0200
+++ b/tests/test-topic-stack-data.t	Fri Aug 26 14:55:58 2016 +0200
@@ -251,19 +251,19 @@
     ^ add base_e
   $ hg stack baz
   ### topic: baz
-  ### branch: default
+  ### branch: default, 2 behind
   t2: add baz_b
   t1: add baz_a
     ^ add base_c
   $ hg stack foo
   ### topic: foo
-  ### branch: lake
+  ### branch: lake, ambigious rebase destination
   t2@ add foo_b (current)
   t1: add foo_a
     ^ add lake_a
   $ hg stack fuz
   ### topic: fuz
-  ### branch: default
+  ### branch: default, 1 behind
   t3$ add fuz_c (unstable)
   t2$ add fuz_b (unstable)
   t1: fuz1_a