next: prompt user to choose child in ambiguity in `hg next --evolve`
This patch makes `hg next --evolve` prompt user to choose a child to evolve and
update when multiple of them exists. This is improvement over previous behavior
where we used to error out saying ambiguous next unstable changeset and told
user to manually use `hg evolve -r rev`. While writing this patch, I am
personally very happy to have this feature as I have encountered this stage many
times and I wanted `next --evolve` to take care of that.
It uses the revselectionprompt thing added in earlier patches.
--- a/hgext3rd/evolve/__init__.py Fri Mar 16 11:56:50 2018 +0530
+++ b/hgext3rd/evolve/__init__.py Fri Mar 16 12:14:39 2018 +0530
@@ -1139,11 +1139,18 @@
ui.warn(msg % len(aspchildren))
result = 1
elif 1 < len(aspchildren):
- ui.warn(_("ambiguous next (unstable) changeset:\n"))
- for c in aspchildren:
- displayer.show(repo[c])
- ui.warn(_("(run 'hg evolve --rev REV' on one of them)\n"))
- return 1
+ cheader = _("ambiguous next (unstable) changeset, choose one to"
+ " evolve and update:")
+ choosedrev = utility.revselectionprompt(ui, repo,
+ aspchildren, cheader)
+ if choosedrev is None:
+ ui.warn(_("ambiguous next (unstable) changeset:\n"))
+ for c in aspchildren:
+ displayer.show(repo[c])
+ ui.warn(_("(run 'hg evolve --rev REV' on one of them)\n"))
+ return 1
+ else:
+ return _nextevolve(ui, repo, repo[choosedrev], opts)
else:
return _nextevolve(ui, repo, aspchildren[0], opts)
return 1
--- a/tests/test-prev-next.t Fri Mar 16 11:56:50 2018 +0530
+++ b/tests/test-prev-next.t Fri Mar 16 12:14:39 2018 +0530
@@ -235,12 +235,30 @@
no children
(2 unstable changesets to be evolved here, do you want --evolve?)
[1]
- $ hg next --evolve
- ambiguous next (unstable) changeset:
- [4] added c
- [5] added d
- (run 'hg evolve --rev REV' on one of them)
- [1]
+ $ hg next --evolve <<EOF
+ > 0
+ > EOF
+ ambiguous next (unstable) changeset, choose one to evolve and update:
+ 0: [e3b6d5df389b] added c
+ 1: [9df671ccd2c7] added d
+ q: quit the prompt
+ enter the index of the revision you want to select: 0
+ move:[4] added c
+ atop:[6] added b (3)
+ working directory now at 5ce67c2407b0
+
+ $ hg log -GT "{rev}:{node|short} {desc}\n"
+ @ 7:5ce67c2407b0 added c
+ |
+ o 6:d7f119adc759 added b (3)
+ |
+ | * 5:9df671ccd2c7 added d
+ | |
+ | x 3:9ad178109a19 added b (2)
+ |/
+ o 0:a154386e50d1 added a
+
+
$ hg evolve -r 5
move:[5] added d
atop:[6] added b (3)