changeset 5562:5907b495901e

evolve: handle preparation logic for public divergence in one block
author Sushil khanchi <sushilkhanchi97@gmail.com>
date Thu, 13 Aug 2020 18:10:51 +0530
parents d6b3f32f8261
children 9034eef6e737
files hgext3rd/evolve/evolvecmd.py tests/test-evolve-public-content-divergent-corner-cases.t tests/test-evolve-public-content-divergent-discard.t tests/test-evolve-public-content-divergent-main.t
diffstat 4 files changed, 42 insertions(+), 41 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/evolvecmd.py	Thu Aug 13 17:22:19 2020 +0530
+++ b/hgext3rd/evolve/evolvecmd.py	Thu Aug 13 18:10:51 2020 +0530
@@ -307,11 +307,9 @@
         evolvestate[b'other-divergent'] = other.node()
         return div, other
 
-    # keep track if we are solving public content-divergence
-    haspublicdiv = False
     if not (divergent.mutable() and other.mutable()):
-        haspublicdiv = True
         # for simplicity, we keep public one to local side while merging
+        sameparent = divergent.p1().rev() == other.p1().rev()
         # When public branch is behind to the mutable branch, for now we
         # relocate mutable cset to public one's side in every case.
         #
@@ -322,10 +320,16 @@
         # brancmap level.
         if divergent.mutable():
             publicdiv = other
-            divergent, other = swapnodes(divergent, other)
+            if not sameparent:
+                evolvestate[b'relocate-div'] = True
         else:
             publicdiv = divergent
+            if not sameparent:
+                evolvestate[b'relocate-other'] = True
+        resolutionparent = publicdiv.p1().node()
         evolvestate[b'public-divergent'] = publicdiv.node()
+        relocatereq = evolvestate[b'relocate-other']
+        return (True, divergent, other, resolutionparent, relocatereq)
 
     otherp1 = succsotherp1 = other.p1().rev()
     divp1 = succsdivp1 = divergent.p1().rev()
@@ -395,10 +399,8 @@
             pass
         if otheronly:
             relocatereq = True
-            if not haspublicdiv:
-                # can't swap when public divergence, as public can't move
-                divergent, other = swapnodes(divergent, other)
-                resolutionparent = repo[succsotherp1].node()
+            divergent, other = swapnodes(divergent, other)
+            resolutionparent = repo[succsotherp1].node()
         elif divonly:
             relocatereq = True
         else:
@@ -410,9 +412,8 @@
     elif succsdivp1 in gca and succsotherp1 not in gca:
         relocatereq = True
 
-        if not haspublicdiv:
-            divergent, other = swapnodes(divergent, other)
-            resolutionparent = divergent.p1().node()
+        divergent, other = swapnodes(divergent, other)
+        resolutionparent = divergent.p1().node()
     else:
         msg = _(b"skipping %s: have a different parent than %s "
                 b"(not handled yet)\n") % (divergent, other)
@@ -522,7 +523,7 @@
                   % divergent))
         return (False, b".")
     # relocate divergent cset to its obsolete parent's successsor
-    if divergent.p1().node() != resolutionparent:
+    if divergent.p1().node() != resolutionparent or evolvestate[b'relocate-div']:
         evolvestate[b'relocating-div'] = True
         ui.status(_(b'rebasing "divergent" content-divergent changeset %s on'
                     b' %s\n' % (divergent, repo[resolutionparent])))
@@ -536,7 +537,7 @@
         divergent = repo[newdivergent]
 
     # relocate the other divergent if required
-    if relocatereq:
+    if relocatereq or evolvestate[b'relocate-other']:
         # relocating will help us understand during the time of conflicts that
         # whether conflicts occur at reloacting or they occured at merging
         # content divergent changesets
--- a/tests/test-evolve-public-content-divergent-corner-cases.t	Thu Aug 13 17:22:19 2020 +0530
+++ b/tests/test-evolve-public-content-divergent-corner-cases.t	Thu Aug 13 18:10:51 2020 +0530
@@ -388,10 +388,10 @@
   
 
   $ hg evolve --content-divergent --any --update
-  merge:[5] added d
-  with: [4] added c e
+  merge:[4] added c e
+  with: [5] added d
   base: [3] added d
-  rebasing "other" content-divergent changeset e568fd1029bb on 155349b645be
+  rebasing "divergent" content-divergent changeset e568fd1029bb on 155349b645be
   merging c
   warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
   unresolved merge conflicts
--- a/tests/test-evolve-public-content-divergent-discard.t	Thu Aug 13 17:22:19 2020 +0530
+++ b/tests/test-evolve-public-content-divergent-discard.t	Thu Aug 13 18:10:51 2020 +0530
@@ -89,8 +89,8 @@
       public
   
   $ hg evolve --content-divergent --any
