changeset 1978:e42dd4523c0d

topic: list the number of troubled changesets when --verbose is used Displaying more information in the topic list is useful, we continue with the number of troubled changesets. This will help people to spot topics that needs evolution, for example after a pull.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Sat, 13 Aug 2016 01:24:10 +0200
parents 137f8b04901e
children bee7a1ef8ba8
files hgext3rd/topic/__init__.py hgext3rd/topic/stack.py tests/test-topic-list.t
diffstat 3 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py	Fri Aug 12 23:59:37 2016 +0200
+++ b/hgext3rd/topic/__init__.py	Sat Aug 13 01:24:10 2016 +0200
@@ -45,6 +45,7 @@
 cmdtable = {}
 command = cmdutil.command(cmdtable)
 colortable = {'topic.active': 'green',
+              'topic.list.troubledcount': 'red',
               'topic.stack.index': 'yellow',
               'topic.stack.state.base': 'dim',
               'topic.stack.state.clean': 'green',
@@ -295,6 +296,11 @@
             fm.plain('\t(')
             fm.write('changesetcount', '%d changesets', data['changesetcount'],
                      label='topic.list.changesetcount')
+            if data['troubledcount']:
+                fm.plain(', ')
+                fm.write('troubledcount', '%d troubled',
+                         data['troubledcount'],
+                         label='topic.list.troubledcount')
             fm.plain(')')
         fm.plain('\n')
     fm.end()
--- a/hgext3rd/topic/stack.py	Fri Aug 12 23:59:37 2016 +0200
+++ b/hgext3rd/topic/stack.py	Sat Aug 13 01:24:10 2016 +0200
@@ -68,10 +68,12 @@
     """get various data about a stack
 
     :changesetcount: number of non-obsolete changesets in the stack
+    :troubledcount: number on troubled changesets
     """
     data = {}
     revs = repo.revs("topic(%s) - obsolete()", topic)
     data['changesetcount'] = len(revs)
+    data['troubledcount'] = len([r for r in revs if repo[r].troubled()])
     return data
 
 # Copied from evolve 081605c2e9b6
--- a/tests/test-topic-list.t	Fri Aug 12 23:59:37 2016 +0200
+++ b/tests/test-topic-list.t	Sat Aug 13 01:24:10 2016 +0200
@@ -173,10 +173,10 @@
 verbose
 
   $ hg topic --verbose
-     bar	(5 changesets)
+     bar	(5 changesets, 1 troubled)
      baz	(2 changesets)
    * foo	(2 changesets)
-     fuz	(3 changesets)
+     fuz	(3 changesets, 2 troubled)
 
 json
 
@@ -207,7 +207,8 @@
    {
     "active": false,
     "changesetcount": 5,
-    "topic": "bar"
+    "topic": "bar",
+    "troubledcount": 1
    },
    {
     "active": false,
@@ -222,6 +223,7 @@
    {
     "active": false,
     "changesetcount": 3,
-    "topic": "fuz"
+    "topic": "fuz",
+    "troubledcount": 2
    }
   ]