Mercurial > evolve
changeset 1985:03d6b685c16a
topic: list the number of 'behind' changeset when --verbose is used
Displaying more information in the topic list is useful, we continue with the
number of 'behind' changesets. This 'behind' count the number of new changesets on
the default rebase destination. This will highlight topics that need rebasing.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Sun, 14 Aug 2016 19:57:58 +0200 |
parents | 2a07df823588 |
children | 042356d5ba59 |
files | hgext3rd/topic/__init__.py hgext3rd/topic/stack.py tests/test-topic-list.t |
diffstat | 3 files changed, 33 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext3rd/topic/__init__.py Mon Aug 15 00:19:44 2016 +0200 +++ b/hgext3rd/topic/__init__.py Sun Aug 14 19:57:58 2016 +0200 @@ -47,6 +47,8 @@ colortable = {'topic.active': 'green', 'topic.list.troubledcount': 'red', 'topic.list.headcount.multiple': 'yellow', + 'topic.list.behindcount': 'cyan', + 'topic.list.behinderror': 'red', 'topic.stack.index': 'yellow', 'topic.stack.state.base': 'dim', 'topic.stack.state.clean': 'green', @@ -307,6 +309,16 @@ fm.write('headcount', '%d heads', data['headcount'], label='topic.list.headcount.multiple') + if 0 < data['behindcount']: + fm.plain(', ') + fm.write('behindcount', '%d behind', + data['behindcount'], + label='topic.list.behindcount') + elif -1 == data['behindcount']: + fm.plain(', ') + fm.write('behinderror', '%s', + _('ambiguous destination'), + label='topic.list.behinderror') fm.plain(')') fm.plain('\n') fm.end()
--- a/hgext3rd/topic/stack.py Mon Aug 15 00:19:44 2016 +0200 +++ b/hgext3rd/topic/stack.py Sun Aug 14 19:57:58 2016 +0200 @@ -4,6 +4,7 @@ # GNU General Public License version 2 or any later version. from mercurial.i18n import _ from mercurial import ( + destutil, error, node, ) @@ -69,6 +70,7 @@ :changesetcount: number of non-obsolete changesets in the stack :troubledcount: number on troubled changesets :headcount: number of heads on the topic + :behindcount: number of changeset on rebase destination """ data = {} revs = repo.revs("topic(%s) - obsolete()", topic) @@ -76,6 +78,19 @@ 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]]) + data['behindcount'] = 0 + if revs: + minroot = [min(r for r in revs if not deps[r])] + try: + dest = destutil.destmerge(repo, action='rebase', + sourceset=minroot, + onheadcheck=False) + data['behindcount'] = len(repo.revs("only(%d, %ld)", dest, + minroot)) + except error.NoMergeDestAbort: + data['behindcount'] = 0 + except error.ManyMergeDestAbort: + data['behindcount'] = -1 return data
--- a/tests/test-topic-list.t Mon Aug 15 00:19:44 2016 +0200 +++ b/tests/test-topic-list.t Sun Aug 14 19:57:58 2016 +0200 @@ -174,9 +174,9 @@ $ hg topic --verbose bar (5 changesets, 1 troubled, 2 heads) - baz (2 changesets) - * foo (2 changesets) - fuz (3 changesets, 2 troubled) + baz (2 changesets, 2 behind) + * foo (2 changesets, ambiguous destination) + fuz (3 changesets, 2 troubled, 1 behind) json @@ -213,16 +213,19 @@ }, { "active": false, + "behindcount": 2, "changesetcount": 2, "topic": "baz" }, { "active": true, + "behinderror": "ambiguous destination", "changesetcount": 2, "topic": "foo" }, { "active": false, + "behindcount": 1, "changesetcount": 3, "topic": "fuz", "troubledcount": 2