pick: remove transaction on the whole command (issue6037)
At its core, pick is a pretty straightforward and well-behaving command, it
uses functions already in core hg, it checks that wdir is clean and that
changeset to pick is not public, it checks if there happen to be merge
conflicts and can be --continue'd later, etc.
It is very similar to graft in core (it also uses mergemod.graft function), but
it obsoletes the original changeset. However, graft does not experience this
incorrect behavior from issue 6037.
What happens in the test case for this issue when we pick a revision that
touches both "a" and "b": mergemod.graft() takes the original changeset and
tries to apply it to the wdir, which results in "b" being marked as newly added
and ready to be committed, "a" updated with the new content and being marked as
modified, but "a" also has conflicts. Pick correctly notices this and saves its
state before asking for user intervention. So far so good. However, when the
command raises InterventionRequired to print a user-facing message and exit
while being wrapped in repo.transaction() context manager, the latter partially
undoes what mergemod.graft() did: it unmarks "b" as added. And when user
continues pick, "b" is therefore not tracked and is not included in the
resulting commit.
The transaction is not useful here, because it doesn't touch wdir (it's still
dirty), it doesn't remove pickstate (and other commands will refuse to work
until pick --abort or --continue), it just makes "b" untracked.
The solution is to use repo.transaction() only to wrap code that writes data to
hg store in the final stages of the command after all checks have passed and is
not expected to fail on trivial cases like merge conflicts. For example,
committing the picked changeset. But since pick uses repo.commit() for that,
and because that function already uses a transaction, wrapping it in another
transaction doesn't make sense.
============================================
Testing obsolescence markers push: Cases A.4
============================================
Mercurial pushes obsolescences markers relevant to the "pushed-set", the set of
all changesets that requested to be "in sync" after the push (even if they are
already on both side).
This test belongs to a series of tests checking such set is properly computed
and applied. this does not tests "obsmarkers" discovery capabilities.
Category A: simple cases
Testcase 4: Push in the middle of the obsolescence chain
A.4 Push in the middle of the obsolescence chain
================================================
.. (Where we show that we should not push the marker without the successors)
..
.. {{{
.. B ◔
.. |
.. A⇠ø⇠○ A'
.. |/
.. ● O
.. }}}
..
.. Markers exist from:
..
.. * `A ø⇠○ A'`
.. * chain from A
..
.. Command runs:
..
.. * hg push -r B
..
.. Expected exchange:
..
.. * Chain from A
..
.. Expected Exclude:
..
.. * `Ai ø⇠○ A'`
Setup
-----
$ . $TESTDIR/testlib/exchange-obsmarker-util.sh
initial
$ setuprepos A.4
creating test repo for test case A.4
- pulldest
- main
- pushdest
cd into `main` and proceed with env setup
$ cd main
$ mkcommit A0
$ mkcommit B
$ hg update 0
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
$ mkcommit A1
created new head
$ hg debugobsolete aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa `getid 'desc(A0)'`
$ hg debugobsolete `getid 'desc(A0)'` `getid 'desc(A1)'`
obsoleted 1 changesets
1 new orphan changesets
$ hg log -G --hidden
@ e5ea8f9c7314 (draft): A1
|
| * 06055a7959d4 (draft): B
| |
| x 28b51eb45704 (draft): A0
|/
o a9bdc8b26820 (public): O
$ inspect_obsmarkers
obsstore content
================
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 28b51eb45704506b5c603decd6bf7ac5e0f6a52f 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
28b51eb45704506b5c603decd6bf7ac5e0f6a52f e5ea8f9c73143125d36658e90ef70c6d2027a5b7 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
obshashtree
===========
a9bdc8b26820b1b87d585b82eb0ceb4a2ecdbc04 0000000000000000000000000000000000000000
28b51eb45704506b5c603decd6bf7ac5e0f6a52f 5d69322fad9eb1ba8f8f2c2312346ed347fdde76
06055a7959d4128e6e3bccfd01482e83a2db8a3a fd3e5712c9c2d216547d7a1b87ac815ee1fb7542
e5ea8f9c73143125d36658e90ef70c6d2027a5b7 cf518031fa753e9b049d727e6b0e19f645bab38f
obshashrange
============
rev node index size depth obshash
2 06055a7959d4 0 3 3 000000000000
1 28b51eb45704 0 2 2 5d69322fad9e
3 e5ea8f9c7314 0 2 2 cf518031fa75
2 06055a7959d4 2 1 3 000000000000
1 28b51eb45704 1 1 2 5d69322fad9e
0 a9bdc8b26820 0 1 1 000000000000
3 e5ea8f9c7314 1 1 2 cf518031fa75
$ cd ..
$ cd ..
Actual Test for first version
-----------------------------
$ dotest A.4 B -f
## Running testcase A.4
# testing echange of "B" (06055a7959d4)
## initial state
# obstore: main
28b51eb45704506b5c603decd6bf7ac5e0f6a52f e5ea8f9c73143125d36658e90ef70c6d2027a5b7 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 28b51eb45704506b5c603decd6bf7ac5e0f6a52f 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
# obstore: pushdest
# obstore: pulldest
## pushing "B" from main to pushdest
pushing to pushdest
searching for changes
remote: adding changesets
remote: adding manifests
remote: adding file changes
remote: added 2 changesets with 2 changes to 2 files
remote: 1 new obsolescence markers
## post push state
# obstore: main
28b51eb45704506b5c603decd6bf7ac5e0f6a52f e5ea8f9c73143125d36658e90ef70c6d2027a5b7 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 28b51eb45704506b5c603decd6bf7ac5e0f6a52f 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
# obstore: pushdest
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 28b51eb45704506b5c603decd6bf7ac5e0f6a52f 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
# obstore: pulldest
## pulling "06055a7959d4" from main into pulldest
pulling from main
searching for changes
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files
1 new obsolescence markers
new changesets 28b51eb45704:06055a7959d4 (2 drafts)
(run 'hg update' to get a working copy)
## post pull state
# obstore: main
28b51eb45704506b5c603decd6bf7ac5e0f6a52f e5ea8f9c73143125d36658e90ef70c6d2027a5b7 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 28b51eb45704506b5c603decd6bf7ac5e0f6a52f 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
# obstore: pushdest
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 28b51eb45704506b5c603decd6bf7ac5e0f6a52f 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
# obstore: pulldest
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 28b51eb45704506b5c603decd6bf7ac5e0f6a52f 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}