# HG changeset patch # User Pierre-Yves David # Date 1458239101 25200 # Node ID db19b1dc5c4590478205fd51e31a348644226075 # Parent a91115687a7e95fa882e712b94c0cfec7aa024c1 topic: restrict 'hg prev' to current topic unless --no-topic is passed This is far from perfect but a good start. diff -r a91115687a7e -r db19b1dc5c45 hgext/evolve.py --- a/hgext/evolve.py Thu Mar 17 10:04:30 2016 -0700 +++ b/hgext/evolve.py Thu Mar 17 11:25:01 2016 -0700 @@ -2079,6 +2079,7 @@ [('B', 'move-bookmark', False, _('move active bookmark after update')), ('', 'merge', False, _('bring uncommitted change along')), + ('', 'no-topic', False, _('ignore topic and move topologically')), ('n', 'dry-run', False, _('do not perform actions, just print what would be done'))], '[OPTION]...') @@ -2160,6 +2161,12 @@ raise children = [ctx for ctx in wparents[0].children() if not ctx.obsolete()] + topic = getattr(repo, 'currenttopic', '') + filtered = [] + if topic and not opts.get("no_topic", False): + filtered = [ctx for ctx in children if ctx.topic() != topic] + # XXX N-square membership on children + children = [ctx for ctx in children if ctx not in filtered] displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate}) if len(children) == 1: c = children[0] @@ -2195,8 +2202,17 @@ result = 1 else: aspchildren = _aspiringchildren(repo, [repo['.'].rev()]) + if topic: + filtered.extend(repo[c] for c in children + if repo[c].topic() != topic) + # XXX N-square membership on children + aspchildren = [ctx for ctx in aspchildren if ctx not in filtered] if not opts['evolve'] or not aspchildren: - ui.warn(_('no children\n')) + if filtered: + ui.warn(_('no children on topic "%s"\n') % topic) + ui.warn(_('do you want --no-topic\n')) + else: + ui.warn(_('no children\n')) if aspchildren: msg = _('(%i unstable changesets to be evolved here, ' 'do you want --evolve?)\n') diff -r a91115687a7e -r db19b1dc5c45 tests/test-evolve-topic.t --- a/tests/test-evolve-topic.t Thu Mar 17 10:04:30 2016 -0700 +++ b/tests/test-evolve-topic.t Thu Mar 17 11:25:01 2016 -0700 @@ -191,3 +191,26 @@ | o 0 - {} 199cc73e9a0b add aaa (draft) + +Tests next and prev behavior +============================ + +Basic move are restricted to the current topic + + $ hg up foo + switching to topic foo + 0 files updated, 0 files merged, 4 files removed, 0 files unresolved + $ hg prev + 0 files updated, 0 files merged, 1 files removed, 0 files unresolved + [14] add eee + $ hg next + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + [15] add fff + $ hg next + no children on topic "foo" + do you want --no-topic + [1] + $ hg next --no-topic + switching to topic bar + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + [16] add ggg