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.
--- 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
}
]