evolve: handle split commit for instability
authorLaurent Charignon <lcharignon@fb.com>
Wed, 24 Jun 2015 16:27:36 -0700
changeset 1481 3c0aebe73482
parent 1480 bc4c7b1bb793
child 1482 c7726b19c7a0
evolve: handle split commit for instability
hgext/evolve.py
tests/test-evolve-split.t
tests/test-evolve.t
tests/test-unstable.t
--- a/hgext/evolve.py	Fri Aug 07 13:59:19 2015 -0700
+++ b/hgext/evolve.py	Wed Jun 24 16:27:36 2015 -0700
@@ -1708,10 +1708,17 @@
     targets = newer[0]
     assert targets
     if len(targets) > 1:
-        msg = _("does not handle split parents yet\n")
-        ui.write_err(msg)
-        return 2
-    target = targets[0]
+        # split target, figure out which one to pick, are they all in line?
+        targetrevs = [repo[r].rev() for r in targets]
+        roots = repo.revs('roots(%ld)', targetrevs)
+        heads = repo.revs('heads(%ld)', targetrevs)
+        if len(roots) > 1 or len(heads) > 1:
+            msg = "cannot solve split accross two branches\n"
+            ui.write_err(msg)
+            return 2
+        target = repo[heads.first()]
+    else:
+        target = targets[0]
     displayer = cmdutil.show_changeset(ui, repo, {'template': shorttemplate})
     target = repo[target]
     if not ui.quiet or confirm:
--- a/tests/test-evolve-split.t	Fri Aug 07 13:59:19 2015 -0700
+++ b/tests/test-evolve-split.t	Wed Jun 24 16:27:36 2015 -0700
@@ -58,4 +58,6 @@
   o  0:58663bb03074@default(draft) add aa
   
   $ hg evolve --rev "0::"
-  does not handle split parents yet
+  move:[2] add uu
+  atop:[4] _pp
+  working directory is now at 6f5bbe2e3df3
--- a/tests/test-evolve.t	Fri Aug 07 13:59:19 2015 -0700
+++ b/tests/test-evolve.t	Wed Jun 24 16:27:36 2015 -0700
@@ -1393,6 +1393,8 @@
   o  18:0bb66d4c1968@default(draft) a3
   |
   $ hg evolve --rev "18::"
-  does not handle split parents yet
+  move:[33] add uu
+  atop:[35] _pp
+  working directory is now at 04fae07745d4
 
 
--- a/tests/test-unstable.t	Fri Aug 07 13:59:19 2015 -0700
+++ b/tests/test-unstable.t	Wed Jun 24 16:27:36 2015 -0700
@@ -182,7 +182,6 @@
 ===============================================================================
 Test instability resolution for a changeset unstable because its parent
 is obsolete with multiple successors all in one chain (simple split)
-Not supported yet
 ==============================================================================
 
   $ hg init test4
@@ -208,16 +207,16 @@
   
 
   $ hg evo --all --any --unstable
-  does not handle split parents yet
+  move:[2] add _c
+  atop:[4] add bprimesplit2
+  working directory is now at 387cc1e837d7
   $ hg log -G
-  @  4:2a4ccc0bb20c@default(draft) add bprimesplit2
+  @  5:387cc1e837d7@default(draft) add _c
+  |
+  o  4:2a4ccc0bb20c@default(draft) add bprimesplit2
   |
   o  3:8b87864bd0f4@default(draft) add bprimesplit1
   |
-  | o  2:102002290587@default(draft) add _c
-  | |
-  | x  1:37445b16603b@default(draft) add _b
-  |/
   o  0:135f39f4bd78@default(draft) add _a
   
 
@@ -228,7 +227,6 @@
 Test instability resolution for a changeset unstable because its parent
 is obsolete with multiple successors on one branches but in reverse
 order (cross-split).
-Not supported yet
 ==============================================================================
 
   $ hg init test5
@@ -263,16 +261,16 @@
   
 
   $ hg evo --all --any --unstable
-  does not handle split parents yet
+  move:[2] add _c
+  atop:[6] add bsecondsplit2
+  working directory is now at 98e3f21461ff
   $ hg log -G
-  @  6:59b942dbda14@default(draft) add bsecondsplit2
+  @  7:98e3f21461ff@default(draft) add _c
+  |
+  o  6:59b942dbda14@default(draft) add bsecondsplit2
   |
   o  5:8ffdae67d696@default(draft) add bsecondsplit1
   |
-  | o  2:102002290587@default(draft) add _c
-  | |
-  | x  1:37445b16603b@default(draft) add _b
-  |/
   o  0:135f39f4bd78@default(draft) add _a
   
 
@@ -312,7 +310,7 @@
   
 
   $ hg evo --all --any --unstable
-  does not handle split parents yet
+  cannot solve split accross two branches
   $ hg log -G
   @  4:3c69ea6aa93e@default(draft) add bprimesplit2
   |