changeset 3541:bc47c09c9782

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.
author Pulkit Goyal <7895pulkit@gmail.com>
date Wed, 14 Mar 2018 18:24:22 +0530
parents 0624732c92f7
children 7bd516e0a929
files hgext3rd/evolve/evolvecmd.py tests/test-evolve-orphan-split.t
diffstat 2 files changed, 97 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- 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})
--- 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 <<EOF
+  > 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 <<EOF
+  > 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 <<EOF
+  > 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 <<EOF
+  > 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 <<EOF
+  > -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 <<EOF
+  > 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 <<EOF
+  > 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