Mercurial > evolve
view tests/test-metaedit.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 | cfe31185ad07 |
children | 98941c28f3e2 77bf84025dd5 |
line wrap: on
line source
$ cat >> $HGRCPATH <<EOF > [defaults] > amend=-d "0 0" > fold=-d "0 0" > metaedit=-d "0 0" > [web] > push_ssl = false > allow_push = * > [phases] > publish = False > [alias] > qlog = log --template='{rev} - {node|short} {desc} ({phase})\n' > [diff] > git = 1 > unified = 0 > [extensions] > EOF $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH $ mkcommit() { > echo "$1" > "$1" > hg add "$1" > hg ci -m "$1" > } $ mkstack() { > # Creates a stack of commit based on $1 with messages from $2, $3 .. > hg update $1 -C > shift > mkcommits $* > } $ glog() { > hg log -G --template '{rev}:{node|short}@{branch}({phase}) {desc|firstline}\n' "$@" > } $ shaof() { > hg log -T {node} -r "first(desc($1))" > } $ mkcommits() { > for i in $@; do mkcommit $i ; done > } ########################## importing Parren test ########################## $ cat << EOF >> $HGRCPATH > [ui] > logtemplate = "{rev}\t{bookmarks}: {desc|firstline} - {author|user}\n" > EOF HG METAEDIT =============================== Setup the Base Repo ------------------- We start with a plain base repo:: $ hg init $TESTTMP/metaedit; cd $TESTTMP/metaedit $ mkcommit "ROOT" $ hg phase --public "desc(ROOT)" $ mkcommit "A" $ mkcommit "B" $ hg up "desc(A)" 0 files updated, 0 files merged, 1 files removed, 0 files unresolved $ mkcommit "C" created new head $ mkcommit "D" $ echo "D'" > D $ hg amend -m "D2" $ hg up "desc(C)" 0 files updated, 0 files merged, 1 files removed, 0 files unresolved $ mkcommit "E" created new head $ mkcommit "F" Test ---- $ hg log -G @ 7 : F - test | o 6 : E - test | | o 5 : D2 - test |/ o 3 : C - test | | o 2 : B - test |/ o 1 : A - test | o 0 : ROOT - test $ hg update --clean . 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg metaedit -r 0 abort: cannot edit commit information for public revisions [255] $ hg metaedit --fold abort: revisions must be specified with --fold [255] $ hg metaedit -r 0 --fold abort: cannot fold public changesets: ea207398892e (see 'hg help phases' for details) [255] $ hg metaedit 'desc(C) + desc(F)' --fold abort: cannot fold non-linear revisions (multiple roots given) [255] $ hg metaedit "desc(C)::desc(D2) + desc(E)" --fold abort: cannot fold non-linear revisions (multiple heads given) [255] check that metaedit respects allowunstable $ hg metaedit '.^' --config 'experimental.evolution=createmarkers, allnewcommands' abort: cannot edit commit information in the middle of a stack (587528abfffe will become unstable and new unstable changes are not allowed) [255] $ hg metaedit 'desc(A)::desc(B)' --fold --config 'experimental.evolution=createmarkers, allnewcommands' abort: fold will orphan 4 descendants (see 'hg help evolution.instability') [255] $ hg metaedit --user foobar 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg log --template '{rev}: {author}\n' -r 'desc(F):' --hidden 7: test 8: foobar $ hg log --template '{rev}: {author}\n' -r . 8: foobar TODO: support this $ hg metaedit '.^::.' abort: editing multiple revisions without --fold is not currently supported [255] $ HGEDITOR=cat hg metaedit '.^::.' --fold --note 'folding changesets using metaedit, > and newlines' abort: note cannot contain a newline [255] $ HGEDITOR=cat hg metaedit '.^::.' --fold --note "folding changesets using metaedit" HG: This is a fold of 2 changesets. HG: Commit message of changeset 6. E HG: Commit message of changeset 8. F HG: Enter commit message. Lines beginning with 'HG:' are removed. HG: Leave message empty to abort commit. HG: -- HG: user: test HG: branch 'default' HG: added E HG: added F 2 changesets folded 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ glog -r . @ 9:a08d35fd7d9d@default(draft) E | ~ $ hg obslog -r . @ a08d35fd7d9d (9) E |\ x | 212b2a2b87cd (8) F | | rewritten(description, user, parent, content) as a08d35fd7d9d using metaedit by test (Thu Jan 01 00:00:00 1970 +0000) | | note: folding changesets using metaedit | | | x c2bd843aa246 (6) E | rewritten(description, content) as a08d35fd7d9d using metaedit by test (Thu Jan 01 00:00:00 1970 +0000) | note: folding changesets using metaedit | x 587528abfffe (7) F rewritten(user) as 212b2a2b87cd using metaedit by test (Thu Jan 01 00:00:00 1970 +0000) no new commit is created here because the date is the same $ HGEDITOR=cat hg metaedit E F HG: Enter commit message. Lines beginning with 'HG:' are removed. HG: Leave message empty to abort commit. HG: -- HG: user: test HG: branch 'default' HG: added E HG: added F nothing changed $ glog -r '.^::.' @ 9:a08d35fd7d9d@default(draft) E | o 3:3260958f1169@default(draft) C | ~ TODO: don't create a new commit in this case, we should take the date of the old commit (we add a default date with a value to show that metaedit is taking the current date to generate the hash, this way we still have a stable hash but highlight the bug) $ hg metaedit --config defaults.metaedit= --config devel.default-date="42 0" 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ hg log -r '.^::.' --template '{rev}: {desc|firstline}\n' 3: C 10: E $ hg up .^ 0 files updated, 0 files merged, 2 files removed, 0 files unresolved $ hg metaedit --user foobar2 tip $ hg log --template '{rev}: {author}\n' -r "user(foobar):" --hidden 8: foobar 9: test 10: test 11: foobar2 $ hg diff -r "10" -r "11" --hidden 'fold' one commit $ HGUSER=foobar3 hg metaedit "desc(D2)" --fold -U 1 changesets folded $ hg log -r "tip" --template '{rev}: {author}\n' 12: foobar3