changeset 5561:d6b3f32f8261

evolve: add logic to decide local and other side before merge Before we perform merge between the two content-divergent csets, this logic decides which cset would reside at which side i.e. local or other. for e.g. in case of public content divergence where one side of divergence is public, we always keep public one to local side. (this logic of always keeping public one to local side may change in future, but for now that's what it is.)
author Sushil khanchi <sushilkhanchi97@gmail.com>
date Thu, 13 Aug 2020 17:22:19 +0530
parents b31cd9ee890a
children 5907b495901e
files hgext3rd/evolve/evolvecmd.py
diffstat 1 files changed, 19 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/hgext3rd/evolve/evolvecmd.py	Wed Aug 05 14:25:29 2020 +0530
+++ b/hgext3rd/evolve/evolvecmd.py	Thu Aug 13 17:22:19 2020 +0530
@@ -551,7 +551,10 @@
         evolvestate[b'other-divergent'] = newother
         other = repo[newother]
 
-    _mergecontentdivergents(repo, progresscb, divergent, other, base,
+    localside, otherside = divergent, other
+    if not otherside.mutable():
+        localside, otherside = other, divergent
+    _mergecontentdivergents(repo, progresscb, localside, otherside, base,
                             evolvestate)
     res, newnode = _completecontentdivergent(ui, repo, progresscb, divergent,
                                              other, base, evolvestate)
@@ -572,7 +575,7 @@
         if newnode == publicdiv.node():
             # case 2)
             pubstr = bytes(publicdiv)
-            othstr = bytes(other)
+            othstr = bytes(otherside)
             msg = _(b'content divergence resolution between %s '
                     b'(public) and %s has same content as %s, '
                     b'discarding %s\n')
@@ -668,6 +671,9 @@
         else:
             date = max(divergent.date(), other.date())
 
+    localside, otherside = divergent, other
+    if not otherside.mutable():
+        localside, otherside = other, divergent
     # We really want a new commit in order to avoid obsmarker cycles (otherwise
     # divergence resolutions done in separate repos may create markers in the
     # opposite directions). For that reason, we set ui.allowemptycommit and
@@ -677,8 +683,8 @@
         {(b'ui', b'allowemptycommit'): b'true'}, b'evolve'
     ):
         extra = {
-            b'divergence_source_local': divergent.hex(),
-            b'divergence_source_other': other.hex()
+            b'divergence_source_local': localside.hex(),
+            b'divergence_source_other': otherside.hex()
         }
         newnode = repo.commit(text=desc, user=user, date=date, extra=extra)
     new = repo[newnode]
@@ -1989,7 +1995,10 @@
                 evolvestate[b'other-divergent'] = newother
                 other = repo[newother]
             # continue the resolution by merging the content-divergent csets
-            _mergecontentdivergents(repo, progresscb, divergent, other,
+            localside, otherside = divergent, other
+            if not otherside.mutable():
+                localside, otherside = other, divergent
+            _mergecontentdivergents(repo, progresscb, localside, otherside,
                                     base, evolvestate)
 
         if evolvestate[b'relocating-other']:
@@ -2004,8 +2013,11 @@
             evolvestate[b'other-divergent'] = newother
             other = repo[newother]
             # continue the resolution by merging the content-divergent csets
-            _mergecontentdivergents(repo, progresscb, divergent,
-                                    other, base, evolvestate)
+            localside, otherside = divergent, other
+            if not otherside.mutable():
+                localside, otherside = other, divergent
+            _mergecontentdivergents(repo, progresscb, localside, otherside,
+                                    base, evolvestate)
 
         res, newnode = _completecontentdivergent(ui, repo, progresscb,
                                                  divergent, other,