evolve: create new commit while resolving content-divergence
Before this patch, we used to amend one of the content-divergent changes with
the changes from the merge. Creating a new commit will certain advantages like
letting user enter a commit message, showing user the new merge diff before
commiting the content-divergent resolution and give us more control in the
implementation part.
The reason amend was used initially was just because it was easy. There are some
tests update due to change.
--- a/hgext3rd/evolve/evolvecmd.py Tue May 22 20:33:42 2018 +0530
+++ b/hgext3rd/evolve/evolvecmd.py Mon Apr 23 14:48:53 2018 +0530
@@ -33,7 +33,6 @@
from mercurial.i18n import _
from . import (
- cmdrewrite,
compat,
exthelper,
rewriteutil,
@@ -447,25 +446,23 @@
tr = repo.currenttransaction()
assert tr is not None
try:
- repo.ui.setconfig('ui', 'allowemptycommit', True, 'evolve')
with repo.dirstate.parentchange():
- repo.dirstate.setparents(divergent.node(), node.nullid)
- oldlen = len(repo)
- # temporary hack because we can't use cmdrewrite.amend() during an
- # interrupted evolve
- evolvestate.delete()
+ repo.dirstate.setparents(divergent.p1().node(), node.nullid)
- # XXX: we should not use amend here, rather create a new commit
- cmdrewrite.amend(ui, repo, message='', logfile='')
- # XXX: we can get rid of this len() call also by creating a new commit
- if oldlen == len(repo):
+ newnode = repo.commit(text=divergent.description(), user=repo.ui.username())
+ if newnode == divergent.node() or newnode is None:
+ # no changes
new = divergent
- # no changes
+ repo.ui.status(_("nothing changed\n"))
+ hg.updaterepo(repo, divergent.rev(), False)
+ obsolete.createmarkers(repo, [(other, (new,))], operation='evolve')
else:
- new = repo['.']
+ new = repo[newnode]
+ hg.updaterepo(repo, new.rev(), False)
+ obsolete.createmarkers(repo, [(other, (new,))], operation='evolve')
+ obsolete.createmarkers(repo, [(divergent, (new,))], operation='evolve')
# creating markers and moving phases post-resolution
- obsolete.createmarkers(repo, [(other, (new,))], operation='evolve')
phases.retractboundary(repo, tr, other.phase(), [new.node()])
return (True, new.node())
finally:
--- a/tests/test-divergent.t Tue May 22 20:33:42 2018 +0530
+++ b/tests/test-divergent.t Mon Apr 23 14:48:53 2018 +0530
@@ -60,9 +60,9 @@
updating to "local" side of the conflict: c2f698071cba
merging "other" content-divergent changeset 'e708fd28d5cf'
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
- working directory is now at c26f1d3baed2
+ working directory is now at c9708170cf11
$ hg log -G
- @ 4:c26f1d3baed2@default(draft) add bdivergent1 []
+ @ 4:c9708170cf11@default(draft) add bdivergent1 []
|
o 0:135f39f4bd78@default(draft) add _a []
@@ -94,7 +94,7 @@
|
| * 6:26c7705fee96@default(draft) add cdivergent1 [content-divergent]
|/
- | o 4:c26f1d3baed2@default(draft) add bdivergent1 []
+ | o 4:c9708170cf11@default(draft) add bdivergent1 []
|/
o 0:135f39f4bd78@default(draft) add _a []
@@ -154,7 +154,7 @@
base: [1] add _b
merging "other" content-divergent changeset 'c2f698071cba'
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
- working directory is now at aa26817f6fbe
+ working directory is now at 1ed713bcebf6
$ cd ..
--- a/tests/test-sharing.t Tue May 22 20:33:42 2018 +0530
+++ b/tests/test-sharing.t Mon Apr 23 14:48:53 2018 +0530
@@ -511,12 +511,12 @@
base: [4] fix bug 24 (v1)
merging "other" content-divergent changeset 'e3f99ce9d9cd'
0 files updated, 1 files merged, 0 files removed, 0 files unresolved
- working directory is now at 5ad6037c046c
+ working directory is now at 711ede2d7a26
$ hg log -q -r 'contentdivergent()'
Figure SG10: Bob's repository after fixing divergence.
$ hg --hidden shortlog -G -r 3::
- @ 7:5ad6037c046c draft fix bug 24 (v2 by bob)
+ @ 7:711ede2d7a26 draft fix bug 24 (v2 by bob)
|
| x 6:e3f99ce9d9cd draft fix bug 24 (v2 by alice)
|/
@@ -527,7 +527,7 @@
o 3:a06ec1bf97bd public fix bug 15 (v2)
|
~
- $ hg --hidden shortlog -r 'precursors(5ad6037c046c)'
+ $ hg --hidden shortlog -r 'precursors(711ede2d7a26)'
5:a360947f6faf draft fix bug 24 (v2 by bob)
6:e3f99ce9d9cd draft fix bug 24 (v2 by alice)
$ cat file1
--- a/tests/test-stabilize-result.t Tue May 22 20:33:42 2018 +0530
+++ b/tests/test-stabilize-result.t Mon Apr 23 14:48:53 2018 +0530
@@ -294,16 +294,14 @@
resolving manifests
merging a
0 files updated, 1 files merged, 0 files removed, 0 files unresolved
- amending changeset eacc9c8240fe
committing files:
a
committing manifest
committing changelog
- committed changeset 15:f344982e63c4
- working directory is now at f344982e63c4
+ working directory is now at 4d6ed26797bc
$ hg st
$ glog
- @ 15:f344982e63c4@default(draft) bk:[] More addition
+ @ 15:4d6ed26797bc@default(draft) bk:[] More addition
|
| o 11:8fc63fe1f297@default(draft) bk:[] phase-divergent update to 1cf0aacfd363:
| |
@@ -316,7 +314,7 @@
o 0:07f494440405@default(public) bk:[] adda
$ hg summary
- parent: 15:f344982e63c4 tip
+ parent: 15:4d6ed26797bc tip
More addition
branch: default
commit: (clean)
@@ -327,11 +325,11 @@
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
- # Node ID f344982e63c462b1e44c0371c804685389e673a9
+ # Node ID 4d6ed26797bc392c0099e48402a5134e669f1a60
# Parent 7bc2f5967f5e4ed277f60a89b7b04cc5d6407ced
More addition
- diff -r 7bc2f5967f5e -r f344982e63c4 a
+ diff -r 7bc2f5967f5e -r 4d6ed26797bc a
--- a/a Thu Jan 01 00:00:00 1970 +0000
+++ b/a Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +1,9 @@
@@ -351,9 +349,9 @@
$ hg up --hidden 3932c176bbaa
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
updated to hidden changeset 3932c176bbaa
- (hidden revision '3932c176bbaa' was rewritten as: f344982e63c4)
+ (hidden revision '3932c176bbaa' was rewritten as: 4d6ed26797bc)
working directory parent is obsolete! (3932c176bbaa)
- (use 'hg evolve' to update to its successor: f344982e63c4)
+ (use 'hg evolve' to update to its successor: 4d6ed26797bc)
$ echo 'gotta break' >> a
$ hg amend
2 new content-divergent changesets
@@ -366,7 +364,7 @@
$ glog
@ 17:0b336205a5d0@default(draft) bk:[] More addition (2)
|
- | * 15:f344982e63c4@default(draft) bk:[] More addition
+ | * 15:4d6ed26797bc@default(draft) bk:[] More addition
|/
| o 11:8fc63fe1f297@default(draft) bk:[] phase-divergent update to 1cf0aacfd363:
| |
@@ -381,8 +379,8 @@
$ hg evolve -qn --content-divergent
hg update -c 0b336205a5d0 &&
- hg merge f344982e63c4 &&
- hg commit -m "auto merge resolving conflict between 0b336205a5d0 and f344982e63c4"&&
+ hg merge 4d6ed26797bc &&
+ hg commit -m "auto merge resolving conflict between 0b336205a5d0 and 4d6ed26797bc"&&
hg up -C 3932c176bbaa &&
hg revert --all --rev tip &&
hg commit -m "`hg log -r 0b336205a5d0 --template={desc}`";
@@ -390,7 +388,7 @@
merge:[17] More addition (2)
with: [15] More addition
base: [12] More addition
- merging "other" content-divergent changeset 'f344982e63c4'
+ merging "other" content-divergent changeset '4d6ed26797bc'
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
@@ -413,9 +411,9 @@
(no more unresolved files)
continue: hg evolve --continue
$ hg evolve --continue
- working directory is now at e015aa78acee
+ working directory is now at e8746835a2a1
$ glog
- @ 18:e015aa78acee@default(draft) bk:[] More addition (2)
+ @ 18:e8746835a2a1@default(draft) bk:[] More addition (2)
|
| o 11:8fc63fe1f297@default(draft) bk:[] phase-divergent update to 1cf0aacfd363:
| |
@@ -432,11 +430,11 @@
# User test
# Date 0 0
# Thu Jan 01 00:00:00 1970 +0000
- # Node ID e015aa78acee692d26215fafdb7f70974682739c
+ # Node ID e8746835a2a13122bc8c0ed84fe4ee35649af25d
# Parent 7bc2f5967f5e4ed277f60a89b7b04cc5d6407ced
More addition (2)
- diff -r 7bc2f5967f5e -r e015aa78acee a
+ diff -r 7bc2f5967f5e -r e8746835a2a1 a
--- a/a Thu Jan 01 00:00:00 1970 +0000
+++ b/a Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +1,9 @@