evolve: update the public divergence resolution logic to cover --continue case
authorSushil khanchi <sushilkhanchi97@gmail.com>
Mon, 21 Jan 2019 23:06:10 +0530
changeset 4384 8993fd4805d0
parent 4383 3343eac099ec
child 4385 34322fb3afca
evolve: update the public divergence resolution logic to cover --continue case To continue the interrupted evolve in case of public divergence: we will have to store the node of that public cset which was in content divergence with the other cset, so that we can perform the phase divergence resolution between that public cset and a newnode which is the result of content-divergence resolution. Added tests reflect the behaviour this patch adds.
hgext3rd/evolve/evolvecmd.py
tests/test-evolve-public-content-divergent.t
--- a/hgext3rd/evolve/evolvecmd.py	Mon Jan 21 23:06:34 2019 +0530
+++ b/hgext3rd/evolve/evolvecmd.py	Mon Jan 21 23:06:10 2019 +0530
@@ -1889,7 +1889,18 @@
                                         repo[base],
                                         evolvestate)
         evolvestate['replacements'][divergent] = ret[1]
+        # logic to continue the public content-divergent
+        publicdiv = evolvestate.get('public-divergent')
+        if publicdiv:
+            res, newnode = ret
+            if not res:
+                return (res, newnode)
+            prec = repo[publicdiv]
+            bumped = repo[newnode]
+            ret = _resolvephasedivergent(ui, repo, prec=prec, bumped=bumped,
+                                         tmpctx=bumped)
         tr.close()
+        return ret
     finally:
         tr.release()
 
--- a/tests/test-evolve-public-content-divergent.t	Mon Jan 21 23:06:34 2019 +0530
+++ b/tests/test-evolve-public-content-divergent.t	Mon Jan 21 23:06:10 2019 +0530
@@ -107,3 +107,85 @@
      +a
   
   $ hg evolve -l
+
+  $ cd ..
+
+Testing the case when both divergent cset has same parent and has conflict in merging:
+------------------------------------------------------------------------------
+
+Prepare the repository:
+
+  $ hg init pubdiv1
+  $ cd pubdiv1
+  $ for ch in a b; do
+  >   echo $ch > $ch;
+  >   hg ci -Aqm "added "$ch;
+  > done;
+  $ hg glog
+  @  1:5f6d8a4bf34a added b
+  |   draft
+  |
+  o  0:9092f1db7931 added a
+      draft
+  
+
+Make an amend and change phase to public:
+
+  $ echo "I am foo" > b
+  $ hg amend
+  $ hg phase --public
+
+Amend again to create a cset divergent to public one:
+
+  $ hg up 1 --hidden -q
+  updated to hidden changeset 5f6d8a4bf34a
+  (hidden revision '5f6d8a4bf34a' was rewritten as: 580f2d01e52c)
+  working directory parent is obsolete! (5f6d8a4bf34a)
+
+  $ echo "I am bar" > b
+  $ hg ci --amend -m "updated b"
+  1 new content-divergent changesets
+
+  $ hg glog
+  @  3:0e805383168e updated b
+  |   draft content-divergent
+  |
+  | o  2:580f2d01e52c added b
+  |/    public
+  |
+  o  0:9092f1db7931 added a
+      public
+  
+
+Lets resolve the divergence:
+
+  $ hg evolve --content-divergent
+  merge:[3] updated b
+  with: [2] added b
+  base: [1] added b
+  merging "other" content-divergent changeset '580f2d01e52c'
+  merging b
+  warning: conflicts while merging b! (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]
+
+  $ echo "I am foobar" > b
+  $ hg resolve -m --tool union
+  (no more unresolved files)
+  continue: hg evolve --continue
+  $ hg evolve --continue
+  computing new diff
+  committed as 1a739394e9d4
+  working directory is now at 1a739394e9d4
+
+  $ hg glog
+  @  5:1a739394e9d4 phase-divergent update to 580f2d01e52c:
+  |   draft
+  |
+  o  2:580f2d01e52c added b
+  |   public
+  |
+  o  0:9092f1db7931 added a
+      public
+