@@ -189,6 +189,7 @@
try:
evolve = extensions.find('evolve')
extensions.wrapfunction(evolve, "presplitupdate", presplitupdatetopic)
+ extensions.wrapfunction(evolve, "movetonext", nextwithtopic)
extensions.wrapfunction(evolve, "movetoprev", prevwithtopic)
except (KeyError, AttributeError):
pass
@@ -575,6 +576,30 @@
topicparent = [repo[parentrev]]
return orig(ui, repo, topicparent, opts)
+def nextwithtopic(orig, ui, repo, childrens, opts):
+ if opts.get('no_topic'):
+ return orig(ui, repo, childrens, opts)
+ ctx = repo[None].parents()[0]
+ revnum = ctx.rev()
+ curtopic = repo.currenttopic
+ if not curtopic:
+ curtopic = ctx.topic()
+ if not curtopic:
+ return orig(ui, repo, childrens, opts)
+ revlist = stack.getstack(repo, topic=curtopic)
+ idx = revlist.index(revnum)
+ try:
+ idx = revlist.index(revnum)
+ except IndexError:
+ # Lets move to the root of the current topic
+ idx = -1
+ if idx == len(revlist) - 1:
+ msg = _('no more changesets in topic "%s"')
+ raise error.Abort(msg % curtopic)
+ childrev = revlist[idx + 1]
+ topicchild = [repo[childrev]]
+ return orig(ui, repo, topicchild, opts)
+
def _fixrebase(loaded):
if not loaded:
return
@@ -194,21 +194,53 @@
$ hg up foo
switching to topic foo
0 files updated, 0 files merged, 4 files removed, 0 files unresolved
+ $ hg stack
+ ### topic: foo
+ ### branch: default
+ t4@ add fff (current)
+ t3: add eee
+ t2: add ddd
+ t1: add ccc
+ t0^ add bbb (base)
+
+Moving back and forth
+=====================
+
$ 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
+
+Trying to go beyond the topic
+=============================
+
$ hg next
+ abort: no more changesets in topic "foo"
+ [255]
+ $ hg next --no-topic
switching to topic bar
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
[16] add ggg
- $ hg next --no-topic
+
+Updating to t0 using `hg prev`
+==============================
+
+ $ hg stack
+ ### topic: bar
+ ### branch: default
+ t4: add jjj
+ t3: add iii
+ t2: add hhh
+ t1@ add ggg (current)
+ t0^ add fff (base)
+ $ hg prev
+ preserving the current topic 'bar'
+ 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+ [15] add fff
+ $ hg next
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
- [17] add hhh
- $ hg prev
- 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
[16] add ggg
$ hg prev --no-topic
switching to topic foo