evolve: add logic to handle a particular case in divergence resolution
authorSushil khanchi <sushilkhanchi97@gmail.com>
Sat, 23 Mar 2019 02:10:31 +0530
changeset 4442 819bad275701
parent 4441 f606eab8dff8
child 4443 fc2214916f50
evolve: add logic to handle a particular case in divergence resolution Case is: In content divergence, to check if the two csets are on different parent or same parent what we do is find gca of the two csets and then compare it with the singlesuccessors of two csets's parents. Now, if gca is same as singlesuccessors of both the csets then we conclude that both are on the same parent which is not totally correct as it is possible that both the parents of two csets are obsolete with a single successor. This patch adds the logic to cover the above metioned case correctly, deciding the part when we need to relocate a cset to other side while resolving the stack of divergent csets. Changes in test file demonstrate that before this patch we were not doing it right because it should have relocated every node to other side instead of just relocating the first one from the stack.
hgext3rd/evolve/evolvecmd.py
tests/test-evolve-content-divergence.t
--- a/hgext3rd/evolve/evolvecmd.py	Fri Mar 22 00:16:44 2019 +0530
+++ b/hgext3rd/evolve/evolvecmd.py	Sat Mar 23 02:10:31 2019 +0530
@@ -416,7 +416,17 @@
     resolutionparent = repo[divp1].node()
 
     gca = repo.revs("ancestor(%d, %d)" % (otherp1, divp1))
-
+    # divonly: non-obsolete csets which are topological ancestor of "divergent"
+    # but not "other"
+    divonly = repo.revs("only(%d, %d) - obsolete()" % (divergent.rev(),
+                                                       other.rev()))
+    # otheronly: non-obsolete csets which are topological ancestor of "other"
+    # but not "div"
+    otheronly = repo.revs("only(%d, %d) - obsolete()" % (other.rev(),
+                                                         divergent.rev()))
+    # make it exclusive set
+    divonly = set(divonly) - {divergent.rev()}
+    otheronly = set(otheronly) - {other.rev()}
     # is relocation of one of the changeset required
     relocatereq = False
 
@@ -434,8 +444,27 @@
     # then solve the content-divergence the way we solve 1)
     # for 3) and 4), we still have to decide
     if otherp1 in gca and divp1 in gca:
-        # both are on the same parents
-        pass
+        if otherp1 == other.p1().rev() and divp1 == divergent.p1().rev():
+            # both are on the same parents
+            pass
+        else:
+            # both are not on the same parent but have same parents's succs.
+            if otheronly and divonly:
+                # case: we have visible csets on both side diverging from
+                # tca of "divergent" and "other". We still need to decide what
+                # to do in this case
+                pass
+            if otheronly:
+                relocatereq = True
+                divergent, other = other, divergent
+                evolvestate['divergent'] = divergent.node()
+                evolvestate['other-divergent'] = other.node()
+                resolutionparent = repo[otherp1].node()
+            elif divonly:
+                relocatereq = True
+            else:
+                # no extra cset on either side; so not considering relocation
+                pass
     elif otherp1 in gca and divp1 not in gca:
         relocatereq = True
         pass
--- a/tests/test-evolve-content-divergence.t	Fri Mar 22 00:16:44 2019 +0530
+++ b/tests/test-evolve-content-divergence.t	Sat Mar 23 02:10:31 2019 +0530
@@ -1075,32 +1075,35 @@
   merging "other" content-divergent changeset '186bdc2cdfa2'
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   6 new orphan changesets
-  merge:[6] added b
-  with: [11] added b
+  merge:[11] added b
+  with: [6] added b
   base: [2] added b
-  updating to "local" side of the conflict: d5f148423c16
-  merging "other" content-divergent changeset '6eb54b5af3fb'
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  merge:[7] added c
-  with: [12] added c
+  rebasing "other" content-divergent changeset d5f148423c16 on c04ff147ef79
+  updating to "local" side of the conflict: 6eb54b5af3fb
+  merging "other" content-divergent changeset '8542f15656e7'
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  merge:[12] added c
+  with: [7] added c
   base: [3] added c
-  updating to "local" side of the conflict: 3ce4be6d8e5e
-  merging "other" content-divergent changeset '8ed612937375'
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  merge:[8] added d
-  with: [13] added d
+  rebasing "other" content-divergent changeset 3ce4be6d8e5e on 6eb54b5af3fb
+  updating to "local" side of the conflict: 8ed612937375
+  merging "other" content-divergent changeset 'a690ce53104a'
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  merge:[13] added d
+  with: [8] added d
   base: [4] added d
-  updating to "local" side of the conflict: c72d2885eb51
-  merging "other" content-divergent changeset 'd45f050514c2'
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  working directory is now at c8f73c376a6e
+  rebasing "other" content-divergent changeset c72d2885eb51 on 8ed612937375
+  updating to "local" side of the conflict: d45f050514c2
+  merging "other" content-divergent changeset '1d1772990a3b'
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  working directory is now at 5f7a38bdb75c
 
   $ hg glog
-  @  18:c8f73c376a6e added d
+  @  21:5f7a38bdb75c added d
   |   () [default] draft
-  o  17:77126af93a25 added c
+  o  19:9865d598f0e0 added c
   |   () [default] draft
-  o  16:4e29776e83a5 added b
+  o  17:ac70b8c8eb63 added b
   |   () [default] draft
   o  15:74fbf3e6a0b6 watbar to a
   |   () [default] draft