# HG changeset patch # User Pulkit Goyal <7895pulkit@gmail.com> # Date 1521032062 -19800 # Node ID bc47c09c97828b03ca9846089ad100872f787031 # Parent 0624732c92f798c6df1c70bf08a6f16c896ad022 evolve: prompt user to select destination for stabilization in case of split This patch adds functionality to prompt user to select a revision when there exists multiple stabilization destination because of split on multiple branches. Test are also added for the feature. I am not sure whether this is the best message which we can show, if people have suggestions I will like to improve the messages shown in prompt. diff -r 0624732c92f7 -r bc47c09c9782 hgext3rd/evolve/evolvecmd.py --- a/hgext3rd/evolve/evolvecmd.py Wed Mar 14 18:36:35 2018 +0530 +++ b/hgext3rd/evolve/evolvecmd.py Wed Mar 14 18:24:22 2018 +0530 @@ -127,10 +127,17 @@ roots = repo.revs('roots(%ld)', targetrevs) heads = repo.revs('heads(%ld)', targetrevs) if len(roots) > 1 or len(heads) > 1: - msg = "cannot solve split across two branches\n" - ui.write_err(msg) - return (False, '') - target = repo[heads.first()] + cheader = "ancestor '%s' split over multiple topological branches."\ + "\nchoose an evolve destination:" % orig + selectedrev = utility.revselectionprompt(ui, repo, list(heads), + cheader) + if selectedrev is None: + msg = "cannot solve split across two branches\n" + ui.write_err(msg) + return (False, '') + target = repo[selectedrev] + else: + target = repo[heads.first()] else: target = targets[0] displayer = compat.changesetdisplayer(ui, repo, {'template': shorttemplate}) diff -r 0624732c92f7 -r bc47c09c9782 tests/test-evolve-orphan-split.t --- a/tests/test-evolve-orphan-split.t Wed Mar 14 18:36:35 2018 +0530 +++ b/tests/test-evolve-orphan-split.t Wed Mar 14 18:24:22 2018 +0530 @@ -181,12 +181,93 @@ o 0:8fa14d15e168 added hgignore () draft - $ hg evolve --dry-run + $ hg evolve --dry-run < 0 + > EOF + ancestor 'd48a30875f01' split over multiple topological branches. + choose an evolve destination: + 0: [f2632392aefe] added a b c + 1: [7f87764e5b64] added a b c + q: quit the prompt + enter the index of the revision you want to select: 0 + move:[7] added d + atop:[8] added a b c + hg rebase -r d48a30875f01 -d f2632392aefe + + $ hg evolve --dry-run < 1 + > EOF + ancestor 'd48a30875f01' split over multiple topological branches. + choose an evolve destination: + 0: [f2632392aefe] added a b c + 1: [7f87764e5b64] added a b c + q: quit the prompt + enter the index of the revision you want to select: 1 + move:[7] added d + atop:[10] added a b c + hg rebase -r d48a30875f01 -d 7f87764e5b64 + +Testing the interactive prompt with invalid values first +(this should move its own test file when we use it at multiple places) + + $ hg evolve --all < foo + > EOF + ancestor 'd48a30875f01' split over multiple topological branches. + choose an evolve destination: + 0: [f2632392aefe] added a b c + 1: [7f87764e5b64] added a b c + q: quit the prompt + enter the index of the revision you want to select: foo + invalid value 'foo' entered for index cannot solve split across two branches -XXX: this sounds like a good thing, maybe we should suggest using commands like -grab or rebase to resolve this. Moreover showing the branch heads or list of -successors on different branches will be good. + $ hg evolve --all < 4 + > EOF + ancestor 'd48a30875f01' split over multiple topological branches. + choose an evolve destination: + 0: [f2632392aefe] added a b c + 1: [7f87764e5b64] added a b c + q: quit the prompt + enter the index of the revision you want to select: 4 + invalid value '4' entered for index + cannot solve split across two branches + + $ hg evolve --all < -1 + > EOF + ancestor 'd48a30875f01' split over multiple topological branches. + choose an evolve destination: + 0: [f2632392aefe] added a b c + 1: [7f87764e5b64] added a b c + q: quit the prompt + enter the index of the revision you want to select: -1 + invalid value '-1' entered for index + cannot solve split across two branches - $ hg evolve --all + $ hg evolve --all < q + > EOF + ancestor 'd48a30875f01' split over multiple topological branches. + choose an evolve destination: + 0: [f2632392aefe] added a b c + 1: [7f87764e5b64] added a b c + q: quit the prompt + enter the index of the revision you want to select: q cannot solve split across two branches + +Doing the evolve with the interactive prompt + + $ hg evolve --all < 1 + > EOF + ancestor 'd48a30875f01' split over multiple topological branches. + choose an evolve destination: + 0: [f2632392aefe] added a b c + 1: [7f87764e5b64] added a b c + q: quit the prompt + enter the index of the revision you want to select: 1 + move:[7] added d + atop:[10] added a b c + working directory is now at 1c6caa7c902a