evolve: create a new commit instead of amending one of the divergents
This patch changes the behavior of evolve command while resolving
content-divergence to create a new commit instead of amending one of the
divergent ones.
In past, I have made this change, backed out this change and now today again I
am doing this change, so let's dive in some history.
Using cmdrewrite.amend() was never a good option as that requires hack to delete
the evolvestate and also gives us less control over things. We can't make the
commit on top of different parents as that of content-divergent ones. Due to all
these, I first made this change to create a new commit instead of amending one.
But, after few days, there was flakiness observed in the tests and turned out
that we need to do some dirstate dance as repo.dirstate.setparents() does not
always fix the dirstate. That flakiness was a blocker for progress at that time
and we decided to switch to amend back so that we can have things working with
some hacks and we can later fix the implementation part.
Now, yesterday while tackling resolving content-divergence of a stack which is
as follows:
C1 C2
| |
B1 B2
| |
A1 A2
\/
base
where, A1-A2, B1-B2, C1-C2 are content-divergent with each other. Now we can
resolve A1-A2 very well because they have the same parent and let's say that
resolution leads to A3.
Now, we want to resolve B1-B2 and make the new resolution commit on top of A3 so
that we can end up something like:
C3
|
B3
|
A3
|
base
however, amending one of the divergent changesets, it's not possible to create a
commit on a different parent like A3 here without some relocation. We should
prevent relocation as that may leads to some conflicts and should change the
parent before committing.
So, looking ahead, we can't move with using amend as still using that we will
need some relocation hacks making code ugly and prone to bad behaviors, bugs.
Let's change back to creating a new commit so that we can move forward in a good
way.
About repo.dirstate.setparents() not setting the dirstate, I have researched
yesterday night about how we can do that and found out that we can use
cmdrewrite._uncommitdirstate() here. Expect upcoming patches to improve the
documentation of that function.
There are lot of test changes because of change in hash but there is no behavior
change. The only behavior change is in test-evolve-abort-contentdiv.t which is
nice because creating a new commit helps us in stripping that while aborting.
We have a lot of testing of content-divergence and no behavior change gives
enough confidence for making this change.
I reviewed the patch carefully to make sure there is no behavior change and I
suggest reviewer to do the same.
Tests for changing and clearing topics
======================================
$ . "$TESTDIR/testlib/topic_setup.sh"
$ cat <<EOF >> $HGRCPATH
> [experimental]
> # disable the new graph style until we drop 3.7 support
> graphstyle.missing = |
> evolution=createmarkers, allowunstable
> [phases]
> publish=false
> [alias]
> glog = log -G -T "{rev}:{node|short} \{{topic}}\n{desc} ({bookmarks})\n\n"
> EOF
About the glog output: {} contains the topic name and () will contain the bookmark
Setting up a repo
----------------
$ hg init topics
$ cd topics
$ for ch in a b c d e f g h; do touch $ch; echo "foo" >> $ch; hg ci -Aqm "Added "$ch; done
$ hg glog
@ 7:ec2426147f0e {}
| Added h ()
|
o 6:87d6d6676308 {}
| Added g ()
|
o 5:825660c69f0c {}
| Added f ()
|
o 4:aa98ab95a928 {}
| Added e ()
|
o 3:62615734edd5 {}
| Added d ()
|
o 2:28ad74487de9 {}
| Added c ()
|
o 1:29becc82797a {}
| Added b ()
|
o 0:18d04c59bb5d {}
Added a ()
Clearing topic from revision without topic
$ hg topic -r . --clear
changed topic on 0 changes
Clearing current topic when no active topic is not error
$ hg topic
$ hg topic --clear
Setting topics to all the revisions
$ hg topic -r 0:: foo
switching to topic foo
changed topic on 8 changes
$ hg glog
@ 15:05095f607171 {foo}
| Added h ()
|
o 14:97505b53ab0d {foo}
| Added g ()
|
o 13:75a8360fe626 {foo}
| Added f ()
|
o 12:abcedffeae90 {foo}
| Added e ()
|
o 11:1315a3808ed0 {foo}
| Added d ()
|
o 10:1fa891977a22 {foo}
| Added c ()
|
o 9:a53ba98dd6b8 {foo}
| Added b ()
|
o 8:86a186070af2 {foo}
Added a ()
Clearing the active topic using --clear
$ hg topic
* foo (8 changesets)
$ hg topic --clear
$ hg topic
foo (8 changesets)
Changing topics on some revisions (also testing issue 5441)
$ hg topic -r abcedffeae90:: bar
switching to topic bar
changed topic on 4 changes
$ hg glog
@ 19:d7d36e193ea7 {bar}
| Added h ()
|
o 18:e7b418d79a05 {bar}
| Added g ()
|
o 17:82e0b14f4d9e {bar}
| Added f ()
|
o 16:edc4a6b9ea60 {bar}
| Added e ()
|
o 11:1315a3808ed0 {foo}
| Added d ()
|
o 10:1fa891977a22 {foo}
| Added c ()
|
o 9:a53ba98dd6b8 {foo}
| Added b ()
|
o 8:86a186070af2 {foo}
Added a ()
Changing topics without passing topic name and clear
$ hg topic -r .
abort: changing topic requires a topic name or --clear
[255]
Changing topic using --current flag
$ hg topic foobar
$ hg topic -r . --current
active topic 'foobar' grew its first changeset
(see 'hg help topics' for more information)
changed topic on 1 changes
$ hg glog -r .
@ 20:c2d6b7df5dcf {foobar}
| Added h ()
|
Changing topic in between the stack
$ hg topic -r 9::10 --current
5 new orphan changesets
changed topic on 2 changes
$ hg glog
o 22:1b88140feefe {foobar}
| Added c ()
|
o 21:c39cabfcbbf7 {foobar}
| Added b ()
|
| @ 20:c2d6b7df5dcf {foobar}
| | Added h ()
| |
| * 18:e7b418d79a05 {bar}
| | Added g ()
| |
| * 17:82e0b14f4d9e {bar}
| | Added f ()
| |
| * 16:edc4a6b9ea60 {bar}
| | Added e ()
| |
| * 11:1315a3808ed0 {foo}
| | Added d ()
| |
| x 10:1fa891977a22 {foo}
| | Added c ()
| |
| x 9:a53ba98dd6b8 {foo}
|/ Added b ()
|
o 8:86a186070af2 {foo}
Added a ()
$ hg rebase -s 11 -d 22
rebasing 11:1315a3808ed0 "Added d" (foo)
switching to topic foo
rebasing 16:edc4a6b9ea60 "Added e" (bar)
switching to topic bar
rebasing 17:82e0b14f4d9e "Added f" (bar)
rebasing 18:e7b418d79a05 "Added g" (bar)
rebasing 20:c2d6b7df5dcf "Added h" (foobar)
switching to topic foobar
$ hg glog
@ 27:a1a9465da59b {foobar}
| Added h ()
|
o 26:7c76c271395f {bar}
| Added g ()
|
o 25:7f26084dfaf1 {bar}
| Added f ()
|
o 24:b1f05e9ba0b5 {bar}
| Added e ()
|
o 23:f9869da2286e {foo}
| Added d ()
|
o 22:1b88140feefe {foobar}
| Added c ()
|
o 21:c39cabfcbbf7 {foobar}
| Added b ()
|
o 8:86a186070af2 {foo}
Added a ()
Amending a topic
----------------
When the changeset has a topic and we have different active topic
$ hg topic wat
$ hg ci --amend
active topic 'wat' grew its first changeset
(see 'hg help topics' for more information)
$ hg glog -r .
@ 28:61470c956807 {wat}
| Added h ()
|
Clear the current topic and amending
$ hg topic --clear
$ hg ci --amend
$ hg glog -r .
@ 29:b584fa49f42e {}
| Added h ()
|
When the changeset does not has a topic but we have an active topic
$ hg topic watwat
marked working directory as topic: watwat
$ hg ci --amend
active topic 'watwat' grew its first changeset
(see 'hg help topics' for more information)
$ hg glog -r .
@ 30:a24c31c35013 {watwat}
| Added h ()
|
Testing changing topics on public changeset
-------------------------------------------
$ hg phase -r 8 -p
Clearing the topic
$ hg topic -r 8 --clear
abort: can't change topic of a public change
[255]
Changing the topic
$ hg topic -r 8 foobarboo
abort: can't change topic of a public change
[255]
Testing the bookmark movement
-----------------------------
$ hg bookmark book
$ hg glog
@ 30:a24c31c35013 {watwat}
| Added h (book)
|
o 26:7c76c271395f {bar}
| Added g ()
|
o 25:7f26084dfaf1 {bar}
| Added f ()
|
o 24:b1f05e9ba0b5 {bar}
| Added e ()
|
o 23:f9869da2286e {foo}
| Added d ()
|
o 22:1b88140feefe {foobar}
| Added c ()
|
o 21:c39cabfcbbf7 {foobar}
| Added b ()
|
o 8:86a186070af2 {}
Added a ()
On clearing the topic
$ hg topic -r . --clear
clearing empty topic "watwat"
active topic 'watwat' is now empty
changed topic on 1 changes
$ hg glog
@ 31:c48d6d71b2d9 {}
| Added h (book)
|
o 26:7c76c271395f {bar}
| Added g ()
|
o 25:7f26084dfaf1 {bar}
| Added f ()
|
o 24:b1f05e9ba0b5 {bar}
| Added e ()
|
o 23:f9869da2286e {foo}
| Added d ()
|
o 22:1b88140feefe {foobar}
| Added c ()
|
o 21:c39cabfcbbf7 {foobar}
| Added b ()
|
o 8:86a186070af2 {}
Added a ()
On changing the topic
$ hg bookmark bookboo
$ hg topic -r . movebook
switching to topic movebook
changed topic on 1 changes
$ hg glog
@ 32:1b83d11095b9 {movebook}
| Added h (book bookboo)
|
o 26:7c76c271395f {bar}
| Added g ()
|
o 25:7f26084dfaf1 {bar}
| Added f ()
|
o 24:b1f05e9ba0b5 {bar}
| Added e ()
|
o 23:f9869da2286e {foo}
| Added d ()
|
o 22:1b88140feefe {foobar}
| Added c ()
|
o 21:c39cabfcbbf7 {foobar}
| Added b ()
|
o 8:86a186070af2 {}
Added a ()
Changing topic on secret changesets
-----------------------------------
$ hg up 26
switching to topic bar
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
(leaving bookmark bookboo)
$ hg phase -r . -s -f
$ hg phase -r .
26: secret
$ hg topic -r . watwat
switching to topic watwat
1 new orphan changesets
changed topic on 1 changes
$ hg glog
@ 33:894983f69e69 {watwat}
| Added g ()
|
| * 32:1b83d11095b9 {movebook}
| | Added h (book bookboo)
| |
| x 26:7c76c271395f {bar}
|/ Added g ()
|
o 25:7f26084dfaf1 {bar}
| Added f ()
|
o 24:b1f05e9ba0b5 {bar}
| Added e ()
|
o 23:f9869da2286e {foo}
| Added d ()
|
o 22:1b88140feefe {foobar}
| Added c ()
|
o 21:c39cabfcbbf7 {foobar}
| Added b ()
|
o 8:86a186070af2 {}
Added a ()
$ hg phase -r .
33: secret