Mercurial > evolve
annotate tests/test-import.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 | 9f42f819267b |
children | 995ed7aac8a6 |
rev | line source |
---|---|
930
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
1 |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
2 This feature requires mercurial 3.0 |
984
b286f77d680c
tests: fix grammar, spelling, punctuation in comments
Greg Ward <greg@gerg.ca>
parents:
951
diff
changeset
|
3 (and the `only()` revset is 3.0 specific) |
930
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
4 |
951
e3f7258d05d5
test: fix test-import condition
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
930
diff
changeset
|
5 $ (hg help revset | grep '"only(' > /dev/null) || exit 80 |
930
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
6 |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
7 Test creation of obsolescence marker by path import |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
8 |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
9 $ hg init auto-obsolete |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
10 $ cd auto-obsolete |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
11 $ echo '[extensions]' >> $HGRCPATH |
1806
9f42f819267b
evolve: move the extensions to 'hgext3rd'
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
1185
diff
changeset
|
12 $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext3rd/evolve/" >> $HGRCPATH |
930
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
13 $ echo A > a |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
14 $ hg commit -Am A |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
15 adding a |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
16 $ echo B > b |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
17 $ hg commit -Am B |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
18 adding b |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
19 $ hg up '.^' |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
20 0 files updated, 0 files merged, 1 files removed, 0 files unresolved |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
21 $ echo C > c |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
22 $ hg commit -Am C |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
23 adding c |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
24 created new head |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
25 $ hg log -G |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
26 @ changeset: 2:eb8dd0f31b51 |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
27 | tag: tip |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
28 | parent: 0:f2bbf19cf96d |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
29 | user: test |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
30 | date: Thu Jan 01 00:00:00 1970 +0000 |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
31 | summary: C |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
32 | |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
33 | o changeset: 1:95b760afef3c |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
34 |/ user: test |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
35 | date: Thu Jan 01 00:00:00 1970 +0000 |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
36 | summary: B |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
37 | |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
38 o changeset: 0:f2bbf19cf96d |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
39 user: test |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
40 date: Thu Jan 01 00:00:00 1970 +0000 |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
41 summary: A |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
42 |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
43 |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
44 (actual test) |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
45 |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
46 $ hg export 'desc(B)' | hg import - --obsolete |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
47 applying patch from stdin |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
48 $ hg log -G |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
49 @ changeset: 3:00c49133f17e |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
50 | tag: tip |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
51 | user: test |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
52 | date: Thu Jan 01 00:00:00 1970 +0000 |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
53 | summary: B |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
54 | |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
55 o changeset: 2:eb8dd0f31b51 |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
56 | parent: 0:f2bbf19cf96d |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
57 | user: test |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
58 | date: Thu Jan 01 00:00:00 1970 +0000 |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
59 | summary: C |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
60 | |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
61 o changeset: 0:f2bbf19cf96d |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
62 user: test |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
63 date: Thu Jan 01 00:00:00 1970 +0000 |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
64 summary: A |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
65 |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
66 $ hg debugobsolete |
1065
f355bbc124fc
test: update test to new date formatting in debuobsolete output
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
984
diff
changeset
|
67 95b760afef3c234ffb3f9fd391edcb36e60921a4 00c49133f17e5e5a52b6ef1b6d516c0e90b56d8a 0 (*) {'user': 'test'} (glob) |
930
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
68 |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
69 $ hg rollback |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
70 repository tip rolled back to revision 2 (undo import) |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
71 working directory now based on revision 2 |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
72 $ hg log -G |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
73 @ changeset: 2:eb8dd0f31b51 |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
74 | tag: tip |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
75 | parent: 0:f2bbf19cf96d |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
76 | user: test |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
77 | date: Thu Jan 01 00:00:00 1970 +0000 |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
78 | summary: C |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
79 | |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
80 | o changeset: 1:95b760afef3c |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
81 |/ user: test |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
82 | date: Thu Jan 01 00:00:00 1970 +0000 |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
83 | summary: B |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
84 | |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
85 o changeset: 0:f2bbf19cf96d |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
86 user: test |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
87 date: Thu Jan 01 00:00:00 1970 +0000 |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
88 summary: A |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
89 |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
90 $ hg debugobsolete |
cac35bef8aee
import: --obsolete flag for automatic obsolescence marker creation
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
diff
changeset
|
91 |