view tests/test-evolve-phase-divergence.t @ 4309:ef49e48da074 mercurial-4.3

test-compat: merge mercurial-4.4 into mercurial-4.3
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 21 Dec 2018 20:14:26 +0100
parents 3d917da5bd95
children
line wrap: on
line source

** Test for handling of phase divergent changesets by `hg evolve` **
====================================================================

  $ cat >> $HGRCPATH <<EOF
  > [alias]
  > glog = log -GT "{rev}:{node|short} {desc|firstline}\n ({bookmarks}) {phase}"
  > [extensions]
  > rebase =
  > EOF

Setting up a public repo
------------------------

  $ hg init public
  $ cd public
  $ echo a > a
  $ mkcommit() {
  >    echo "$1" > "$1"
  >    hg add "$1"
  >    hg ci -m "add $1"
  > }
  $ hg commit -A -m init
  adding a
  $ cd ..

  $ evolvepath=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/

Setting up a private non-publishing repo
----------------------------------------

  $ hg clone -U public private
  $ cd private
  $ cat >> .hg/hgrc <<EOF
  > [extensions]
  > evolve = $evolvepath
  > [ui]
  > logtemplate = {rev}:{node|short}@{branch}({phase}) {desc|firstline}\n
  > [phases]
  > publish = false
  > EOF
  $ cd ..

Setting up couple of more instances of private repo
---------------------------------------------------

  $ cp -a private alice
  $ cp -a private bob

Creating a phase-divergence changeset
-------------------------------------

Alice creating a draft changeset and pushing to main private repo

  $ cd alice
  $ hg update
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  $ echo a >> a
  $ hg commit -u alice -m 'modify a'
  $ hg push ../private
  pushing to ../private
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files
  $ hg glog
  @  1:4d1169d82e47 modify a
  |   () draft
  o  0:d3873e73d99e init
      () public

Bob pulling from private repo and pushing to the main public repo making the
changeset public

  $ cd ../bob
  $ hg pull ../private
  pulling from ../private
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files
  (run 'hg update' to get a working copy)

  $ hg glog
  o  1:4d1169d82e47 modify a
  |   () draft
  o  0:d3873e73d99e init
      () public

  $ hg push ../public
  pushing to ../public
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files

  $ hg glog
  o  1:4d1169d82e47 modify a
  |   () public
  o  0:d3873e73d99e init
      () public

*But* Alice decided to amend the changeset she had and then pulling from public
repo creating phase-divergent changeset locally

  $ cd ../alice
  $ hg amend -m 'tweak a'

XXX: pull should tell us how to see what is the new phase-divergent changeset
  $ hg pull ../public
  pulling from ../public
  searching for changes
  no changes found
  1 new bumped changesets

  $ hg glog
  @  2:98bb3a6cfe1a tweak a
  |   () draft
  | o  1:4d1169d82e47 modify a
  |/    () public
  o  0:d3873e73d99e init
      () public

Using evolve --list to list phase-divergent changesets
------------------------------------------------------

  $ hg evolve --list
  98bb3a6cfe1a: tweak a
    bumped: 4d1169d82e47 (immutable precursor)
  


XXX-Pulkit: Trying to see instability on public changeset

XXX-Pulkit: this is not helpful

