# HG changeset patch # User Pierre-Yves David # Date 1471039177 -7200 # Node ID 137f8b04901e808294d0969400d6ccde3cb5f979 # Parent ebdc2a6a9a2591351afb37300b87d2b0dd8f2677 topic: list the number of changesets when --verbose is used Displaying more information in the topic list is useful, we start with the most obvious: number of non-obsolete changeset in the topic. diff -r ebdc2a6a9a25 -r 137f8b04901e hgext3rd/topic/__init__.py --- a/hgext3rd/topic/__init__.py Sun Aug 14 20:40:46 2016 +0200 +++ b/hgext3rd/topic/__init__.py Fri Aug 12 23:59:37 2016 +0200 @@ -289,6 +289,13 @@ fm.plain(' %s ' % marker, label=label) fm.write('topic', '%s', topic, label=label) fm.data(active=active) + if ui.verbose: + # XXX we should include the data even when not verbose + data = stack.stackdata(repo, topic) + fm.plain('\t(') + fm.write('changesetcount', '%d changesets', data['changesetcount'], + label='topic.list.changesetcount') + fm.plain(')') fm.plain('\n') fm.end() diff -r ebdc2a6a9a25 -r 137f8b04901e hgext3rd/topic/stack.py --- a/hgext3rd/topic/stack.py Sun Aug 14 20:40:46 2016 +0200 +++ b/hgext3rd/topic/stack.py Fri Aug 12 23:59:37 2016 +0200 @@ -64,6 +64,16 @@ fm.plain('\n') fm.end() +def stackdata(repo, topic): + """get various data about a stack + + :changesetcount: number of non-obsolete changesets in the stack + """ + data = {} + revs = repo.revs("topic(%s) - obsolete()", topic) + data['changesetcount'] = len(revs) + return data + # Copied from evolve 081605c2e9b6 def _orderrevs(repo, revs): diff -r ebdc2a6a9a25 -r 137f8b04901e tests/test-topic-list.t --- a/tests/test-topic-list.t Sun Aug 14 20:40:46 2016 +0200 +++ b/tests/test-topic-list.t Fri Aug 12 23:59:37 2016 +0200 @@ -173,10 +173,10 @@ verbose $ hg topic --verbose - bar - baz - * foo - fuz + bar (5 changesets) + baz (2 changesets) + * foo (2 changesets) + fuz (3 changesets) json @@ -206,18 +206,22 @@ [ { "active": false, + "changesetcount": 5, "topic": "bar" }, { "active": false, + "changesetcount": 2, "topic": "baz" }, { "active": true, + "changesetcount": 2, "topic": "foo" }, { "active": false, + "changesetcount": 3, "topic": "fuz" } ]