Mercurial > evolve
changeset 1977:137f8b04901e
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.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Fri, 12 Aug 2016 23:59:37 +0200 |
parents | ebdc2a6a9a25 |
children | e42dd4523c0d |
files | hgext3rd/topic/__init__.py hgext3rd/topic/stack.py tests/test-topic-list.t |
diffstat | 3 files changed, 25 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- 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()
--- 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):
--- 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" } ]