Mercurial > evolve
annotate tests/test-obsconvert.t @ 4687:313565dd75e3 stable
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.
author | Anton Shestakov <av6@dwimlabs.net> |
---|---|
date | Fri, 07 Jun 2019 18:14:48 +0800 |
parents | 945a0989e41b |
children | f5d472b7e800 |
rev | line source |
---|---|
1159
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
1 $ cat >> $HGRCPATH <<EOF |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
2 > [extensions] |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
3 > EOF |
1806
9f42f819267b
evolve: move the extensions to 'hgext3rd'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1187
diff
changeset
|
4 $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH |
1159
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
5 $ hg init alpha |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
6 $ cd alpha |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
7 $ echo foo > foo |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
8 $ hg addremove |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
9 adding foo |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
10 $ hg ci -m 'foo' |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
11 $ for x in 1 2 3 4 ; do |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
12 > echo foo $x > foo |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
13 > hg amend |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
14 > done |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
15 |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
16 Test conversion between obsolete marker formats |
1172
8d28bb4fc127
debugobsconvert: fix 6f08a8f6bb1d and add proper test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1170
diff
changeset
|
17 $ hg debugobsolete |
2581
ef5d556ec589
effectflag: activate effect flag on test-obsconvert.t test file
Boris Feld <boris.feld@octobus.net>
parents:
1806
diff
changeset
|
18 e63c23eaa88ae77967edcf4ea194d31167c478b0 b81ac6b9d2a55f9a7a6b90a006b1aab0568d6d34 0 (*) {'ef1': '*', 'user': 'test'} (glob) |
ef5d556ec589
effectflag: activate effect flag on test-obsconvert.t test file
Boris Feld <boris.feld@octobus.net>
parents:
1806
diff
changeset
|
19 b81ac6b9d2a55f9a7a6b90a006b1aab0568d6d34 384fc811182687231962e486f23ea8c5bab7a2d3 0 (*) {'ef1': '*', 'user': 'test'} (glob) |
ef5d556ec589
effectflag: activate effect flag on test-obsconvert.t test file
Boris Feld <boris.feld@octobus.net>
parents:
1806
diff
changeset
|
20 384fc811182687231962e486f23ea8c5bab7a2d3 949d379b3c3bf051906bc3528c049cb536e2ec86 0 (*) {'ef1': '*', 'user': 'test'} (glob) |
ef5d556ec589
effectflag: activate effect flag on test-obsconvert.t test file
Boris Feld <boris.feld@octobus.net>
parents:
1806
diff
changeset
|
21 949d379b3c3bf051906bc3528c049cb536e2ec86 f2e4c45b2a4a58ccf7ef6825b8fa5685873cd2f7 0 (*) {'ef1': '*', 'user': 'test'} (glob) |
1159
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
22 $ hg debugobsconvert --new-format 0 |
1170
4697f23e0ede
debugobsconvert: fix a typo on "version"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1159
diff
changeset
|
23 Old store is version 1, will rewrite in version 0 |
1159
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
24 Done! |
1172
8d28bb4fc127
debugobsconvert: fix 6f08a8f6bb1d and add proper test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1170
diff
changeset
|
25 $ hg debugobsolete |
2581
ef5d556ec589
effectflag: activate effect flag on test-obsconvert.t test file
Boris Feld <boris.feld@octobus.net>
parents:
1806
diff
changeset
|
26 e63c23eaa88ae77967edcf4ea194d31167c478b0 b81ac6b9d2a55f9a7a6b90a006b1aab0568d6d34 0 (*) {'ef1': '*', 'user': 'test'} (glob) |
ef5d556ec589
effectflag: activate effect flag on test-obsconvert.t test file
Boris Feld <boris.feld@octobus.net>
parents:
1806
diff
changeset
|
27 b81ac6b9d2a55f9a7a6b90a006b1aab0568d6d34 384fc811182687231962e486f23ea8c5bab7a2d3 0 (*) {'ef1': '*', 'user': 'test'} (glob) |
ef5d556ec589
effectflag: activate effect flag on test-obsconvert.t test file
Boris Feld <boris.feld@octobus.net>
parents:
1806
diff
changeset
|
28 384fc811182687231962e486f23ea8c5bab7a2d3 949d379b3c3bf051906bc3528c049cb536e2ec86 0 (*) {'ef1': '*', 'user': 'test'} (glob) |
ef5d556ec589
effectflag: activate effect flag on test-obsconvert.t test file
Boris Feld <boris.feld@octobus.net>
parents:
1806
diff
changeset
|
29 949d379b3c3bf051906bc3528c049cb536e2ec86 f2e4c45b2a4a58ccf7ef6825b8fa5685873cd2f7 0 (*) {'ef1': '*', 'user': 'test'} (glob) |
1159
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
30 $ hg debugobsconvert --new-format 0 |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
31 abort: New format is the same as the old format, not upgrading! |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
32 [255] |
1172
8d28bb4fc127
debugobsconvert: fix 6f08a8f6bb1d and add proper test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1170
diff
changeset
|
33 $ hg debugobsolete |
2581
ef5d556ec589
effectflag: activate effect flag on test-obsconvert.t test file
Boris Feld <boris.feld@octobus.net>
parents:
1806
diff
changeset
|
34 e63c23eaa88ae77967edcf4ea194d31167c478b0 b81ac6b9d2a55f9a7a6b90a006b1aab0568d6d34 0 (*) {'ef1': '*', 'user': 'test'} (glob) |
ef5d556ec589
effectflag: activate effect flag on test-obsconvert.t test file
Boris Feld <boris.feld@octobus.net>
parents:
1806
diff
changeset
|
35 b81ac6b9d2a55f9a7a6b90a006b1aab0568d6d34 384fc811182687231962e486f23ea8c5bab7a2d3 0 (*) {'ef1': '*', 'user': 'test'} (glob) |
ef5d556ec589
effectflag: activate effect flag on test-obsconvert.t test file
Boris Feld <boris.feld@octobus.net>
parents:
1806
diff
changeset
|
36 384fc811182687231962e486f23ea8c5bab7a2d3 949d379b3c3bf051906bc3528c049cb536e2ec86 0 (*) {'ef1': '*', 'user': 'test'} (glob) |
ef5d556ec589
effectflag: activate effect flag on test-obsconvert.t test file
Boris Feld <boris.feld@octobus.net>
parents:
1806
diff
changeset
|
37 949d379b3c3bf051906bc3528c049cb536e2ec86 f2e4c45b2a4a58ccf7ef6825b8fa5685873cd2f7 0 (*) {'ef1': '*', 'user': 'test'} (glob) |
1159
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
38 $ hg debugobsconvert --new-format 1 |
1170
4697f23e0ede
debugobsconvert: fix a typo on "version"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1159
diff
changeset
|
39 Old store is version 0, will rewrite in version 1 |
1159
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
40 Done! |
1172
8d28bb4fc127
debugobsconvert: fix 6f08a8f6bb1d and add proper test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1170
diff
changeset
|
41 $ hg debugobsolete |
2581
ef5d556ec589
effectflag: activate effect flag on test-obsconvert.t test file
Boris Feld <boris.feld@octobus.net>
parents:
1806
diff
changeset
|
42 e63c23eaa88ae77967edcf4ea194d31167c478b0 b81ac6b9d2a55f9a7a6b90a006b1aab0568d6d34 0 (*) {'ef1': '*', 'user': 'test'} (glob) |
ef5d556ec589
effectflag: activate effect flag on test-obsconvert.t test file
Boris Feld <boris.feld@octobus.net>
parents:
1806
diff
changeset
|
43 b81ac6b9d2a55f9a7a6b90a006b1aab0568d6d34 384fc811182687231962e486f23ea8c5bab7a2d3 0 (*) {'ef1': '*', 'user': 'test'} (glob) |
ef5d556ec589
effectflag: activate effect flag on test-obsconvert.t test file
Boris Feld <boris.feld@octobus.net>
parents:
1806
diff
changeset
|
44 384fc811182687231962e486f23ea8c5bab7a2d3 949d379b3c3bf051906bc3528c049cb536e2ec86 0 (*) {'ef1': '*', 'user': 'test'} (glob) |
ef5d556ec589
effectflag: activate effect flag on test-obsconvert.t test file
Boris Feld <boris.feld@octobus.net>
parents:
1806
diff
changeset
|
45 949d379b3c3bf051906bc3528c049cb536e2ec86 f2e4c45b2a4a58ccf7ef6825b8fa5685873cd2f7 0 (*) {'ef1': '*', 'user': 'test'} (glob) |
1159
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
46 |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
47 Test that the default is some reasonably modern format (first downgrade) |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
48 $ hg debugobsconvert --new-format 0 |
1170
4697f23e0ede
debugobsconvert: fix a typo on "version"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1159
diff
changeset
|
49 Old store is version 1, will rewrite in version 0 |
1159
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
50 Done! |
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
51 $ hg debugobsconvert |
1170
4697f23e0ede
debugobsconvert: fix a typo on "version"
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1159
diff
changeset
|
52 Old store is version 0, will rewrite in version 1 |
1159
04bd66779a1f
obsup: hack extension to make in-place upgrading of obsolete markers easy
Augie Fackler <raf@durin42.com>
parents:
diff
changeset
|
53 Done! |
1172
8d28bb4fc127
debugobsconvert: fix 6f08a8f6bb1d and add proper test
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1170
diff
changeset
|
54 $ hg debugobsolete |
2581
ef5d556ec589
effectflag: activate effect flag on test-obsconvert.t test file
Boris Feld <boris.feld@octobus.net>
parents:
1806
diff
changeset
|
55 e63c23eaa88ae77967edcf4ea194d31167c478b0 b81ac6b9d2a55f9a7a6b90a006b1aab0568d6d34 0 (*) {'ef1': '*', 'user': 'test'} (glob) |
ef5d556ec589
effectflag: activate effect flag on test-obsconvert.t test file
Boris Feld <boris.feld@octobus.net>
parents:
1806
diff
changeset
|
56 b81ac6b9d2a55f9a7a6b90a006b1aab0568d6d34 384fc811182687231962e486f23ea8c5bab7a2d3 0 (*) {'ef1': '*', 'user': 'test'} (glob) |
ef5d556ec589
effectflag: activate effect flag on test-obsconvert.t test file
Boris Feld <boris.feld@octobus.net>
parents:
1806
diff
changeset
|
57 384fc811182687231962e486f23ea8c5bab7a2d3 949d379b3c3bf051906bc3528c049cb536e2ec86 0 (*) {'ef1': '*', 'user': 'test'} (glob) |
ef5d556ec589
effectflag: activate effect flag on test-obsconvert.t test file
Boris Feld <boris.feld@octobus.net>
parents:
1806
diff
changeset
|
58 949d379b3c3bf051906bc3528c049cb536e2ec86 f2e4c45b2a4a58ccf7ef6825b8fa5685873cd2f7 0 (*) {'ef1': '*', 'user': 'test'} (glob) |