hgext3rd/evolve/evolvecmd.py
changeset 5075 fbe614cae40c
parent 5064 c9138c441761
child 5111 1fe3f7ffb462
--- a/hgext3rd/evolve/evolvecmd.py	Wed Jan 15 15:28:44 2020 +0700
+++ b/hgext3rd/evolve/evolvecmd.py	Sun Dec 08 02:17:11 2019 +0530
@@ -128,35 +128,22 @@
         while repo[newer].node() == orig.node():
             obs = obs.parents()[0]
             newer = utility._singlesuccessor(repo, obs)
-        target = newer
     except utility.MultipleSuccessorsError as exc:
         if exc.divergenceflag:
             msg = _(b"skipping %s: divergent rewriting. can't choose "
                     b"destination\n") % obs
             ui.write_err(msg)
             return (False, b".")
-        targets = exc.successorssets[0]
-        assert targets
         if exc.splitflag:
-            # split target, figure out which one to pick, are they all in line?
-            targetrevs = [repo[r].rev() for r in targets]
-            roots = repo.revs(b'roots(%ld)', targetrevs)
-            heads = repo.revs(b'heads(%ld)', targetrevs)
-            if len(roots) > 1 or len(heads) > 1:
-                cheader = _(b"ancestor '%s' split over multiple topological"
-                            b" branches.\nchoose an evolve destination:") % orig
-                selectedrev = utility.revselectionprompt(ui, repo, list(heads),
-                                                         cheader)
-                if selectedrev is None:
-                    msg = _(b"could not solve instability, "
-                            b"ambiguous destination: "
-                            b"parent split across two branches\n")
-                    ui.write_err(msg)
-                    return (False, b".")
-                target = repo[selectedrev]
-            else:
-                target = repo[heads.first()]
-    target = repo[target]
+            splitsucc = utility.picksplitsuccessor(ui, repo, obs, orig)
+            if not splitsucc[0]:
+                msg = _(b"could not solve instability, "
+                        b"ambiguous destination: "
+                        b"parent split across two branches\n")
+                ui.write_err(msg)
+                return (False, b".")
+            newer = splitsucc[1]
+    target = repo[newer]
     if not ui.quiet or confirm:
         repo.ui.write(_(b'move:'), label=b'evolve.operation')
         displayer.show(orig)