changeset 5579:6289ddfb9d48

evolve: refactor some error raising logic in content-divergence This patch makes sure that we raise error when it is ambiguous for us to decide the resolution parent. It modifies a test also to make sure that we don't loose code coverage for some cases.
author Sushil khanchi <sushilkhanchi97@gmail.com>
date Fri, 21 Aug 2020 18:04:48 +0530
parents b0234a269f29
children cc0f46025c7f
files hgext3rd/evolve/evolvecmd.py tests/test-evolve-content-divergent-stack.t
diffstat 2 files changed, 36 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/evolvecmd.py	Fri Aug 21 16:22:24 2020 +0530
+++ b/hgext3rd/evolve/evolvecmd.py	Fri Aug 21 18:04:48 2020 +0530
@@ -319,16 +319,21 @@
     otherp1 = succsotherp1 = other.p1().rev()
     divp1 = succsdivp1 = divergent.p1().rev()
 
-    # finding single successors of otherp1 and divp1
+    # finding single successors of divp1 and otherp1
+    try:
+        succsdivp1 = utility._singlesuccessor(repo, divergent.p1())
+    except utility.MultipleSuccessorsError:
+        msg = _(b"skipping %s: ambiguous orphan resolution parent for "
+                b"%s\n") % (divergent, divergent)
+        ui.write_err(msg)
+        return (False, b".")
     try:
         succsotherp1 = utility._singlesuccessor(repo, other.p1())
     except utility.MultipleSuccessorsError:
-        pass
-
-    try:
-        succsdivp1 = utility._singlesuccessor(repo, divergent.p1())
-    except utility.MultipleSuccessorsError:
-        pass
+        msg = _(b"skipping %s: ambiguous orphan resolution parent for "
+                b"%s\n") % (divergent, other)
+        ui.write_err(msg)
+        return (False, b".")
 
     # the changeset on which resolution changeset will be based on
     resolutionparent = repo[succsdivp1].node()
--- a/tests/test-evolve-content-divergent-stack.t	Fri Aug 21 16:22:24 2020 +0530
+++ b/tests/test-evolve-content-divergent-stack.t	Fri Aug 21 18:04:48 2020 +0530
@@ -1150,17 +1150,33 @@
   o  0:bde1d2b6b5e5 added base
       () [default] draft
 
+  $ hg reb -r 10 -d 7
+  rebasing 10:9a1f460df8b5 "added dar"
+  $ hg up 0 -q
+  $ echo alpha > alpha
+  $ hg ci -Am "added alpha"
+  adding alpha
+  created new head
+  $ hg reb -r 6 -d 'desc("added alpha")'
+  rebasing 6:57a3f8edf065 "added dar"
+  $ hg evolve --content-divergent
+  skipping 8b68d5104188: have a different parent than cf9a46e19942 (not handled yet)
+  | 8b68d5104188, cf9a46e19942 are not based on the same changeset.
+  | With the current state of its implementation, 
+  | evolve does not work in that case.
+  | rebase one of them next to the other and run 
+  | this command again.
+  | - either: hg rebase --dest 'p1(8b68d5104188)' -r cf9a46e19942
+  | - or:     hg rebase --dest 'p1(cf9a46e19942)' -r 8b68d5104188
+
+  $ hg strip -r 16:
+  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+  saved backup bundle to $TESTTMP/multiplesuccs2/.hg/strip-backup/8b68d5104188-e72c2390-backup.hg
+  2 new orphan changesets
   $ echo bar > bar; hg ci -Aqm "added bar"
   $ echo car > car; hg ci -Aqm "added car"
   $ hg prune --split -s 16+17 -r 15
   1 changesets pruned
 
   $ hg evolve --content-divergent
-  skipping 57a3f8edf065: have a different parent than 9a1f460df8b5 (not handled yet)
-  | 57a3f8edf065, 9a1f460df8b5 are not based on the same changeset.
-  | With the current state of its implementation, 
-  | evolve does not work in that case.
-  | rebase one of them next to the other and run 
-  | this command again.
-  | - either: hg rebase --dest 'p1(57a3f8edf065)' -r 9a1f460df8b5
-  | - or:     hg rebase --dest 'p1(9a1f460df8b5)' -r 57a3f8edf065
+  skipping 57a3f8edf065: ambiguous orphan resolution parent for 57a3f8edf065