Mercurial > evolve
view tests/test-evolve-abort-orphan.t @ 3846:f9dad99a90d5
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.
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Wed, 13 Jun 2018 17:15:10 +0530 |
parents | f0096db2a7b1 |
children | 629558d09898 |
line wrap: on
line source
Tests for the --abort flag for `hg evolve` command while orphan resolution ========================================================================== The `--abort` flag aborts the interrupted evolve by undoing all the work which was done during resolution i.e. stripping new changesets created, moving bookmarks back, moving working directory back. This test contains cases when `hg evolve` is doing orphan resolution. Setup ===== $ cat >> $HGRCPATH <<EOF > [phases] > publish = False > [alias] > glog = log -GT "{rev}:{node|short} {desc}\n ({bookmarks}) {phase}" > [extensions] > EOF $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH $ hg init abortrepo $ cd abortrepo $ 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 | () draft o 3:ca1b80f7960a added c | () draft o 2:b1661037fa25 added b | () draft o 1:c7586e2a9264 added a | () draft o 0:8fa14d15e168 added hgignore () draft Testing --abort when no evolve is interrupted ============================================= $ hg evolve --abort abort: no interrupted evolve to stop [255] Testing with wrong combination of flags ======================================= $ hg evolve --abort --continue abort: cannot specify both "--abort" and "--continue" [255] $ hg evolve --abort --stop abort: cannot specify both "--abort" and "--stop" [255] $ hg evolve --abort --rev 3 abort: cannot specify both "--rev" and "--abort" [255] $ hg evolve --abort --any abort: cannot specify both "--any" and "--abort" [255] $ hg evolve --abort --all abort: cannot specify both "--all" and "--abort" [255] Normal testingw when no rev was evolved ======================================== $ hg prev 0 files updated, 0 files merged, 1 files removed, 0 files unresolved [3] added c $ echo babar > d $ hg add d $ hg amend 1 new orphan changesets $ hg evolve --all move:[4] added d atop:[5] added c merging d warning: conflicts while merging d! (edit, then use 'hg resolve --mark') abort: fix conflicts and see `hg help evolve.interrupted` [255] $ hg evolve --abort evolve aborted working directory is now at e93a9161a274 $ hg glog @ 5:e93a9161a274 added c | () draft | * 4:c41c793e0ef1 added d | | () draft | x 3:ca1b80f7960a added c |/ () draft o 2:b1661037fa25 added b | () draft o 1:c7586e2a9264 added a | () draft o 0:8fa14d15e168 added hgignore () draft $ hg diff $ hg status cleaning up things for next testing $ hg evolve --all move:[4] added d atop:[5] added c merging d warning: conflicts while merging d! (edit, then use 'hg resolve --mark') abort: fix conflicts and see `hg help evolve.interrupted` [255] $ echo foo > d $ hg resolve -m (no more unresolved files) continue: hg evolve --continue $ hg evolve --continue evolving 4:c41c793e0ef1 "added d" working directory is now at e83de241f751 $ hg up .^^^ 0 files updated, 0 files merged, 3 files removed, 0 files unresolved When there are evolved revisions but on a single branch ======================================================= $ echo bar > c $ hg add c $ hg amend 3 new orphan changesets $ hg evolve --all move:[2] added b atop:[7] added a move:[5] added c atop:[8] added b merging c warning: conflicts while merging c! (edit, then use 'hg resolve --mark') abort: fix conflicts and see `hg help evolve.interrupted` [255] testing that interrupted evolve shows up in morestatus $ hg status -v M c A d # The repository is in an unfinished *evolve* state. # Unresolved merge conflicts: # # c # # To mark files as resolved: hg resolve --mark FILE # To continue: hg evolve --continue # To abort: hg evolve --abort # To stop: hg evolve --stop # (also see `hg help evolve.interrupted`) $ hg glog @ 8:0c41ec482070 added b | () draft o 7:125af0ed8cae added a | () draft | * 6:e83de241f751 added d | | () draft | * 5:e93a9161a274 added c | | () draft | x 2:b1661037fa25 added b | | () draft | x 1:c7586e2a9264 added a |/ () draft o 0:8fa14d15e168 added hgignore () draft $ hg evolve --abort 1 new orphan changesets evolve aborted working directory is now at 125af0ed8cae $ hg glog @ 7:125af0ed8cae added a | () draft | * 6:e83de241f751 added d | | () draft | * 5:e93a9161a274 added c | | () draft | * 2:b1661037fa25 added b | | () draft | x 1:c7586e2a9264 added a |/ () draft o 0:8fa14d15e168 added hgignore () draft $ cd .. Testing when evolved revs are on multiple branches ================================================== $ hg init repotwo $ cd repotwo $ echo ".*\.orig" > .hgignore $ hg add .hgignore $ hg ci -m "added hgignore" $ echo a > a $ hg ci -Aqm "added a" $ for ch in b c; do echo $ch > $ch; hg add $ch; hg ci -m "added "$ch; done; $ hg up .^^ 0 files updated, 0 files merged, 2 files removed, 0 files unresolved $ for ch in c d; do echo $ ch > $ch; hg add $ch; hg ci -m "added "$ch; done; created new head $ hg up .^^ 0 files updated, 0 files merged, 2 files removed, 0 files unresolved $ echo foo > a $ hg ci -m "foo to a" created new head $ hg glog @ 6:8f20d4390c21 foo to a | () draft | o 5:bcb1c47f8520 added d | | () draft | o 4:86d2603075a3 added c |/ () draft | o 3:17509928e5bf added c | | () draft | o 2:9f0c80a55ddc added b |/ () draft o 1:2f913b0c9220 added a | () draft o 0:8fa14d15e168 added hgignore () draft $ hg prev 1 files updated, 0 files merged, 0 files removed, 0 files unresolved [1] added a $ echo aa > a $ hg amend 5 new orphan changesets $ hg evolve --all move:[2] added b atop:[7] added a move:[4] added c atop:[7] added a move:[6] foo to a atop:[7] added a merging a warning: conflicts while merging a! (edit, then use 'hg resolve --mark') abort: fix conflicts and see `hg help evolve.interrupted` [255] $ hg glog o 9:7f8e8bd9f0b6 added c | () draft | o 8:db3b42ef4da7 added b |/ () draft @ 7:807e8e2ca559 added a | () draft | * 6:8f20d4390c21 foo to a | | () draft | | * 5:bcb1c47f8520 added d | | | () draft | | x 4:86d2603075a3 added c | |/ () draft | | * 3:17509928e5bf added c | | | () draft | | x 2:9f0c80a55ddc added b | |/ () draft | x 1:2f913b0c9220 added a |/ () draft o 0:8fa14d15e168 added hgignore () draft $ hg evolve --abort 2 new orphan changesets evolve aborted working directory is now at 807e8e2ca559 $ hg glog @ 7:807e8e2ca559 added a | () draft | * 6:8f20d4390c21 foo to a | | () draft | | * 5:bcb1c47f8520 added d | | | () draft | | * 4:86d2603075a3 added c | |/ () draft | | * 3:17509928e5bf added c | | | () draft | | * 2:9f0c80a55ddc added b | |/ () draft | x 1:2f913b0c9220 added a |/ () draft o 0:8fa14d15e168 added hgignore () draft $ hg status $ hg diff Testing when user created a new changesets on top of evolved revisions ====================================================================== $ hg evolve --all move:[2] added b atop:[7] added a move:[4] added c atop:[7] added a move:[6] foo to a atop:[7] added a merging a warning: conflicts while merging a! (edit, then use 'hg resolve --mark') abort: fix conflicts and see `hg help evolve.interrupted` [255] $ hg glog o 9:7f8e8bd9f0b6 added c | () draft | o 8:db3b42ef4da7 added b |/ () draft @ 7:807e8e2ca559 added a | () draft | * 6:8f20d4390c21 foo to a | | () draft | | * 5:bcb1c47f8520 added d | | | () draft | | x 4:86d2603075a3 added c | |/ () draft | | * 3:17509928e5bf added c | | | () draft | | x 2:9f0c80a55ddc added b | |/ () draft | x 1:2f913b0c9220 added a |/ () draft o 0:8fa14d15e168 added hgignore () draft $ echo foo > a $ hg resolve -m (no more unresolved files) continue: hg evolve --continue $ cd .. $ hg init clonerepo $ cd repotwo $ hg push ../clonerepo --force pushing to ../clonerepo searching for changes adding changesets adding manifests adding file changes added 10 changesets with 8 changes to 5 files (+4 heads) 3 new obsolescence markers 3 new orphan changesets $ cd ../clonerepo $ hg up 7f8e8bd9f0b6 3 files updated, 0 files merged, 0 files removed, 0 files unresolved $ echo bar > bar $ hg add bar $ hg ci -m "made an new commit on evolved rev" $ hg push ../repotwo --force pushing to ../repotwo searching for changes adding changesets adding manifests adding file changes added 1 changesets with 1 changes to 1 files $ cd ../repotwo $ hg evolve --abort warning: new changesets detected on destination branch abort: unable to abort interrupted evolve, use 'hg evolve --stop' to stop evolve [255] $ hg evolve --stop stopped the interrupted evolve working directory is now at 807e8e2ca559 Testing when the evolved revision turned public due to some other user actions ============================================================================== $ hg evolve --all move:[3] added c atop:[8] added b move:[5] added d atop:[9] added c move:[6] foo to a atop:[7] added a merging a warning: conflicts while merging a! (edit, then use 'hg resolve --mark') abort: fix conflicts and see `hg help evolve.interrupted` [255] $ hg glog o 12:1c476940790a added d | () draft | o 11:c10a55eb0cc6 added c | | () draft +---o 10:48eca1ed5478 made an new commit on evolved rev | | () draft o | 9:7f8e8bd9f0b6 added c | | () draft | o 8:db3b42ef4da7 added b |/ () draft @ 7:807e8e2ca559 added a | () draft | * 6:8f20d4390c21 foo to a | | () draft | x 1:2f913b0c9220 added a |/ () draft o 0:8fa14d15e168 added hgignore () draft $ hg phase -r 1c476940790a --public $ hg evolve --abort cannot clean up public changesets: 1c476940790a abort: unable to abort interrupted evolve, use 'hg evolve --stop' to stop evolve [255] $ hg evolve --stop stopped the interrupted evolve working directory is now at 807e8e2ca559 $ cd .. Testing that bookmark should be moved back when doing `hg evolve --abort` ========================================================================= $ hg init repothree $ cd repothree $ echo ".*\.orig" > .hgignore $ hg add .hgignore $ hg ci -m "added hgignore" $ for ch in a b c; do echo $ch > $ch; hg add $ch; hg ci -m "added "$ch; done; $ hg up .^ 0 files updated, 0 files merged, 1 files removed, 0 files unresolved $ hg bookmark bm1 $ hg up .^ 0 files updated, 0 files merged, 1 files removed, 0 files unresolved (leaving bookmark bm1) $ echo foo > c $ hg add c $ hg amend 2 new orphan changesets $ hg glog @ 4:a0086c17bfc7 added a | () draft | * 3:17509928e5bf added c | | () draft | * 2:9f0c80a55ddc added b | | (bm1) draft | x 1:2f913b0c9220 added a |/ () draft o 0:8fa14d15e168 added hgignore () draft $ hg evolve --all move:[2] added b atop:[4] added a move:[3] added c atop:[5] added b merging c warning: conflicts while merging c! (edit, then use 'hg resolve --mark') abort: fix conflicts and see `hg help evolve.interrupted` [255] $ hg glog @ 5:c1f4718020e3 added b | (bm1) draft o 4:a0086c17bfc7 added a | () draft | * 3:17509928e5bf added c | | () draft | x 2:9f0c80a55ddc added b | | () draft | x 1:2f913b0c9220 added a |/ () draft o 0:8fa14d15e168 added hgignore () draft $ hg evolve --abort 1 new orphan changesets evolve aborted working directory is now at a0086c17bfc7 $ hg glog @ 4:a0086c17bfc7 added a | () draft | * 3:17509928e5bf added c | | () draft | * 2:9f0c80a55ddc added b | | (bm1) draft | x 1:2f913b0c9220 added a |/ () draft o 0:8fa14d15e168 added hgignore () draft Testing `--abort` when conflicts are caused due to `hg next --evolve` ===================================================================== $ hg next --evolve move:[2] added b atop:[4] added a working directory now at c1f4718020e3 $ hg next --evolve move:[3] added c atop:[5] added b merging c warning: conflicts while merging c! (edit, then use 'hg resolve --mark') abort: fix conflicts and see `hg help evolve.interrupted` [255] $ hg evolve --abort evolve aborted working directory is now at c1f4718020e3