XXX-Marmoute: public changeset "instable themself"
XXX-Marmoute: I'm not sure if we store this information and it is useful to show it.
XXX-Marmoute: We should maybe point the user toward `hg obslog` instead`
  $ hg evolve -r 4d1169d8 --list
  4d1169d82e47: modify a
  

Understanding phasedivergence using obslog
------------------------------------------

XXX: There must be mention of phase-divergence here
  $ hg obslog -r . --all
  @  98bb3a6cfe1a (2) tweak a
  |
  o  4d1169d82e47 (1) modify a
       rewritten(description) as 98bb3a6cfe1a by test (Thu Jan 01 00:00:00 1970 +0000)
  
Solving the phase divergence using evolve command
--------------------------------------------------

(We do not solve evolution other than orphan by default because it turned out
it was too confusing for users. We used to behave this way, but having multiple
possible outcome to evolve end up scaring people)

  $ hg evolve
  nothing to evolve on current working copy parent
  (do you want to use --phase-divergent)
  [2]

testing the --confirm option
  $ hg evolve --phase-divergent --confirm <<EOF
  > n
  > EOF
  recreate:[2] tweak a
  atop:[1] modify a
  perform evolve? [Ny] n
  abort: evolve aborted by user
  [255]

testing the --dry-run option

  $ hg evolve --phase-divergent --dry-run
  recreate:[2] tweak a
  atop:[1] modify a
  hg rebase --rev 98bb3a6cfe1a --dest d3873e73d99e;
  hg update 4d1169d82e47;
  hg revert --all --rev 98bb3a6cfe1a;
  hg commit --msg "bumped update to 98bb3a6cfe1a"

XXX: evolve should have mentioned that draft commit is just obsoleted in favour
of public one. From the message it looks like a new commit is created.

  $ hg evolve --phase-divergent
  recreate:[2] tweak a
  atop:[1] modify a
  computing new diff
  committed as 4d1169d82e47
  working directory is now at 4d1169d82e47

  $ hg glog
  @  1:4d1169d82e47 modify a
  |   () public
  o  0:d3873e73d99e init
      () public

Syncying every repo with the new state
--------------------------------------

  $ hg push ../public
  pushing to ../public
  searching for changes
  no changes found
  2 new obsolescence markers
  [1]
  $ hg push ../private
  pushing to ../private
  searching for changes
  no changes found
  2 new obsolescence markers
  [1]
  $ hg push ../bob
  pushing to ../bob
  searching for changes
  no changes found
  2 new obsolescence markers
  [1]

Creating more phase-divergence where a new resolution commit will be formed and
also testing bookmark movement
--------------------------------------------------------------------------------

Alice created a commit and push to private non-publishing repo

  $ echo foo > foo
  $ hg add foo
  $ hg ci -m "added foo to foo"
  $ hg glog
  @  3:aa071e5554e3 added foo to foo
  |   () draft
  o  1:4d1169d82e47 modify a
  |   () public
  o  0:d3873e73d99e init
      () public

  $ hg push ../private
  pushing to ../private
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files

Bob pulled from the private repo and pushed that to publishing repo

  $ cd ../bob
  $ hg pull ../private
  pulling from ../private
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files
  (run 'hg update' to get a working copy)

  $ hg push ../public
  pushing to ../public
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files

Alice amended that changeset and then pulled from publishing repo creating
phase-divergence

  $ cd ../alice
  $ echo bar >> foo
  $ hg amend -m "added bar to foo"
  $ hg bookmark bm

  $ hg pull ../public
  pulling from ../public
  searching for changes
  no changes found
  1 new bumped changesets

  $ hg glog
  @  5:d47f2b37ed82 added bar to foo
  |   (bm) draft
  | o  3:aa071e5554e3 added foo to foo
  |/    () public
  o  1:4d1169d82e47 modify a
  |   () public
  o  0:d3873e73d99e init
      () public

Resolving the new phase-divergence changeset using `hg evolve`
--------------------------------------------------------------

XXX: this should have popped up for a new commit message of the changeset or an
option should be there

XXX: we should document what should user expect where running this, writing this
test I have to go through code base to understand what will be the behavior

  $ hg evolve --phase-divergent
  recreate:[5] added bar to foo
  atop:[3] added foo to foo
  computing new diff
  committed as bdf645eb43bb
  working directory is now at bdf645eb43bb

  $ hg exp
  # HG changeset patch
  # User test
  # Date 0 0
  #      Thu Jan 01 00:00:00 1970 +0000
  # Node ID bdf645eb43bb0c9f180cd17d109bb359ce1571b2
  # Parent  aa071e5554e36080a36cfd24accd5a71e3320f1e
  bumped update to aa071e5554e3:
  
  added bar to foo
  
  diff -r aa071e5554e3 -r bdf645eb43bb foo
  --- a/foo	Thu Jan 01 00:00:00 1970 +0000
  +++ b/foo	Thu Jan 01 00:00:00 1970 +0000
  @@ -1,1 +1,2 @@
   foo
  +bar

XXX: the commit message is not best one, we should give option to user to modify
the commit message

  $ hg glog
  @  6:bdf645eb43bb bumped update to aa071e5554e3:
  |   (bm) draft
  o  3:aa071e5554e3 added foo to foo
  |   () public
  o  1:4d1169d82e47 modify a
  |   () public
  o  0:d3873e73d99e init
      () public

  $ hg obslog -r . --all
  @  bdf645eb43bb (6) bumped update to aa071e5554e3:
  |
  x  d47f2b37ed82 (5) added bar to foo
  |    rewritten(description, parent, content) as bdf645eb43bb by test (Thu Jan 01 00:00:00 1970 +0000)
  |
  o  aa071e5554e3 (3) added foo to foo
       rewritten(description, content) as d47f2b37ed82 by test (Thu Jan 01 00:00:00 1970 +0000)
  

Syncing all other repositories
------------------------------

These pushed should not be turned to quiet mode as the output is very helpful to
make sure everything is working fine

  $ hg push ../bob
  pushing to ../bob
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files
  3 new obsolescence markers

  $ hg push ../private
  pushing to ../private
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files
  3 new obsolescence markers

  $ hg push ../public
  pushing to ../public
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files
  3 new obsolescence markers

Creating a phasedivergence changeset where the divergent changeset changed in a
way that we rebase that on old public changeset, there will be conflicts, but
the `hg evolve` command handles it very well and uses `hg revert` logic to
prevent any conflicts
-------------------------------------------------------------------------------

Alice creates one more changeset and pushes to private repo

  $ echo bar > bar
  $ hg ci -Aqm "added bar to bar"
  $ hg push ../private
  pushing to ../private
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files

Bob pulls from private and pushes to public repo
  $ cd ../bob

  $ hg pull ../private
  pulling from ../private
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files
  (run 'hg update' to get a working copy)

  $ hg push ../public
  pushing to ../public
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files

Alice amends the changeset and then pull from public creating phase-divergence

  $ cd ../alice
  $ echo foo > bar
  $ hg amend -m "foo to bar"

  $ hg pull ../public
  pulling from ../public
  searching for changes
  no changes found
  1 new bumped changesets

  $ hg glog
  @  9:d529f41744b3 foo to bar
  |   (bm) draft
  | o  7:6176b60d16d2 added bar to bar
  |/    () public
  o  6:bdf645eb43bb bumped update to aa071e5554e3:
  |   () public
  o  3:aa071e5554e3 added foo to foo
  |   () public
  o  1:4d1169d82e47 modify a
  |   () public
  o  0:d3873e73d99e init
      () public

Resolving the new phase-divergence changeset using `hg evolve`
---------------------------------------------------------------

  $ hg evolve --phase-divergent
  recreate:[9] foo to bar
  atop:[7] added bar to bar
  computing new diff
  committed as 73f67b6cf2c4
  working directory is now at 73f67b6cf2c4

  $ hg exp
  # HG changeset patch
  # User test
  # Date 0 0
  #      Thu Jan 01 00:00:00 1970 +0000
  # Node ID 73f67b6cf2c428075c41d377f8651912e0d8cae2
  # Parent  6176b60d16d20d69c77bb27c2a1b79caec671612
  bumped update to 6176b60d16d2:
  
  foo to bar
  
  diff -r 6176b60d16d2 -r 73f67b6cf2c4 bar
  --- a/bar	Thu Jan 01 00:00:00 1970 +0000
  +++ b/bar	Thu Jan 01 00:00:00 1970 +0000
  @@ -1,1 +1,1 @@
  -bar
  +foo

  $ hg glog
  @  10:73f67b6cf2c4 bumped update to 6176b60d16d2:
  |   (bm) draft
  o  7:6176b60d16d2 added bar to bar
  |   () public
  o  6:bdf645eb43bb bumped update to aa071e5554e3:
  |   () public
  o  3:aa071e5554e3 added foo to foo
  |   () public
  o  1:4d1169d82e47 modify a
  |   () public
  o  0:d3873e73d99e init
      () public

Syncing all the repositories
----------------------------

  $ hg push ../private
  pushing to ../private
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files
  3 new obsolescence markers
  $ hg push ../public
  pushing to ../public
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files
  3 new obsolescence markers

Creating phase-divergence with divergent changeset and precursor having
different parents
-----------------------------------------------------------------------

Alice creates a changeset and pushes to private repo

  $ echo x > x
  $ hg ci -Am "added x to x"
  adding x

  $ hg push ../private
  pushing to ../private
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files

Bob does what he always does, pull from private and push to public, he is acting
as a CI service

  $ cd ../bob
  $ hg pull ../private
  pulling from ../private
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 2 changesets with 2 changes to 2 files
  3 new obsolescence markers
  (run 'hg update' to get a working copy)
  $ hg push ../public
  pushing to ../public
  searching for changes
  adding changesets
  adding manifests
  adding file changes
  added 1 changesets with 1 changes to 1 files

Alice like always dont care about Bob existence and rebases her changeset and
then pull from public repo creating phase divergence

  $ cd ../alice
  $ hg rebase -r . -d .^^^
  rebasing 11:ae81846887bc "added x to x" (tip bm)

  $ hg pull ../public
  pulling from ../public
  searching for changes
  no changes found
  1 new bumped changesets

  $ hg obslog -r .
  @  5cc37876a882 (12) added x to x
  |
  o  ae81846887bc (11) added x to x
       rewritten(parent) as 5cc37876a882 by test (Thu Jan 01 00:00:00 1970 +0000)
  
  $ hg glog -r .^::
  hg: parse error at 4: not a prefix: end
  [255]

Using `hg evolve` to resolve phase-divergence
---------------------------------------------

  $ hg evolve --phase-divergent
  recreate:[12] added x to x
  atop:[11] added x to x
  rebasing to destination parent: 73f67b6cf2c4
  (leaving bookmark bm)
  computing new diff
  committed as ae81846887bc
  working directory is now at ae81846887bc

XXX: we should move bookmark here
  $ hg glog
  @  11:ae81846887bc added x to x
  |   (bm) public
  o  10:73f67b6cf2c4 bumped update to 6176b60d16d2:
  |   () public
  o  7:6176b60d16d2 added bar to bar
  |   () public
  o  6:bdf645eb43bb bumped update to aa071e5554e3:
  |   () public
  o  3:aa071e5554e3 added foo to foo
  |   () public
  o  1:4d1169d82e47 modify a
  |   () public
  o  0:d3873e73d99e init
      () public

  $ hg obslog -r ae81846887bc --all --hidden
  x  14c7c60e138f (13) added x to x
  |    pruned by test (Thu Jan 01 00:00:00 1970 +0000)
  |
  x  5cc37876a882 (12) added x to x
  |    rewritten(parent) as 14c7c60e138f by test (Thu Jan 01 00:00:00 1970 +0000)
  |
  @  ae81846887bc (11) added x to x
       rewritten(parent) as 5cc37876a882 by test (Thu Jan 01 00:00:00 1970 +0000)
  

  $ hg exp
  # HG changeset patch
  # User test
  # Date 0 0
  #      Thu Jan 01 00:00:00 1970 +0000
  # Node ID ae81846887bc53e9ba17ea2172950677d1ba3a1d
  # Parent  73f67b6cf2c428075c41d377f8651912e0d8cae2
  added x to x
  
  diff -r 73f67b6cf2c4 -r ae81846887bc x
  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
  +++ b/x	Thu Jan 01 00:00:00 1970 +0000
  @@ -0,0 +1,1 @@
  +x

Creating divergence with parent and content change both but not resulting in
conflicts
-----------------------------------------------------------------------------

Alice is tired of pushing and pulling and will create phase-divergence locally

  $ hg glog
  @  11:ae81846887bc added x to x
  |   (bm) public
  o  10:73f67b6cf2c4 bumped update to 6176b60d16d2:
  |   () public
  o  7:6176b60d16d2 added bar to bar
  |   () public
  o  6:bdf645eb43bb bumped update to aa071e5554e3:
  |   () public
  o  3:aa071e5554e3 added foo to foo
  |   () public
  o  1:4d1169d82e47 modify a
  |   () public
  o  0:d3873e73d99e init
      () public

  $ echo y > y
  $ echo foobar >> foo
  $ hg add y
  $ hg ci -m "y to y and foobar to foo"
  $ hg rebase -r . -d .^^^
  rebasing 14:43dd61d1a393 "y to y and foobar to foo" (tip)

  $ echo foo > y
  $ hg amend

Alice making the old changeset public to have content-divergence

  $ hg phase -r 43dd61d1a393 --public --hidden
  1 new bumped changesets
  $ hg glog
  @  17:694790041d7d y to y and foobar to foo
  |   () draft
  | o  14:43dd61d1a393 y to y and foobar to foo
  | |   () public
  | o  11:ae81846887bc added x to x
  | |   (bm) public
  | o  10:73f67b6cf2c4 bumped update to 6176b60d16d2:
  |/    () public
  o  7:6176b60d16d2 added bar to bar
  |   () public
  o  6:bdf645eb43bb bumped update to aa071e5554e3:
  |   () public
  o  3:aa071e5554e3 added foo to foo
  |   () public
  o  1:4d1169d82e47 modify a
  |   () public
  o  0:d3873e73d99e init
      () public

  $ hg obslog -r .
  @  694790041d7d (17) y to y and foobar to foo
  |
  x  9195657992dd (15) y to y and foobar to foo
  |    rewritten(content) as 694790041d7d by test (Thu Jan 01 00:00:00 1970 +0000)
  |
  o  43dd61d1a393 (14) y to y and foobar to foo
       rewritten(parent) as 9195657992dd by test (Thu Jan 01 00:00:00 1970 +0000)
  
Resolving divergence using `hg evolve`
-------------------------------------

  $ hg evolve --phase-divergent
  recreate:[17] y to y and foobar to foo
  atop:[14] y to y and foobar to foo
  rebasing to destination parent: ae81846887bc
  computing new diff
  committed as 8da44ebfc416
  working directory is now at 8da44ebfc416

  $ hg exp
  # HG changeset patch
  # User test
  # Date 0 0
  #      Thu Jan 01 00:00:00 1970 +0000
  # Node ID 8da44ebfc416e3a6fc52c29f3a78e1d87c0d492e
  # Parent  43dd61d1a393577a202514a924148969b8f74db8
  bumped update to 43dd61d1a393:
  
  y to y and foobar to foo
  
  diff -r 43dd61d1a393 -r 8da44ebfc416 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 @@
  -y
  +foo

  $ hg glog
  @  19:8da44ebfc416 bumped update to 43dd61d1a393:
  |   () draft
  o  14:43dd61d1a393 y to y and foobar to foo
  |   () public
  o  11:ae81846887bc added x to x
  |   (bm) public
  o  10:73f67b6cf2c4 bumped update to 6176b60d16d2:
  |   () public
  o  7:6176b60d16d2 added bar to bar
  |   () public
  o  6:bdf645eb43bb bumped update to aa071e5554e3:
  |   () public
  o  3:aa071e5554e3 added foo to foo
  |   () public
  o  1:4d1169d82e47 modify a
  |   () public
  o  0:d3873e73d99e init
      () public

Creating divergence with parent and content change both which results in
conflicts while rebasing on parent
-----------------------------------------------------------------------------

  $ echo l > l
  $ hg ci -Aqm "added l to l"
  $ hg rebase -r . -d .^^^^
  rebasing 20:515507bedb51 "added l to l" (tip)
  $ echo kl > l
  $ echo foo > x
  $ hg add x
  $ hg amend

  $ hg obslog -r .
  @  e3c208c26c0c (23) added l to l
  |
  x  c114000165ef (21) added l to l
  |    rewritten(content) as e3c208c26c0c by test (Thu Jan 01 00:00:00 1970 +0000)
  |
  x  515507bedb51 (20) added l to l
       rewritten(parent) as c114000165ef by test (Thu Jan 01 00:00:00 1970 +0000)
  

  $ hg phase -r 515507bedb51 --public --hidden
  1 new bumped changesets

Resolution using `hg evolve --phase-divergent`
----------------------------------------------

  $ hg evolve --phase-divergent
  recreate:[23] added l to l
  atop:[20] added l to l
  rebasing to destination parent: 8da44ebfc416
  merging x
  warning: conflicts while merging x! (edit, then use 'hg resolve --mark')
  fix conflicts and see `hg help evolve.interrupted`
  [1]

  $ hg diff
  diff -r 8da44ebfc416 l
  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
  +++ b/l	Thu Jan 01 00:00:00 1970 +0000
  @@ -0,0 +1,1 @@
  +kl
  diff -r 8da44ebfc416 x
  --- a/x	Thu Jan 01 00:00:00 1970 +0000
  +++ b/x	Thu Jan 01 00:00:00 1970 +0000
  @@ -1,1 +1,5 @@
  +<<<<<<< destination: 8da44ebfc416 - test: bumped update to 43dd61d1a393:
   x
  +=======
  +foo
  +>>>>>>> evolving:    e3c208c26c0c - test: added l to l

  $ echo foo > x

  $ hg resolve -m
  (no more unresolved files)
  continue: hg evolve --continue

  $ hg evolve --continue
  evolving 23:e3c208c26c0c "added l to l"
  computing new diff
  committed as 01e0d829c156
  working directory is now at 01e0d829c156

  $ hg glog
  @  25:01e0d829c156 bumped update to 515507bedb51:
  |   () draft
  o  20:515507bedb51 added l to l
  |   () public
  o  19:8da44ebfc416 bumped update to 43dd61d1a393:
  |   () public
  o  14:43dd61d1a393 y to y and foobar to foo
  |   () public
  o  11:ae81846887bc added x to x
  |   (bm) public
  o  10:73f67b6cf2c4 bumped update to 6176b60d16d2:
  |   () public
  o  7:6176b60d16d2 added bar to bar
  |   () public
  o  6:bdf645eb43bb bumped update to aa071e5554e3:
  |   () public
  o  3:aa071e5554e3 added foo to foo
  |   () public
  o  1:4d1169d82e47 modify a
  |   () public
  o  0:d3873e73d99e init
      () public

  $ hg exp
  # HG changeset patch
  # User test
  # Date 0 0
  #      Thu Jan 01 00:00:00 1970 +0000
  # Node ID 01e0d829c1560d8297062062dff671e272439e38
  # Parent  515507bedb512ac15258c2ab44809645139055ef
  bumped update to 515507bedb51:
  
  added l to l
  
  diff -r 515507bedb51 -r 01e0d829c156 l
  --- a/l	Thu Jan 01 00:00:00 1970 +0000
  +++ b/l	Thu Jan 01 00:00:00 1970 +0000
  @@ -1,1 +1,1 @@
  -l
  +kl
  diff -r 515507bedb51 -r 01e0d829c156 x
  --- a/x	Thu Jan 01 00:00:00 1970 +0000
  +++ b/x	Thu Jan 01 00:00:00 1970 +0000
  @@ -1,1 +1,1 @@
  -x
  +foo

Creating phase divergence when couple of changesets are folded into one
------------------------------------------------------------------------

  $ hg glog -r .
  @  25:01e0d829c156 bumped update to 515507bedb51:
  |   () draft
  ~
  $ echo f > f
  $ hg ci -Aqm "added f"
  $ echo g > g
  $ hg ci -Aqm "added g"

  $ hg fold -r . -r .^ --exact
  2 changesets folded
  0 files updated, 0 files merged, 0 files removed, 0 files unresolved

  $ hg evolve --list

  $ hg phase -r e86ee52bfd76 --public --hidden
  1 new bumped changesets

  $ hg glog -r 515507bedb51::
  @  28:d83c51bdc098 added g
  |   () draft
  | o  27:e86ee52bfd76 added g
  | |   () public
  | o  26:d3c143cd906e added f
  |/    () public
  o  25:01e0d829c156 bumped update to 515507bedb51:
  |   () public
  o  20:515507bedb51 added l to l
  |   () public
  ~

  $ hg evolve --list
  d83c51bdc098: added g
    bumped: d3c143cd906e (immutable precursor)
    bumped: e86ee52bfd76 (immutable precursor)
  
Resolving phase divergence using `hg evolve`

  $ hg evolve --phase-divergent --all
  recreate:[28] added g
  atop:[27] added g
  rebasing to destination parent: d3c143cd906e
  computing new diff
  committed as e86ee52bfd76
  working directory is now at e86ee52bfd76

  $ hg glog -r 515507bedb51::
  @  27:e86ee52bfd76 added g
  |   () public
  o  26:d3c143cd906e added f
  |   () public
  o  25:01e0d829c156 bumped update to 515507bedb51:
  |   () public
  o  20:515507bedb51 added l to l
  |   () public
  ~

When the public changesets is splitted causing phase-divergence
---------------------------------------------------------------

  $ echo m > m
  $ echo n > n
  $ hg ci -Aqm "added m and n"

  $ hg glog -r d3c143cd906e::
  @  30:bbb1ce6e7cb5 added m and n
  |   () draft
  o  27:e86ee52bfd76 added g
  |   () public
  o  26:d3c143cd906e added f
  |   () public
  ~

  $ hg prev
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
  [27] added g
  $ echo m > m
  $ hg ci -Aqm "added m"
  $ echo n > n
  $ hg ci -Aqm "added n"

  $ hg glog -r e86ee52bfd76::
  @  32:e1e84fb7bd8c added n
  |   () draft
  o  31:38f8157363bc added m
  |   () draft
  | o  30:bbb1ce6e7cb5 added m and n
  |/    () draft
  o  27:e86ee52bfd76 added g
  |   () public
  ~

  $ hg prune -r bbb1ce6e7cb5 --succ 38f8157363bc --succ e1e84fb7bd8c --split
  1 changesets pruned

  $ hg phase -r bbb1ce6e7cb5 --hidden --public
  2 new bumped changesets

  $ hg glog -r e86ee52bfd76::
  @  32:e1e84fb7bd8c added n
  |   () draft
  o  31:38f8157363bc added m
  |   () draft
  | o  30:bbb1ce6e7cb5 added m and n
  |/    () public
  o  27:e86ee52bfd76 added g
  |   () public
  ~

  $ hg evolve --all --phase-divergent
  recreate:[31] added m
  atop:[30] added m and n
  computing new diff
  committed as 26c0e0acbf58
  recreate:[32] added n
  atop:[30] added m and n
  rebasing to destination parent: e86ee52bfd76
  computing new diff
  committed as 167994483a30
  working directory is now at 167994483a30

XXX: this is messy, we should solve things in better way
  $ hg glog -r e86ee52bfd76:: --hidden
  @  35:167994483a30 bumped update to bbb1ce6e7cb5:
  |   () draft
  | x  34:ebca40be1c77 added n
  | |   () draft
  +---o  33:26c0e0acbf58 bumped update to bbb1ce6e7cb5:
  | |     () draft
  | | x  32:e1e84fb7bd8c added n
  | | |   () draft
  | | x  31:38f8157363bc added m
  | |/    () draft
  o |  30:bbb1ce6e7cb5 added m and n
  |/    () public
  o  27:e86ee52bfd76 added g
  |   () public
  ~

XXX: not sure this is the correct
  $ hg exp 167994483a30
  # HG changeset patch
  # User test
  # Date 0 0
  #      Thu Jan 01 00:00:00 1970 +0000
  # Node ID 167994483a3052f6ea76aa4ba54bd0d6ecd03506
  # Parent  bbb1ce6e7cb56a4d0ddd9b602492c1e79f2beaf5
  bumped update to bbb1ce6e7cb5:
  
  added n
  
  diff -r bbb1ce6e7cb5 -r 167994483a30 m
  --- a/m	Thu Jan 01 00:00:00 1970 +0000
  +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
  @@ -1,1 +0,0 @@
  -m

XXX: not sure this is correct
  $ hg exp 26c0e0acbf58 --hidden
  # HG changeset patch
  # User test
  # Date 0 0
  #      Thu Jan 01 00:00:00 1970 +0000
  # Node ID 26c0e0acbf58e4bd2a2414e43b7d2d8aefdbba60
  # Parent  bbb1ce6e7cb56a4d0ddd9b602492c1e79f2beaf5
  bumped update to bbb1ce6e7cb5:
  
  added m
  
  diff -r bbb1ce6e7cb5 -r 26c0e0acbf58 n
  --- a/n	Thu Jan 01 00:00:00 1970 +0000
  +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
  @@ -1,1 +0,0 @@
  -n

When the public changeset is splitted across various branches
--------------------------------------------------------------

  $ echo p > p
  $ echo q > q
  $ hg ci -Aqm "added p and q"

  $ hg prev
  0 files updated, 0 files merged, 2 files removed, 0 files unresolved
  [35] bumped update to bbb1ce6e7cb5:
  $ echo p > p
  $ hg ci -Aqm "added p"
  $ hg prev
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  [35] bumped update to bbb1ce6e7cb5:
  $ echo q > q
  $ hg ci -Aqm "added q"

  $ hg glog -r 167994483a30::
  @  38:25009377929c added q
  |   () draft
  | o  37:a27f3cc92c8f added p
  |/    () draft
  | o  36:f695c2c8812d added p and q
  |/    () draft
  o  35:167994483a30 bumped update to bbb1ce6e7cb5:
  |   () draft
  ~

  $ hg prune -r f695c2c8812d --succ a27f3cc92c8f --succ 25009377929c --split
  1 changesets pruned

  $ hg phase -r f695c2c8812d --public --hidden
  2 new bumped changesets

  $ hg glog -r 167994483a30::
  @  38:25009377929c added q
  |   () draft
  | o  37:a27f3cc92c8f added p
  |/    () draft
  | o  36:f695c2c8812d added p and q
  |/    () public
  o  35:167994483a30 bumped update to bbb1ce6e7cb5:
  |   () public
  ~

  $ hg evolve --list
  a27f3cc92c8f: added p
    bumped: f695c2c8812d (immutable precursor)
  
  25009377929c: added q
    bumped: f695c2c8812d (immutable precursor)
  
  $ hg evolve --all --phase-divergent
  recreate:[37] added p
  atop:[36] added p and q
  computing new diff
  committed as abd19926ab01
  recreate:[38] added q
  atop:[36] added p and q
  computing new diff
  committed as 12c31db4edf9
  working directory is now at 12c31db4edf9

  $ hg glog -r 167994483a30:: --hidden
  @  40:12c31db4edf9 bumped update to f695c2c8812d:
  |   () draft
  | o  39:abd19926ab01 bumped update to f695c2c8812d:
  |/    () draft
  | x  38:25009377929c added q
  | |   () draft
  | | x  37:a27f3cc92c8f added p
  | |/    () draft
  o |  36:f695c2c8812d added p and q
  |/    () public
  o  35:167994483a30 bumped update to bbb1ce6e7cb5:
  |   () public
  ~

XXX: not sure this is correct
  $ hg exp 12c31db4edf9
  # HG changeset patch
  # User test
  # Date 0 0
  #      Thu Jan 01 00:00:00 1970 +0000
  # Node ID 12c31db4edf9a889e3ce9986f484bbf939f4fb42
  # Parent  f695c2c8812d12a910a47440ee189e553326a1c8
  bumped update to f695c2c8812d:
  
  added q
  
  diff -r f695c2c8812d -r 12c31db4edf9 p
  --- a/p	Thu Jan 01 00:00:00 1970 +0000
  +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
  @@ -1,1 +0,0 @@
  -p

XXX: not sure this is correct
  $ hg exp abd19926ab01
  # HG changeset patch
  # User test
  # Date 0 0
  #      Thu Jan 01 00:00:00 1970 +0000
  # Node ID abd19926ab0109f43f38e732cfa8ae747e2e4187
  # Parent  f695c2c8812d12a910a47440ee189e553326a1c8
  bumped update to f695c2c8812d:
  
  added p
  
  diff -r f695c2c8812d -r abd19926ab01 q
  --- a/q	Thu Jan 01 00:00:00 1970 +0000
  +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
  @@ -1,1 +0,0 @@
  -q

Testing the evolution of a phase-divergent merge with no conflicts
------------------------------------------------------------------

  $ hg glog -r 167994483a30::
  @  40:12c31db4edf9 bumped update to f695c2c8812d:
  |   () draft
  | o  39:abd19926ab01 bumped update to f695c2c8812d:
  |/    () draft
  o  36:f695c2c8812d added p and q
  |   () public
  o  35:167994483a30 bumped update to bbb1ce6e7cb5:
  |   () public
  ~

  $ echo h > h
  $ hg ci -Aqm "added h"
  $ hg prev
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  [40] bumped update to f695c2c8812d:
  $ echo i > i
  $ hg ci -Aqm "added i"
  $ hg merge -r 'desc("added h")'
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  (branch merge, don't forget to commit)
  $ hg ci -m "merge h and i"

  $ hg glog -r 12c31db4edf9::
  @    43:98ce636fa344 merge h and i
  |\    () draft
  | o  42:c13ebd59dd4e added i
  | |   () draft
  o |  41:10bb6c8a838f added h
  |/    () draft
  o  40:12c31db4edf9 bumped update to f695c2c8812d:
  |   () draft
  ~

  $ hg up 10bb6c8a838f
  0 files updated, 0 files merged, 1 files removed, 0 files unresolved
  $ hg merge -r c13ebd59dd4e
  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
  (branch merge, don't forget to commit)
  $ hg ci -m "merge h and i successor"
  created new head
  $ hg glog -r 12c31db4edf9::
  @    44:57c7c43469f2 merge h and i successor
  |\    () draft
  +---o  43:98ce636fa344 merge h and i
  | |/    () draft
  | o  42:c13ebd59dd4e added i
  | |   () draft
  o |  41:10bb6c8a838f added h
  |/    () draft
  o  40:12c31db4edf9 bumped update to f695c2c8812d:
  |   () draft
  ~

  $ hg prune -r 98ce636fa344 --succ .
  1 changesets pruned

  $ hg phase 98ce636fa344 --hidden --public
  1 new bumped changesets

Resolution of phase-divergent merge commit using `hg evolve`

XXX: we should handle phase-divergent merges
  $ hg evolve --phase-divergent
  skipping 57c7c43469f2 : we do not handle merge yet