========================================================
Tests the resolution of content divergence: corner cases
========================================================
This file intend to cover cases that are specific enough to not fit in the
other cases.
$ cat >> $HGRCPATH <<EOF
> [alias]
> glog = log -GT "{rev}:{node|short} {desc|firstline}\n ({bookmarks}) [{branch}] {phase}"
> [defaults]
> amend=-d "0 0"
> fold=-d "0 0"
> [web]
> push_ssl = false
> allow_push = *
> [phases]
> publish = False
> [diff]
> git = 1
> unified = 0
> [ui]
> logtemplate = {rev}:{node|short}@{branch}({phase}) {desc|firstline} [{instabilities}]\n
> [experimental]
> evolution.allowdivergence = True
> [extensions]
> EOF
$ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH
$ mkcommit() {
> echo "$1" > "$1"
> hg add "$1"
> hg ci -m "add $1"
> }
$ mkcommits() {
> for i in $@; do mkcommit $i ; done
> }
Basic test of divergence: two divergent changesets with the same parents
With --all --any we dedupe the divergent and solve the divergence once
$ hg init test1
$ cd test1
$ echo a > a
$ hg ci -Aqm "added a"
$ echo b > b
$ hg ci -Aqm "added b"
$ hg up .^
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ echo bdivergent > bdivergent1
$ hg ci -Am "divergent"
adding bdivergent1
created new head
$ hg up .^
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ echo bdivergent > bdivergent2
$ hg ci -Am "divergent"
adding bdivergent2
created new head
$ hg prune -s 8374d2ddc3a4 "desc('added b')"
1 changesets pruned
$ hg prune -s 593c57f2117e "desc('added b')" --hidden
1 changesets pruned
2 new content-divergent changesets
$ hg log -G
@ 3:8374d2ddc3a4@default(draft) divergent [content-divergent]
|
| * 2:593c57f2117e@default(draft) divergent [content-divergent]
|/
o 0:9092f1db7931@default(draft) added a []
$ hg evolve --all --any --content-divergent --update
merge:[2] divergent
with: [3] divergent
base: [1] added b
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
working directory is now at 45bf1312f454
$ hg log -G
@ 4:45bf1312f454@default(draft) divergent []
|
o 0:9092f1db7931@default(draft) added a []
$ hg debugobsolete
5f6d8a4bf34ab274ccc9f631c2536964b8a3666d 8374d2ddc3a4d48428c3d2f80e4fc86f13736f96 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'operation': 'prune', 'user': 'test'}
5f6d8a4bf34ab274ccc9f631c2536964b8a3666d 593c57f2117e33dd0884382f02789d948f548557 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'operation': 'prune', 'user': 'test'}
593c57f2117e33dd0884382f02789d948f548557 45bf1312f45468b76158b33f8426e6530c8b35b1 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'evolve', 'user': 'test'}
8374d2ddc3a4d48428c3d2f80e4fc86f13736f96 45bf1312f45468b76158b33f8426e6530c8b35b1 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'evolve', 'user': 'test'}
$ hg obslog --all
@ 45bf1312f454 (4) divergent
|\
x | 593c57f2117e (2) divergent
| | amended(content) as 45bf1312f454 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
| |
| x 8374d2ddc3a4 (3) divergent
|/ amended(content) as 45bf1312f454 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
|
x 5f6d8a4bf34a (1) added b
rewritten(description, content) as 593c57f2117e using prune by test (Thu Jan 01 00:00:00 1970 +0000)
rewritten(description, content) as 8374d2ddc3a4 using prune by test (Thu Jan 01 00:00:00 1970 +0000)
Test divergence resolution when it yields to an empty commit (issue4950)
cdivergent2 contains the same content than cdivergent1 and they are divergent
versions of the revision _c
$ hg up .^
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
$ mkcommit _c
created new head
$ hg up .^
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ mkcommit cdivergent1
created new head
$ hg up .^
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ echo "cdivergent1" > cdivergent1
$ hg add cdivergent1
$ hg ci -m "add _c"
created new head
$ hg log -G
@ 7:b2ae71172042@default(draft) add _c []
|
| o 6:e3ff64ce8d4c@default(draft) add cdivergent1 []
|/
| o 5:48819a835615@default(draft) add _c []
|/
| o 4:45bf1312f454@default(draft) divergent []
|/
o 0:9092f1db7931@default(draft) added a []
$ hg prune -s b2ae71172042 48819a835615
1 changesets pruned
$ hg prune -s e3ff64ce8d4c 48819a835615 --hidden
1 changesets pruned
2 new content-divergent changesets
$ hg log -G
@ 7:b2ae71172042@default(draft) add _c [content-divergent]
|
| * 6:e3ff64ce8d4c@default(draft) add cdivergent1 [content-divergent]
|/
| o 4:45bf1312f454@default(draft) divergent []
|/
o 0:9092f1db7931@default(draft) added a []
$ hg evolve --all --any --content-divergent
merge:[6] add cdivergent1
with: [7] add _c
base: [5] add _c
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
nothing changed
working directory is now at e3ff64ce8d4c
$ hg log -G
@ 6:e3ff64ce8d4c@default(draft) add cdivergent1 []
|
| o 4:45bf1312f454@default(draft) divergent []
|/
o 0:9092f1db7931@default(draft) added a []
$ hg debugobsolete
5f6d8a4bf34ab274ccc9f631c2536964b8a3666d 8374d2ddc3a4d48428c3d2f80e4fc86f13736f96 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'operation': 'prune', 'user': 'test'}
5f6d8a4bf34ab274ccc9f631c2536964b8a3666d 593c57f2117e33dd0884382f02789d948f548557 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'operation': 'prune', 'user': 'test'}
593c57f2117e33dd0884382f02789d948f548557 45bf1312f45468b76158b33f8426e6530c8b35b1 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'evolve', 'user': 'test'}
8374d2ddc3a4d48428c3d2f80e4fc86f13736f96 45bf1312f45468b76158b33f8426e6530c8b35b1 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'evolve', 'user': 'test'}
48819a83561596ef0aeac4082eaaa8afe4320f3a b2ae71172042972a8e8d2bc11e2b2fe4e0c3aa49 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'prune', 'user': 'test'}
48819a83561596ef0aeac4082eaaa8afe4320f3a e3ff64ce8d4ce33b40d9f367a8ec472fec588ca3 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'operation': 'prune', 'user': 'test'}
b2ae71172042972a8e8d2bc11e2b2fe4e0c3aa49 e3ff64ce8d4ce33b40d9f367a8ec472fec588ca3 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '1', 'operation': 'evolve', 'user': 'test'}
BROKEN: We should have created a new commit as successor instead of reusing
revision 6
$ hg obslog --all
@ e3ff64ce8d4c (6) add cdivergent1
|\
| x b2ae71172042 (7) add _c
|/ reworded(description) as e3ff64ce8d4c using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
|
x 48819a835615 (5) add _c
amended(content) as b2ae71172042 using prune by test (Thu Jan 01 00:00:00 1970 +0000)
rewritten(description, content) as e3ff64ce8d4c using prune by test (Thu Jan 01 00:00:00 1970 +0000)
$ cd ..
Test None docstring issue of evolve divergent, which caused hg crush
$ hg init test2
$ cd test2
$ mkcommits _a _b
$ hg up .^
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ echo bdivergent > bdivergent11
$ hg ci -Am "bdivergent"
adding bdivergent11
created new head
$ hg up .^
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ echo bdivergent > bdivergent22
$ hg ci -Am "bdivergent"
adding bdivergent22
created new head
$ hg log -G
@ 3:6b096fb45070@default(draft) bdivergent []
|
| o 2:05a6b6a9e633@default(draft) bdivergent []
|/
| o 1:37445b16603b@default(draft) add _b []
|/
o 0:135f39f4bd78@default(draft) add _a []
$ hg prune -s 6b096fb45070 37445b16603b
1 changesets pruned
$ hg prune -s 05a6b6a9e633 37445b16603b --hidden
1 changesets pruned
2 new content-divergent changesets
$ hg log -G
@ 3:6b096fb45070@default(draft) bdivergent [content-divergent]
|
| * 2:05a6b6a9e633@default(draft) bdivergent [content-divergent]
|/
o 0:135f39f4bd78@default(draft) add _a []
$ cat >$TESTTMP/test_extension.py << EOF
> from mercurial import merge
> origupdate = merge.update
> def newupdate(*args, **kwargs):
> return origupdate(*args, **kwargs)
> merge.update = newupdate
> EOF
$ cat >> $HGRCPATH << EOF
> [extensions]
> testextension=$TESTTMP/test_extension.py
> EOF
$ hg evolve
nothing to evolve on current working copy parent
(do you want to use --content-divergent)
[2]
$ hg evolve --content-divergent
merge:[2] bdivergent
with: [3] bdivergent
base: [1] add _b
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
working directory is now at 73ff357d3975
$ hg log -G
@ 4:73ff357d3975@default(draft) bdivergent []
|
o 0:135f39f4bd78@default(draft) add _a []
$ hg debugobsolete
37445b16603b50165d5eb80735fb986c72a2dac1 6b096fb450709a194b21fb9b192fe9b1572c4af0 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'operation': 'prune', 'user': 'test'}
37445b16603b50165d5eb80735fb986c72a2dac1 05a6b6a9e633802d2bdd06e6d292982a767d930e 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'operation': 'prune', 'user': 'test'}
05a6b6a9e633802d2bdd06e6d292982a767d930e 73ff357d3975b9f319b59fd5853abc3c8294ae89 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'evolve', 'user': 'test'}
6b096fb450709a194b21fb9b192fe9b1572c4af0 73ff357d3975b9f319b59fd5853abc3c8294ae89 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'evolve', 'user': 'test'}
$ hg obslog --all
@ 73ff357d3975 (4) bdivergent
|\
x | 05a6b6a9e633 (2) bdivergent
| | amended(content) as 73ff357d3975 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
| |
| x 6b096fb45070 (3) bdivergent
|/ amended(content) as 73ff357d3975 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
|
x 37445b16603b (1) add _b
rewritten(description, content) as 05a6b6a9e633 using prune by test (Thu Jan 01 00:00:00 1970 +0000)
rewritten(description, content) as 6b096fb45070 using prune by test (Thu Jan 01 00:00:00 1970 +0000)
$ cd ..
Test to make sure that evolve don't fall into unrecoverable state (issue6053)
------------------------------------------------------------------------------
It happened when two divergent csets has different parent (need relocation)
and resolution parent is obsolete. So this issue triggered when during
relocation we hit conflicts. So lets make the repo as described.
$ hg init localside
$ cd localside
$ for ch in a b c d e; do
> echo $ch > $ch;
> hg add $ch;
> hg ci -m "added "$ch;
> done;
$ hg glog
@ 4:8d71eadcc9df added e
| () [default] draft
o 3:9150fe93bec6 added d
| () [default] draft
o 2:155349b645be added c
| () [default] draft
o 1:5f6d8a4bf34a added b
| () [default] draft
o 0:9092f1db7931 added a
() [default] draft
$ echo ee > e
$ hg amend -m "updated e"
$ hg up 1 -q
To make sure we hit conflict while relocating
$ echo dd > d
$ echo ee > e
$ hg add d e
$ hg ci -m "updated e"
created new head
Lets create divergence
$ hg prune 4 -s . --hidden
1 changesets pruned
2 new content-divergent changesets
Making obsolete resolution parent
$ hg prune 3
1 changesets pruned
1 new orphan changesets
$ hg glog
@ 6:de4ea3103326 updated e
| () [default] draft
| * 5:ff6f7cd76a7c updated e
| | () [default] draft
| x 3:9150fe93bec6 added d
| | () [default] draft
| o 2:155349b645be added c
|/ () [default] draft
o 1:5f6d8a4bf34a added b
| () [default] draft
o 0:9092f1db7931 added a
() [default] draft
$ hg evolve --content-divergent --any --update --config ui.interactive=true <<EOF
> c
> EOF
merge:[5] updated e
with: [6] updated e
base: [4] added e
rebasing "divergent" content-divergent changeset ff6f7cd76a7c on 155349b645be
rebasing "other" content-divergent changeset de4ea3103326 on 155349b645be
file 'd' was deleted in local but was modified in other.
You can use (c)hanged version, leave (d)eleted, or leave (u)nresolved.
What do you want to do? c
0 files updated, 1 files merged, 0 files removed, 0 files unresolved
working directory is now at eb6357cd41b6
$ hg glog -l1
@ 9:eb6357cd41b6 updated e
| () [default] draft
~
$ hg debugobsolete
8d71eadcc9dfb21a924e75a5796c2f011bdc55a4 ff6f7cd76a7c97d938e8fe87f0fc816b66929435 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '9', 'operation': 'amend', 'user': 'test'}
8d71eadcc9dfb21a924e75a5796c2f011bdc55a4 de4ea3103326293994c634101e780724346ee89f 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '13', 'operation': 'prune', 'user': 'test'}
9150fe93bec603cd88d05cda9f6ff13420cb53e9 0 {155349b645beebee15325a9a22dd0c9ef8fbbbd3} (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'prune', 'user': 'test'}
ff6f7cd76a7c97d938e8fe87f0fc816b66929435 0ceb21ca2557a61433f097e4d64024e37cae2c10 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'evolve', 'user': 'test'}
de4ea3103326293994c634101e780724346ee89f a2465d1d56d1aee8ed90d2292978456d2be6f7b9 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '4', 'operation': 'evolve', 'user': 'test'}
0ceb21ca2557a61433f097e4d64024e37cae2c10 eb6357cd41b6a6ec2f12e81cf96eaeeb54b057d2 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'evolve', 'user': 'test'}
a2465d1d56d1aee8ed90d2292978456d2be6f7b9 eb6357cd41b6a6ec2f12e81cf96eaeeb54b057d2 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '0', 'operation': 'evolve', 'user': 'test'}
$ hg obslog --all
@ eb6357cd41b6 (9) updated e
|\
x | 0ceb21ca2557 (7) updated e
| | amended(content) as eb6357cd41b6 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
| |
| x a2465d1d56d1 (8) updated e
| | rewritten as eb6357cd41b6 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
| |
| x de4ea3103326 (6) updated e
| | rebased(parent) as a2465d1d56d1 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
| |
x | ff6f7cd76a7c (5) updated e
|/ rebased(parent) as 0ceb21ca2557 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
|
x 8d71eadcc9df (4) added e
rewritten(description, parent, content) as de4ea3103326 using prune by test (Thu Jan 01 00:00:00 1970 +0000)
rewritten(description, content) as ff6f7cd76a7c using amend by test (Thu Jan 01 00:00:00 1970 +0000)
$ cd ..
Check that canceling of file deletion are merge correctly
---------------------------------------------------------
File addition/deletion tend to have special processing. So we better test them directory
$ hg init non-public
$ cd non-public
$ echo a > a
$ echo b > b
$ echo c > c
$ echo d > d
$ hg ci -Aqm initial
oops, we meant to delete just 'a', but we deleted 'b' and 'c' too
$ hg rm a b c
$ hg ci -m 'delete a'
$ hg revert -r .^ b
$ hg amend
create some content divergence
$ hg co dff6e52f5e41 --hidden
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
updated to hidden changeset dff6e52f5e41
(hidden revision 'dff6e52f5e41' was rewritten as: 0825dcee2670)
working directory parent is obsolete! (dff6e52f5e41)
(use 'hg evolve' to update to its successor: 0825dcee2670)
$ hg revert -r .^ c
$ hg amend
2 new content-divergent changesets
$ hg glog --hidden
@ 3:92ecd58f9b05 delete a
| () [default] draft
| * 2:0825dcee2670 delete a
|/ () [default] draft
| x 1:dff6e52f5e41 delete a
|/ () [default] draft
o 0:75d2b02c4a5c initial
() [default] draft
Resolve the divergence, only "a" should be removed
$ hg evolve --content-divergent --update
merge:[2] delete a
with: [3] delete a
base: [1] delete a
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
working directory is now at 7ca6a9fafcf6
$ hg glog
@ 4:7ca6a9fafcf6 delete a
| () [default] draft
o 0:75d2b02c4a5c initial
() [default] draft
$ hg diff --change .
diff --git a/a b/a
deleted file mode 100644
--- a/a
+++ /dev/null
@@ -1,1 +0,0 @@
-a
$ hg debugobsolete
dff6e52f5e419381c070159c8038ac948f59283f 0825dcee2670349e749f1df45857fca34f61e350 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
dff6e52f5e419381c070159c8038ac948f59283f 92ecd58f9b05d6c0a1c3833a79359eea4b0268ff 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'amend', 'user': 'test'}
0825dcee2670349e749f1df45857fca34f61e350 7ca6a9fafcf619820b754070ac0b447651005422 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'evolve', 'user': 'test'}
92ecd58f9b05d6c0a1c3833a79359eea4b0268ff 7ca6a9fafcf619820b754070ac0b447651005422 0 (Thu Jan 01 00:00:00 1970 +0000) {'ef1': '8', 'operation': 'evolve', 'user': 'test'}
$ hg obslog --all
@ 7ca6a9fafcf6 (4) delete a
|\
x | 0825dcee2670 (2) delete a
| | amended(content) as 7ca6a9fafcf6 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
| |
| x 92ecd58f9b05 (3) delete a
|/ amended(content) as 7ca6a9fafcf6 using evolve by test (Thu Jan 01 00:00:00 1970 +0000)
|
x dff6e52f5e41 (1) delete a
amended(content) as 0825dcee2670 using amend by test (Thu Jan 01 00:00:00 1970 +0000)
amended(content) as 92ecd58f9b05 using amend by test (Thu Jan 01 00:00:00 1970 +0000)