evolve: fix the broken behaviour on div resolution in relocation case
authorSushil khanchi <sushilkhanchi97@gmail.com>
Fri, 22 Feb 2019 21:01:06 +0530
changeset 4408 02ece0e5865e
parent 4407 7fd0cbf6190d
child 4411 8ff5e557432a
evolve: fix the broken behaviour on div resolution in relocation case In content divergence resolution, I see that when "relocationreq" is True which means both the cset are on different parent and relocation is required. In this case when "divergent" is the one who is behind the "other" cset in DAG, we swap them. At this point one thing we missed is to update the evolvestate['divergent']. Because of this in continue case we didn't get the right value of obsmarkers creation. In this patch I added the code to update the evolvestate when we swap them. Now as we know "divergent" and "other" can be swapped in some cases, it is better to store the intial divergent separately in evolvestate which is evolvestate['orig-divergent'] and later this value is used to update the evolvestate['replacements'] which is the track of revisions which has been resolved. Changes in tests demonstrate the fixed behaviour.
hgext3rd/evolve/evolvecmd.py
tests/test-evolve-content-divergence.t
--- a/hgext3rd/evolve/evolvecmd.py	Fri Feb 22 23:49:37 2019 +0530
+++ b/hgext3rd/evolve/evolvecmd.py	Fri Feb 22 21:01:06 2019 +0530
@@ -342,6 +342,7 @@
     repo = repo.unfiltered()
     divergent = repo[divergent.rev()]
     evolvestate['divergent'] = divergent.node()
+    evolvestate['orig-divergent'] = divergent.node()
     # sometimes we will relocate a node in case of different parents and we can
     # encounter conflicts after relocation is done while solving
     # content-divergence and if the user calls `hg evolve --stop`, we need to
@@ -436,6 +437,8 @@
     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()
     else:
         msg = _("skipping %s: have a different parent than %s "
@@ -1888,7 +1891,8 @@
                                         repo[other],
                                         repo[base],
                                         evolvestate)
-        evolvestate['replacements'][divergent] = ret[1]
+        origdivergent = evolvestate['orig-divergent']
+        evolvestate['replacements'][origdivergent] = ret[1]
         # logic to continue the public content-divergent
         publicdiv = evolvestate.get('public-divergent')
         if publicdiv:
--- a/tests/test-evolve-content-divergence.t	Fri Feb 22 23:49:37 2019 +0530
+++ b/tests/test-evolve-content-divergence.t	Fri Feb 22 21:01:06 2019 +0530
@@ -693,26 +693,35 @@
 
   $ hg evolve --continue
   evolving 23:3f7a1f693080 "added z"
-  updating to "local" side of the conflict: 3f7a1f693080
+  updating to "local" side of the conflict: 53242575ffa9
   merging "other" content-divergent changeset 'cdb0643c69fc'
-  4 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  working directory is now at 10c9f94f1e99
+  merging y
+  warning: conflicts while merging y! (edit, then use 'hg resolve --mark')
+  0 files updated, 0 files merged, 0 files removed, 1 files unresolved
+  fix conflicts and see `hg help evolve.interrupted`
+  [1]
 
   $ hg diff
+  diff -r 53242575ffa9 y
+  --- a/y	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/y	Thu Jan 01 00:00:00 1970 +0000
+  @@ -1,1 +1,5 @@
+  +<<<<<<< local: 53242575ffa9 bar - test: added z
+   watbar
+  +=======
+  +foo
+  +>>>>>>> other: cdb0643c69fc - test: added z
 
   $ echo foo > y
   $ hg resolve -m
-  abort: resolve command not applicable when not merging
-  [255]
+  (no more unresolved files)
+  continue: hg evolve --continue
   $ hg evolve --continue
-  abort: no interrupted evolve to continue
-  [255]
+  working directory is now at 6fc7d9682de6
 
   $ hg glog
-  @  27:10c9f94f1e99 added z
-  |   () [default] draft
-  | *  25:53242575ffa9 added z
-  |/    () [bar] draft
+  @  27:6fc7d9682de6 added z
+  |   () [bar] draft
   o  21:7bbcf24ddecf added y
   |   () [bar] draft
   o  15:b006cf317e0e added foo to x
@@ -733,21 +742,22 @@
   # User test
   # Date 0 0
   #      Thu Jan 01 00:00:00 1970 +0000
-  # Node ID 10c9f94f1e9902d905b22019d711d31f3642f589
+  # Branch bar
+  # Node ID 6fc7d9682de6e3bee6c8b1266b756ed7d522b7e4
   # Parent  7bbcf24ddecfe97d7c2ac6fa8c07c155c8fda47b
   added z
   
-  diff -r 7bbcf24ddecf -r 10c9f94f1e99 y
+  diff -r 7bbcf24ddecf -r 6fc7d9682de6 y
   --- a/y	Thu Jan 01 00:00:00 1970 +0000
   +++ b/y	Thu Jan 01 00:00:00 1970 +0000
   @@ -1,1 +1,1 @@
   -watbar
   +foo
-  diff -r 7bbcf24ddecf -r 10c9f94f1e99 z
+  diff -r 7bbcf24ddecf -r 6fc7d9682de6 z
   --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
   +++ b/z	Thu Jan 01 00:00:00 1970 +0000
   @@ -0,0 +1,1 @@
-  +z
+  +bar
 
   $ cd ..