# HG changeset patch # User Pierre-Yves David # Date 1471196453 -7200 # Node ID bee7a1ef8ba898bc3333ff0072254bc910a53e8d # Parent e42dd4523c0dbc69e4fe2f7b6825271caf3be356 topic: list the number of head when --verbose is used Displaying more information in the topic list is useful, we continue with the number of heads on the topics, this will help highlight the problem to users. We only display head if there is more than one. diff -r e42dd4523c0d -r bee7a1ef8ba8 hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py Sat Aug 13 01:24:10 2016 +0200 +++ b/hgext3rd/topic/__init__.py Sun Aug 14 19:40:53 2016 +0200 @@ -46,6 +46,7 @@ command = cmdutil.command(cmdtable) colortable = {'topic.active': 'green', 'topic.list.troubledcount': 'red', + 'topic.list.headcount.multiple': 'yellow', 'topic.stack.index': 'yellow', 'topic.stack.state.base': 'dim', 'topic.stack.state.clean': 'green', @@ -301,6 +302,11 @@ fm.write('troubledcount', '%d troubled', data['troubledcount'], label='topic.list.troubledcount') + if 1 < data['headcount']: + fm.plain(', ') + fm.write('headcount', '%d heads', + data['headcount'], + label='topic.list.headcount.multiple') fm.plain(')') fm.plain('\n') fm.end() diff -r e42dd4523c0d -r bee7a1ef8ba8 hgext3rd/topic/stack.py --- a/hgext3rd/topic/stack.py Sat Aug 13 01:24:10 2016 +0200 +++ b/hgext3rd/topic/stack.py Sun Aug 14 19:40:53 2016 +0200 @@ -69,11 +69,15 @@ :changesetcount: number of non-obsolete changesets in the stack :troubledcount: number on troubled changesets + :headcount: number of heads on the topic """ data = {} revs = repo.revs("topic(%s) - obsolete()", topic) data['changesetcount'] = len(revs) data['troubledcount'] = len([r for r in revs if repo[r].troubled()]) + deps, rdeps = builddependencies(repo, revs) + data['headcount'] = len([r for r in revs if not rdeps[r]]) + return data # Copied from evolve 081605c2e9b6 diff -r e42dd4523c0d -r bee7a1ef8ba8 tests/test-topic-list.t --- a/tests/test-topic-list.t Sat Aug 13 01:24:10 2016 +0200 +++ b/tests/test-topic-list.t Sun Aug 14 19:40:53 2016 +0200 @@ -173,7 +173,7 @@ verbose $ hg topic --verbose - bar (5 changesets, 1 troubled) + bar (5 changesets, 1 troubled, 2 heads) baz (2 changesets) * foo (2 changesets) fuz (3 changesets, 2 troubled) @@ -207,6 +207,7 @@ { "active": false, "changesetcount": 5, + "headcount": 2, "topic": "bar", "troubledcount": 1 },