hgext3rd/evolve/evolvecmd.py
changeset 4444 ea336a6592cc
parent 4443 fc2214916f50
child 4453 700b8b3a5a54
--- a/hgext3rd/evolve/evolvecmd.py	Sun Mar 24 21:29:44 2019 +0530
+++ b/hgext3rd/evolve/evolvecmd.py	Sun Mar 24 21:30:12 2019 +0530
@@ -378,15 +378,18 @@
 
     # haspubdiv: to keep track if we are solving public content-divergence
     haspubdiv = False
-    if not other.mutable():
+    if not (divergent.mutable() and other.mutable()):
         haspubdiv = True
-        publicdiv = other
-        evolvestate['public-divergent'] = other.node()
-        # for simplicity, lets keep public one to local side while merging the
-        # two csets.(local side is divergent one)
-        divergent, other = other, divergent
-        evolvestate['divergent'] = divergent.node()
-        evolvestate['other-divergent'] = other.node()
+        # for simplicity, we keep public one to local side while merging
+        # (as divergent is kept at local side, pinning public -> divergent)
+        if divergent.mutable():
+            publicdiv = other
+            divergent, other = other, divergent
+            evolvestate['divergent'] = divergent.node()
+            evolvestate['other-divergent'] = other.node()
+        else:
+            publicdiv = divergent
+        evolvestate['public-divergent'] = publicdiv.node()
     # we don't handle merge content-divergent changesets yet
     if len(other.parents()) > 1:
         msg = _("skipping %s: %s changeset can't be "
@@ -472,10 +475,20 @@
         pass
     elif divp1 in gca and otherp1 not in gca:
         relocatereq = True
-        divergent, other = other, divergent
-        evolvestate['divergent'] = divergent.node()
-        evolvestate['other-divergent'] = other.node()
-        resolutionparent = divergent.p1().node()
+
+        # When public branch is behind to the mutable branch, for now we
+        # relocate mutable cset to public one's side in every case.
+        #
+        # This behaviour might be sub optimal when ancestors of mutable
+        # cset has changes its relocated descendant rely on.
+        #
+        # Otherwise, we are going to rebase the "behind" branch up to the new
+        # brancmap level.
+        if not haspubdiv:
+            divergent, other = other, divergent
+            evolvestate['divergent'] = divergent.node()
+            evolvestate['other-divergent'] = other.node()
+            resolutionparent = divergent.p1().node()
     else:
         msg = _("skipping %s: have a different parent than %s "
                 "(not handled yet)\n") % (divergent, other)