interactive next --top

Summary:
# Context

See D32917522

# On this diff

This diff implements interactive mode for the `hg next --top` command only. It allows choosing directly between the heads rather than choosing on each branch step

Reviewed By: mitrandir77

Differential Revision: D32920283

fbshipit-source-id: a74d68f9753ee772e6962a85da9d458504a836a1
This commit is contained in:
Yan Soares Couto 2021-12-14 13:16:43 -08:00 committed by Facebook GitHub Bot
parent 4b40d6f118
commit 8319b3ebb3
2 changed files with 17 additions and 2 deletions

View File

@ -400,14 +400,17 @@ def _findstacktop(ui, repo, newest=False):
# would result in different destination changesets.
return _findnexttarget(ui, repo, newest=True, top=True)
ui.warn(_("current stack has multiple heads, namely:\n"))
_showchangesets(ui, repo, nodes=heads)
_showchangesets(ui, repo, nodes=heads, indices=ui.interactive())
if ui.interactive():
return _choosenode(ui, heads)
raise error.Abort(
_("ambiguous next changeset"),
hint=_(
"use the --newest flag to always pick the newest child at each step"
),
)
return next(iter(heads), None)
else:
return next(iter(heads), None)
def _findstackbottom(ui, repo):

View File

@ -290,6 +290,18 @@ Test interactive:
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
(leaving bookmark bottom)
[ae9b2b] branch a
$ hg up bottom -q
$ hg --config ui.interactive=true next --top <<EOF
> 3
> EOF
current stack has multiple heads, namely:
(1) [f2987e] (top) r5
(2) [ae9b2b] branch a
(3) [9913ce] branch b
which changeset to move to [1-3/(c)ancel]? 3
3 files updated, 0 files merged, 0 files removed, 0 files unresolved
(leaving bookmark bottom)
[9913ce] branch b
Test next prefer draft commit.