-  merge:[4] added c
-  with: [3] added ch
+  merge:[3] added ch
+  with: [4] added c
   base: [2] added c
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   other divergent changeset 90522bccf499 has same content as local f7c1071f1e7c and differs by "description" only, discarding 90522bccf499
@@ -180,10 +180,10 @@
       public
   
   $ hg evolve --content-divergent --any
-  merge:[5] added d
-  with: [4] added dh
+  merge:[4] added dh
+  with: [5] added d
   base: [3] added d
-  rebasing "other" content-divergent changeset 5acd58ef5066 on 155349b645be
+  rebasing "divergent" content-divergent changeset 5acd58ef5066 on 155349b645be
   0 files updated, 0 files merged, 0 files removed, 0 files unresolved
   other divergent changeset ae3429430ef1 has same content as local e800202333a4 and differs by "description" only, discarding ae3429430ef1
   content divergence resolution between e800202333a4 (public) and ae3429430ef1 has same content as e800202333a4, discarding ae3429430ef1
@@ -265,8 +265,8 @@
       public
   
   $ hg evolve --content-divergent --any
-  merge:[4] added c
-  with: [3] added ch
+  merge:[3] added ch
+  with: [4] added c
   base: [2] added c
   merging ch
   warning: conflicts while merging ch! (edit, then use 'hg resolve --mark')
@@ -380,10 +380,10 @@
       public
   
   $ hg evolve --content-divergent --any
-  merge:[5] added d
-  with: [4] added dh
+  merge:[4] added dh
+  with: [5] added d
   base: [3] added d
-  rebasing "other" content-divergent changeset f89a8e2f86ac on 155349b645be
+  rebasing "divergent" content-divergent changeset f89a8e2f86ac on 155349b645be
   merging c
   warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
   unresolved merge conflicts
@@ -485,10 +485,10 @@
       public
   
   $ hg evolve --content-divergent --any
-  merge:[5] added d
-  with: [4] added dh
+  merge:[4] added dh
+  with: [5] added d
   base: [3] added d
-  rebasing "other" content-divergent changeset db0b7bba0aae on 155349b645be
+  rebasing "divergent" content-divergent changeset db0b7bba0aae on 155349b645be
   merging dh
   warning: conflicts while merging dh! (edit, then use 'hg resolve --mark')
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
@@ -589,10 +589,10 @@
       public
   
   $ hg evolve --content-divergent --any
-  merge:[5] added d
-  with: [4] added dh
+  merge:[4] added dh
+  with: [5] added d
   base: [3] added d
-  rebasing "other" content-divergent changeset 67b19bbd770f on 155349b645be
+  rebasing "divergent" content-divergent changeset 67b19bbd770f on 155349b645be
   merging c
   warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
   unresolved merge conflicts
--- a/tests/test-evolve-public-content-divergent-main.t	Thu Aug 13 17:22:19 2020 +0530
+++ b/tests/test-evolve-public-content-divergent-main.t	Thu Aug 13 18:10:51 2020 +0530
@@ -353,10 +353,10 @@
       public
   
   $ hg evolve --content-divergent --any --update
-  merge:[5] added d
-  with: [4] added d c e
+  merge:[4] added d c e
+  with: [5] added d
   base: [3] added d
-  rebasing "other" content-divergent changeset f31bcc378766 on 155349b645be
+  rebasing "divergent" content-divergent changeset f31bcc378766 on 155349b645be
   merging c
   warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
   unresolved merge conflicts
@@ -483,10 +483,10 @@
       public
   
   $ hg evolve --content-divergent --any
-  merge:[5] added d
-  with: [4] added d
+  merge:[4] added d
+  with: [5] added d
   base: [3] added d
-  rebasing "other" content-divergent changeset 9411ad1fe615 on 155349b645be
+  rebasing "divergent" content-divergent changeset 9411ad1fe615 on 155349b645be
   merging d
   warning: conflicts while merging d! (edit, then use 'hg resolve --mark')
   0 files updated, 0 files merged, 0 files removed, 1 files unresolved
@@ -577,10 +577,10 @@
       public
   
   $ hg evolve --content-divergent --any
-  merge:[5] added d
-  with: [4] added c e
+  merge:[4] added c e
+  with: [5] added d
   base: [3] added d
-  rebasing "other" content-divergent changeset 3c17c7afaf6e on 155349b645be
+  rebasing "divergent" content-divergent changeset 3c17c7afaf6e on 155349b645be
   merging c
   warning: conflicts while merging c! (edit, then use 'hg resolve --mark')
   unresolved merge conflicts