branching: merge with test consolidation
Conflict were simple once isolated.
=======================================================
Tests the resolution of content divergence: basic cases
=======================================================
This file intend to cover basic case of content divergence. See the other test
file for more advanced 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} [{troubles}]\n
> [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
merge:[2] divergent
with: [3] divergent
base: [1] added b
updating to "local" side of the conflict: 593c57f2117e
merging "other" content-divergent changeset '8374d2ddc3a4'
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 []
$ cd ..
Extra setup
-----------
(the test below were initially in a different file)
$ hg init cdiv
$ cd cdiv
$ echo ".*\.orig" > .hgignore
$ hg add .hgignore
$ hg ci -m "added hgignore"
$ for ch in a b c d; do echo foo > $ch; hg add $ch; hg ci -qm "added "$ch; done;
$ hg glog
@ 4:c41c793e0ef1 added d
| () [default] draft
o 3:ca1b80f7960a added c
| () [default] draft
o 2:b1661037fa25 added b
| () [default] draft
o 1:c7586e2a9264 added a
| () [default] draft
o 0:8fa14d15e168 added hgignore
() [default] draft
Merging branch difference
-------------------------
Creating content-divergence with branch change where base, divergent and other
have different branches
$ hg branch -r . foobar
changed branch on 1 changesets
$ hg up c41c793e0ef1 --hidden
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
updated to hidden changeset c41c793e0ef1
(hidden revision 'c41c793e0ef1' was rewritten as: 9e5dffcb3d48)
working directory parent is obsolete! (c41c793e0ef1)
(use 'hg evolve' to update to its successor: 9e5dffcb3d48)
$ echo bar > d
$ hg branch watwat
marked working directory as branch watwat
$ hg amend
2 new content-divergent changesets
$ hg glog
@ 6:264b04f771fb added d
| () [watwat] draft
| * 5:9e5dffcb3d48 added d
|/ () [foobar] draft
o 3:ca1b80f7960a added c
| () [default] draft
o 2:b1661037fa25 added b
| () [default] draft
o 1:c7586e2a9264 added a
| () [default] draft
o 0:8fa14d15e168 added hgignore
() [default] draft
$ hg evolve --content-divergent --config ui.interactive=True<<EOF
> c
> EOF
merge:[6] added d
with: [5] added d
base: [4] added d
merging "other" content-divergent changeset '9e5dffcb3d48'
0 files updated, 0 files merged, 0 files removed, 0 files unresolved
content divergent changesets on different branches.
choose branch for the resolution changeset. (a) default or (b) watwat or (c) foobar? c
working directory is now at 0ac42f1bc15c
$ hg glog
@ 7:0ac42f1bc15c added d
| () [foobar] draft
o 3:ca1b80f7960a added c
| () [default] draft
o 2:b1661037fa25 added b
| () [default] draft
o 1:c7586e2a9264 added a
| () [default] draft
o 0:8fa14d15e168 added hgignore
() [default] draft
Testing merging of commit messages
-----------------------------------
When base and one of the divergent has same commit messages and other divergent
has different one
$ echo wat > d
$ hg amend
$ hg up .^
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
$ echo bar > d
$ hg ci -Aqm "added a d with bar in it, expect some beers"
$ hg prune -r 0ac42f1bc15c -s . --hidden
1 changesets pruned
2 new content-divergent changesets
$ hg glog
@ 9:59081c9c425a added a d with bar in it, expect some beers
| () [default] draft
| * 8:f621d00f5f0e added d
|/ () [foobar] draft
o 3:ca1b80f7960a added c
| () [default] draft
o 2:b1661037fa25 added b
| () [default] draft
o 1:c7586e2a9264 added a
| () [default] draft
o 0:8fa14d15e168 added hgignore
() [default] draft
$ hg evolve --content-divergent
merge:[9] added a d with bar in it, expect some beers
with: [8] added d
base: [7] added d
merging "other" content-divergent changeset 'f621d00f5f0e'
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
working directory is now at a9d6fd6b5e40
$ hg glog
@ 10:a9d6fd6b5e40 added a d with bar in it, expect some beers
| () [default] draft
o 3:ca1b80f7960a added c
| () [default] draft
o 2:b1661037fa25 added b
| () [default] draft
o 1:c7586e2a9264 added a
| () [default] draft
o 0:8fa14d15e168 added hgignore
() [default] draft
When base has different message and both divergents has same one
$ echo foo > d
$ hg amend -m "foo to d"
$ hg up a9d6fd6b5e40 --hidden
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
updated to hidden changeset a9d6fd6b5e40
(hidden revision 'a9d6fd6b5e40' was rewritten as: b10b07a394f1)
working directory parent is obsolete! (a9d6fd6b5e40)
(use 'hg evolve' to update to its successor: b10b07a394f1)
$ echo babar > d
$ hg amend -m "foo to d"
2 new content-divergent changesets
$ hg glog
@ 12:0bb497fed24a foo to d
| () [default] draft
| * 11:b10b07a394f1 foo to d
|/ () [default] draft
o 3:ca1b80f7960a added c
| () [default] draft
o 2:b1661037fa25 added b
| () [default] draft
o 1:c7586e2a9264 added a
| () [default] draft
o 0:8fa14d15e168 added hgignore
() [default] draft
$ hg evolve --content-divergent
merge:[12] foo to d
with: [11] foo to d
base: [10] added a d with bar in it, expect some beers
merging "other" content-divergent changeset 'b10b07a394f1'
merging d
warning: conflicts while merging d! (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 foobar > d
$ hg resolve -m
(no more unresolved files)
continue: hg evolve --continue
$ hg evolve --continue
working directory is now at 11175423b5dc
$ hg glog
@ 13:11175423b5dc foo to d
| () [default] draft
o 3:ca1b80f7960a added c
| () [default] draft
o 2:b1661037fa25 added b
| () [default] draft
o 1:c7586e2a9264 added a
| () [default] draft
o 0:8fa14d15e168 added hgignore
() [default] draft
When all three base, divergent and other has different commit messages creating
conflicts
$ echo bar > d
$ hg amend -m "bar to d, expect beers"
$ hg up 11175423b5dc --hidden
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
updated to hidden changeset 11175423b5dc
(hidden revision '11175423b5dc' was rewritten as: 27f0463f169a)
working directory parent is obsolete! (11175423b5dc)
(use 'hg evolve' to update to its successor: 27f0463f169a)
$ echo wat > d
$ hg amend -m "wat to d, wat?"
2 new content-divergent changesets
$ hg glog
@ 15:f542037ddf31 wat to d, wat?
| () [default] draft
| * 14:27f0463f169a bar to d, expect beers
|/ () [default] draft
o 3:ca1b80f7960a added c
| () [default] draft
o 2:b1661037fa25 added b
| () [default] draft
o 1:c7586e2a9264 added a
| () [default] draft
o 0:8fa14d15e168 added hgignore
() [default] draft
$ hg evolve --content-divergent
merge:[15] wat to d, wat?
with: [14] bar to d, expect beers
base: [13] foo to d
merging "other" content-divergent changeset '27f0463f169a'
merging d
warning: conflicts while merging d! (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 watbar > d
$ hg resolve -m
(no more unresolved files)
continue: hg evolve --continue
$ cat > editor.sh <<EOF
> #!/bin/sh
> printf "**showing editors text**\n\n"
> cat \$1
> printf "\n**done showing editors text**\n\n"
> cat > \$1 <<ENDOF
> watbar to d
> ENDOF
> EOF
$ HGEDITOR='sh ./editor.sh' hg evolve --continue
**showing editors text**
HG: Conflicts while merging changeset description of content-divergent changesets.
HG: Resolve conflicts in commit messages to continue.
<<<<<<< divergent
wat to d, wat?||||||| base
foo to d=======
bar to d, expect beers>>>>>>> other
**done showing editors text**
working directory is now at 89ea3eee2d69
$ hg glog
@ 16:89ea3eee2d69 watbar to d
| () [default] draft
o 3:ca1b80f7960a added c
| () [default] draft
o 2:b1661037fa25 added b
| () [default] draft
o 1:c7586e2a9264 added a
| () [default] draft
o 0:8fa14d15e168 added hgignore
() [default] draft
$ cd ..
Stabilize content-divergent changesets with same parent
=======================================================
$ glog() {
> hg log -G --template \
> '{rev}:{node|short}@{branch}({phase}) bk:[{bookmarks}] {desc|firstline}\n' "$@"
> }
$ hg init content-divergent-savanna
$ cd content-divergent-savanna
$ echo a > a
$ hg add a
$ hg ci -m 'root'
$ hg phase --public .
$ cat << EOF >> a
> flore
> arthur
> zephir
> some
> less
> conflict
> EOF
$ hg ci -m 'More addition'
$ glog
@ 1:867e43582046@default(draft) bk:[] More addition
|
o 0:6569b5a81c7e@default(public) bk:[] root
$ echo 'babar' >> a
$ hg amend
$ hg up --hidden 'min(desc("More addition"))'
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
updated to hidden changeset 867e43582046
(hidden revision '867e43582046' was rewritten as: fc6349f931da)
working directory parent is obsolete! (867e43582046)
(use 'hg evolve' to update to its successor: fc6349f931da)
$ mv a a.old
$ echo 'jungle' > a
$ cat a.old >> a
$ rm a.old
$ hg amend
2 new content-divergent changesets
$ glog
@ 3:051337a45e7c@default(draft) bk:[] More addition
|
| * 2:fc6349f931da@default(draft) bk:[] More addition
|/
o 0:6569b5a81c7e@default(public) bk:[] root
Stabilize it
$ hg evolve -qn --confirm --content-divergent
merge:[3] More addition
with: [2] More addition
base: [1] More addition
perform evolve? [Ny] n
abort: evolve aborted by user
[255]
$ echo y | hg evolve -qn --confirm --config ui.interactive=True --content-divergent
merge:[3] More addition
with: [2] More addition
base: [1] More addition
perform evolve? [Ny] y
hg update -c 051337a45e7c &&
hg merge fc6349f931da &&
hg commit -m "auto merge resolving conflict between 051337a45e7c and fc6349f931da"&&
hg up -C 867e43582046 &&
hg revert --all --rev tip &&
hg commit -m "`hg log -r 051337a45e7c --template={desc}`";
$ hg evolve -v --content-divergent
merge:[3] More addition
with: [2] More addition
base: [1] More addition
merging "other" content-divergent changeset 'fc6349f931da'
resolving manifests
merging a
0 files updated, 1 files merged, 0 files removed, 0 files unresolved
committing files:
a
committing manifest
committing changelog
working directory is now at 5bf84d1d71d1
$ hg st
$ glog
@ 4:5bf84d1d71d1@default(draft) bk:[] More addition
|
o 0:6569b5a81c7e@default(public) bk:[] root
$ hg summary
parent: 4:5bf84d1d71d1 tip
More addition
branch: default
commit: (clean)
update: (current)
phases: 1 draft
$ hg export . --config diff.unified=3
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID 5bf84d1d71d12f451bfe1e09b93045eb6338cd6c
# Parent 6569b5a81c7e307ddc076550e8c0f6d75b6effcd
More addition
diff --git a/a b/a
--- a/a
+++ b/a
@@ -1,1 +1,9 @@
+jungle
a
+flore
+arthur
+zephir
+some
+less
+conflict
+babar
Check conflict during content-divergence resolution
---------------------------------------------------
$ hg up --hidden 'min(desc("More addition"))'
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
updated to hidden changeset 867e43582046
(hidden revision '867e43582046' was rewritten as: 5bf84d1d71d1)
working directory parent is obsolete! (867e43582046)
(use 'hg evolve' to update to its successor: 5bf84d1d71d1)
$ echo 'gotta break' >> a
$ hg amend
2 new content-divergent changesets
# reamend so that the case is not the first precursor.
$ hg amend -m "More addition (2)"
$ hg phase 'contentdivergent()'
4: draft
6: draft
$ glog
@ 6:13c1b75640a1@default(draft) bk:[] More addition (2)
|
| * 4:5bf84d1d71d1@default(draft) bk:[] More addition
|/
o 0:6569b5a81c7e@default(public) bk:[] root
$ hg evolve -qn --content-divergent
hg update -c 13c1b75640a1 &&
hg merge 5bf84d1d71d1 &&
hg commit -m "auto merge resolving conflict between 13c1b75640a1 and 5bf84d1d71d1"&&
hg up -C 867e43582046 &&
hg revert --all --rev tip &&
hg commit -m "`hg log -r 13c1b75640a1 --template={desc}`";
$ hg evolve --content-divergent
merge:[6] More addition (2)
with: [4] More addition
base: [1] More addition
merging "other" content-divergent changeset '5bf84d1d71d1'
merging a
warning: conflicts while merging a! (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]
$ cat > a <<EOF
> jungle
> a
> flore
> arthur
> zephir
> some
> less
> conflict
> babar
> EOF
$ hg resolve -m
(no more unresolved files)
continue: hg evolve --continue
$ hg evolve --continue
working directory is now at 2346e1147fed
$ glog
@ 7:2346e1147fed@default(draft) bk:[] More addition (2)
|
o 0:6569b5a81c7e@default(public) bk:[] root
$ hg exp --config diff.unified=3
# HG changeset patch
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
# Node ID 2346e1147fedc8c9aa17f9ba7870dcd8be52f567
# Parent 6569b5a81c7e307ddc076550e8c0f6d75b6effcd
More addition (2)
diff --git a/a b/a
--- a/a
+++ b/a
@@ -1,1 +1,9 @@
+jungle
a
+flore
+arthur
+zephir
+some
+less
+conflict
+babar
$ cd ..