Show More
@@ -1,263 +1,264 | |||||
1 | ======================================================================= |
|
1 | ======================================================================= | |
2 | Check potential race condition around transaction and working copy data |
|
2 | Check potential race condition around transaction and working copy data | |
3 | ======================================================================= |
|
3 | ======================================================================= | |
4 |
|
4 | |||
5 | #testcases bookmarks-in-store bookmarks-wc-level |
|
5 | #testcases bookmarks-in-store bookmarks-wc-level | |
6 |
|
6 | |||
7 | The transaction is garanteed to run with the lock, but may runs without the |
|
7 | The transaction is garanteed to run with the lock, but may runs without the | |
8 | wlock. So if the transaction backup/restore some content related to the |
|
8 | wlock. So if the transaction backup/restore some content related to the | |
9 | working-copy and protected by the wlock, we might run into trouble if another |
|
9 | working-copy and protected by the wlock, we might run into trouble if another | |
10 | process grab the wlock and modify them. |
|
10 | process grab the wlock and modify them. | |
11 |
|
11 | |||
12 | This test file is testing various cases where such parallel changes happens to |
|
12 | This test file is testing various cases where such parallel changes happens to | |
13 | validate the transaction behavior. |
|
13 | validate the transaction behavior. | |
14 |
|
14 | |||
15 | Other is used to get a simple pull source. As pull is a simple way to create |
|
15 | Other is used to get a simple pull source. As pull is a simple way to create | |
16 | transaction without the wlock. |
|
16 | transaction without the wlock. | |
17 |
|
17 | |||
18 | Setup |
|
18 | Setup | |
19 | ===== |
|
19 | ===== | |
20 |
|
20 | |||
21 | Avoid long deadlock |
|
21 | Avoid long deadlock | |
22 |
|
22 | |||
23 | $ cat << EOF >> $HGRCPATH |
|
23 | $ cat << EOF >> $HGRCPATH | |
24 | > [ui] |
|
24 | > [ui] | |
25 | > timeout=10 |
|
25 | > timeout=10 | |
26 | > EOF |
|
26 | > EOF | |
27 |
|
27 | |||
28 | #if bookmarks-in-store |
|
28 | #if bookmarks-in-store | |
29 | $ cat << EOF >> $HGRCPATH |
|
29 | $ cat << EOF >> $HGRCPATH | |
30 | > [format] |
|
30 | > [format] | |
31 | > bookmarks-in-store = yes |
|
31 | > bookmarks-in-store = yes | |
32 | > EOF |
|
32 | > EOF | |
33 | #endif |
|
33 | #endif | |
34 |
|
34 | |||
35 |
|
35 | |||
36 | $ hg init repo |
|
36 | $ hg init repo | |
37 | $ cd repo |
|
37 | $ cd repo | |
38 | $ for filename in a b c d e f g h i j k l m; do |
|
38 | $ for filename in a b c d e f g h i j k l m; do | |
39 | > echo $filename > default_$filename |
|
39 | > echo $filename > default_$filename | |
40 | > hg add default_$filename |
|
40 | > hg add default_$filename | |
41 | > hg commit --quiet --message default_$filename |
|
41 | > hg commit --quiet --message default_$filename | |
42 | > done |
|
42 | > done | |
43 | $ hg bookmark --rev . foo |
|
43 | $ hg bookmark --rev . foo | |
44 | $ hg branch babar |
|
44 | $ hg branch babar | |
45 | marked working directory as branch babar |
|
45 | marked working directory as branch babar | |
46 | (branches are permanent and global, did you want a bookmark?) |
|
46 | (branches are permanent and global, did you want a bookmark?) | |
47 | $ for filename in a b c d e f g h i j k l m; do |
|
47 | $ for filename in a b c d e f g h i j k l m; do | |
48 | > echo $filename > babar_$filename |
|
48 | > echo $filename > babar_$filename | |
49 | > hg add babar_$filename |
|
49 | > hg add babar_$filename | |
50 | > hg commit --quiet --message babar_$filename |
|
50 | > hg commit --quiet --message babar_$filename | |
51 | > done |
|
51 | > done | |
52 | $ hg bookmark --rev . bar |
|
52 | $ hg bookmark --rev . bar | |
53 | $ hg up 'desc("default_m")' |
|
53 | $ hg up 'desc("default_m")' | |
54 | 0 files updated, 0 files merged, 13 files removed, 0 files unresolved |
|
54 | 0 files updated, 0 files merged, 13 files removed, 0 files unresolved | |
55 | $ hg log -G -T '[{branch}] ({bookmarks}) {desc}\n' |
|
55 | $ hg log -G -T '[{branch}] ({bookmarks}) {desc}\n' | |
56 | o [babar] (bar) babar_m |
|
56 | o [babar] (bar) babar_m | |
57 | | |
|
57 | | | |
58 | o [babar] () babar_l |
|
58 | o [babar] () babar_l | |
59 | | |
|
59 | | | |
60 | o [babar] () babar_k |
|
60 | o [babar] () babar_k | |
61 | | |
|
61 | | | |
62 | o [babar] () babar_j |
|
62 | o [babar] () babar_j | |
63 | | |
|
63 | | | |
64 | o [babar] () babar_i |
|
64 | o [babar] () babar_i | |
65 | | |
|
65 | | | |
66 | o [babar] () babar_h |
|
66 | o [babar] () babar_h | |
67 | | |
|
67 | | | |
68 | o [babar] () babar_g |
|
68 | o [babar] () babar_g | |
69 | | |
|
69 | | | |
70 | o [babar] () babar_f |
|
70 | o [babar] () babar_f | |
71 | | |
|
71 | | | |
72 | o [babar] () babar_e |
|
72 | o [babar] () babar_e | |
73 | | |
|
73 | | | |
74 | o [babar] () babar_d |
|
74 | o [babar] () babar_d | |
75 | | |
|
75 | | | |
76 | o [babar] () babar_c |
|
76 | o [babar] () babar_c | |
77 | | |
|
77 | | | |
78 | o [babar] () babar_b |
|
78 | o [babar] () babar_b | |
79 | | |
|
79 | | | |
80 | o [babar] () babar_a |
|
80 | o [babar] () babar_a | |
81 | | |
|
81 | | | |
82 | @ [default] (foo) default_m |
|
82 | @ [default] (foo) default_m | |
83 | | |
|
83 | | | |
84 | o [default] () default_l |
|
84 | o [default] () default_l | |
85 | | |
|
85 | | | |
86 | o [default] () default_k |
|
86 | o [default] () default_k | |
87 | | |
|
87 | | | |
88 | o [default] () default_j |
|
88 | o [default] () default_j | |
89 | | |
|
89 | | | |
90 | o [default] () default_i |
|
90 | o [default] () default_i | |
91 | | |
|
91 | | | |
92 | o [default] () default_h |
|
92 | o [default] () default_h | |
93 | | |
|
93 | | | |
94 | o [default] () default_g |
|
94 | o [default] () default_g | |
95 | | |
|
95 | | | |
96 | o [default] () default_f |
|
96 | o [default] () default_f | |
97 | | |
|
97 | | | |
98 | o [default] () default_e |
|
98 | o [default] () default_e | |
99 | | |
|
99 | | | |
100 | o [default] () default_d |
|
100 | o [default] () default_d | |
101 | | |
|
101 | | | |
102 | o [default] () default_c |
|
102 | o [default] () default_c | |
103 | | |
|
103 | | | |
104 | o [default] () default_b |
|
104 | o [default] () default_b | |
105 | | |
|
105 | | | |
106 | o [default] () default_a |
|
106 | o [default] () default_a | |
107 |
|
107 | |||
108 |
|
108 | |||
109 | $ cat << EOF >> ../txn-close.sh |
|
109 | $ cat << EOF >> ../txn-close.sh | |
110 |
> rm -f |
|
110 | > rm -f "$TESTTMP/transaction-continue" | |
111 |
> $RUNTESTDIR/testlib/wait-on-file 5 |
|
111 | > "$RUNTESTDIR/testlib/wait-on-file" 5 "$TESTTMP/transaction-continue" "$TESTTMP/transaction-waiting" | |
112 |
> rm -f |
|
112 | > rm -f "$TESTTMP/transaction-waiting" | |
113 | > exit 1 |
|
113 | > exit 1 | |
114 | > EOF |
|
114 | > EOF | |
|
115 | ||||
115 | $ cat << EOF >> .hg/hgrc |
|
116 | $ cat << EOF >> .hg/hgrc | |
116 | > [hooks] |
|
117 | > [hooks] | |
117 |
> pretxnclose.test = sh |
|
118 | > pretxnclose.test = sh "$TESTTMP/txn-close.sh" | |
118 | > EOF |
|
119 | > EOF | |
119 |
|
120 | |||
120 | Check the overall logic is working, the transaction is holding the `lock` , but |
|
121 | Check the overall logic is working, the transaction is holding the `lock` , but | |
121 | not the `wlock`, then get aborted on a signal-file. |
|
122 | not the `wlock`, then get aborted on a signal-file. | |
122 |
|
123 | |||
123 | $ hg phase --rev 0 |
|
124 | $ hg phase --rev 0 | |
124 | 0: draft |
|
125 | 0: draft | |
125 | $ hg phase --public --rev 0 2> ../log.err & |
|
126 | $ hg phase --public --rev 0 2> ../log.err & | |
126 | $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/transaction-waiting |
|
127 | $ $RUNTESTDIR/testlib/wait-on-file 5 $TESTTMP/transaction-waiting | |
127 | $ echo y | hg --config ui.interactive=yes debuglock --set-wlock |
|
128 | $ echo y | hg --config ui.interactive=yes debuglock --set-wlock | |
128 | ready to release the lock (y)? y |
|
129 | ready to release the lock (y)? y | |
129 | $ echo y | hg --config ui.interactive=yes debuglock --set-lock |
|
130 | $ echo y | hg --config ui.interactive=yes debuglock --set-lock | |
130 | abort: lock is already held |
|
131 | abort: lock is already held | |
131 | [255] |
|
132 | [255] | |
132 |
$ touch |
|
133 | $ touch "$TESTTMP/transaction-continue" | |
133 | $ wait |
|
134 | $ wait | |
134 | $ hg phase --rev 0 |
|
135 | $ hg phase --rev 0 | |
135 | 0: draft |
|
136 | 0: draft | |
136 | $ cat ../log.err |
|
137 | $ cat ../log.err | |
137 | abort: pretxnclose.test hook exited with status 1 |
|
138 | abort: pretxnclose.test hook exited with status 1 | |
138 |
|
139 | |||
139 | Actual testing |
|
140 | Actual testing | |
140 | ============== |
|
141 | ============== | |
141 |
|
142 | |||
142 | Changing tracked file |
|
143 | Changing tracked file | |
143 | --------------------- |
|
144 | --------------------- | |
144 |
|
145 | |||
145 | $ hg status |
|
146 | $ hg status | |
146 | $ hg phase --public --rev 0 2> ../log.err & |
|
147 | $ hg phase --public --rev 0 2> ../log.err & | |
147 |
$ |
|
148 | $ "$RUNTESTDIR/testlib/wait-on-file" 5 "$TESTTMP/transaction-waiting" | |
148 | $ hg forget default_a |
|
149 | $ hg forget default_a | |
149 | $ hg status |
|
150 | $ hg status | |
150 | R default_a |
|
151 | R default_a | |
151 |
$ touch |
|
152 | $ touch "$TESTTMP/transaction-continue" | |
152 | $ wait |
|
153 | $ wait | |
153 | $ hg status |
|
154 | $ hg status | |
154 | R default_a |
|
155 | R default_a | |
155 | $ hg revert --all --quiet |
|
156 | $ hg revert --all --quiet | |
156 |
|
157 | |||
157 | Changing branch from default |
|
158 | Changing branch from default | |
158 | ---------------------------- |
|
159 | ---------------------------- | |
159 |
|
160 | |||
160 | $ hg branch |
|
161 | $ hg branch | |
161 | default |
|
162 | default | |
162 | $ hg phase --public --rev 0 2> ../log.err & |
|
163 | $ hg phase --public --rev 0 2> ../log.err & | |
163 |
$ |
|
164 | $ "$RUNTESTDIR/testlib/wait-on-file" 5 "$TESTTMP/transaction-waiting" | |
164 | $ hg branch celeste |
|
165 | $ hg branch celeste | |
165 | marked working directory as branch celeste |
|
166 | marked working directory as branch celeste | |
166 | $ hg branch |
|
167 | $ hg branch | |
167 | celeste |
|
168 | celeste | |
168 |
$ touch |
|
169 | $ touch "$TESTTMP/transaction-continue" | |
169 | $ wait |
|
170 | $ wait | |
170 | $ hg branch |
|
171 | $ hg branch | |
171 | celeste |
|
172 | celeste | |
172 |
|
173 | |||
173 | Changing branch from another one |
|
174 | Changing branch from another one | |
174 | -------------------------------- |
|
175 | -------------------------------- | |
175 |
|
176 | |||
176 | $ hg up babar --quiet |
|
177 | $ hg up babar --quiet | |
177 | $ hg branch |
|
178 | $ hg branch | |
178 | babar |
|
179 | babar | |
179 | $ hg phase --public --rev 0 2> ../log.err & |
|
180 | $ hg phase --public --rev 0 2> ../log.err & | |
180 |
$ |
|
181 | $ "$RUNTESTDIR/testlib/wait-on-file" 5 "$TESTTMP/transaction-waiting" | |
181 | $ hg branch celeste |
|
182 | $ hg branch celeste | |
182 | marked working directory as branch celeste |
|
183 | marked working directory as branch celeste | |
183 | $ hg branch |
|
184 | $ hg branch | |
184 | celeste |
|
185 | celeste | |
185 |
$ touch |
|
186 | $ touch "$TESTTMP/transaction-continue" | |
186 | $ wait |
|
187 | $ wait | |
187 | $ hg branch |
|
188 | $ hg branch | |
188 | celeste |
|
189 | celeste | |
189 |
|
190 | |||
190 | updating working copy |
|
191 | updating working copy | |
191 | --------------------- |
|
192 | --------------------- | |
192 |
|
193 | |||
193 | $ hg st |
|
194 | $ hg st | |
194 | $ hg log --rev . -T '{desc}\n' |
|
195 | $ hg log --rev . -T '{desc}\n' | |
195 | babar_m |
|
196 | babar_m | |
196 | $ hg phase --public --rev 0 2> ../log.err & |
|
197 | $ hg phase --public --rev 0 2> ../log.err & | |
197 |
$ $RUNTESTDIR/testlib/wait-on-file 5 |
|
198 | $ $RUNTESTDIR/testlib/wait-on-file 5 "$TESTTMP/transaction-waiting" | |
198 | $ hg update "parents(.)" --quiet |
|
199 | $ hg update "parents(.)" --quiet | |
199 | $ hg log --rev . -T '{desc}\n' |
|
200 | $ hg log --rev . -T '{desc}\n' | |
200 | babar_l |
|
201 | babar_l | |
201 | $ hg st |
|
202 | $ hg st | |
202 |
$ touch |
|
203 | $ touch "$TESTTMP/transaction-continue" | |
203 | $ wait |
|
204 | $ wait | |
204 | $ hg log --rev . -T '{desc}\n' |
|
205 | $ hg log --rev . -T '{desc}\n' | |
205 | babar_l |
|
206 | babar_l | |
206 | $ hg st |
|
207 | $ hg st | |
207 |
|
208 | |||
208 | $ hg purge --no-confirm |
|
209 | $ hg purge --no-confirm | |
209 | $ hg up --quiet babar |
|
210 | $ hg up --quiet babar | |
210 |
|
211 | |||
211 | Activating a bookmark |
|
212 | Activating a bookmark | |
212 | --------------------- |
|
213 | --------------------- | |
213 | (without going through the bookmark command) |
|
214 | (without going through the bookmark command) | |
214 |
|
215 | |||
215 | Show the activation/desactivation pattern that exist without taking the store |
|
216 | Show the activation/desactivation pattern that exist without taking the store | |
216 | lock. |
|
217 | lock. | |
217 |
|
218 | |||
218 | $ hg log -r . -T '= {activebookmark} =\n' |
|
219 | $ hg log -r . -T '= {activebookmark} =\n' | |
219 | = = |
|
220 | = = | |
220 | $ hg up bar |
|
221 | $ hg up bar | |
221 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
222 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
222 | (activating bookmark bar) |
|
223 | (activating bookmark bar) | |
223 | $ hg log -r . -T '= {activebookmark} =\n' |
|
224 | $ hg log -r . -T '= {activebookmark} =\n' | |
224 | = bar = |
|
225 | = bar = | |
225 | $ hg up . |
|
226 | $ hg up . | |
226 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
227 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
227 | (leaving bookmark bar) |
|
228 | (leaving bookmark bar) | |
228 | $ hg log -r . -T '= {activebookmark} =\n' |
|
229 | $ hg log -r . -T '= {activebookmark} =\n' | |
229 | = = |
|
230 | = = | |
230 |
|
231 | |||
231 | Activating the bookmark during a transaction |
|
232 | Activating the bookmark during a transaction | |
232 |
|
233 | |||
233 | $ hg up . --quiet |
|
234 | $ hg up . --quiet | |
234 | $ hg log -r . -T '= {activebookmark} =\n' |
|
235 | $ hg log -r . -T '= {activebookmark} =\n' | |
235 | = = |
|
236 | = = | |
236 | $ hg phase --public --rev 0 2> ../log.err & |
|
237 | $ hg phase --public --rev 0 2> ../log.err & | |
237 |
$ $RUNTESTDIR/testlib/wait-on-file 5 |
|
238 | $ $RUNTESTDIR/testlib/wait-on-file 5 "$TESTTMP/transaction-waiting" | |
238 | $ hg up bar |
|
239 | $ hg up bar | |
239 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
240 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
240 | (activating bookmark bar) |
|
241 | (activating bookmark bar) | |
241 | $ hg log -r . -T '= {activebookmark} =\n' |
|
242 | $ hg log -r . -T '= {activebookmark} =\n' | |
242 | = bar = |
|
243 | = bar = | |
243 |
$ touch |
|
244 | $ touch "$TESTTMP/transaction-continue" | |
244 | $ wait |
|
245 | $ wait | |
245 | $ hg log -r . -T '= {activebookmark} =\n' |
|
246 | $ hg log -r . -T '= {activebookmark} =\n' | |
246 | = bar = |
|
247 | = bar = | |
247 |
|
248 | |||
248 | Deactivating the bookmark |
|
249 | Deactivating the bookmark | |
249 |
|
250 | |||
250 | $ hg up bar --quiet |
|
251 | $ hg up bar --quiet | |
251 | $ hg log -r . -T '= {activebookmark} =\n' |
|
252 | $ hg log -r . -T '= {activebookmark} =\n' | |
252 | = bar = |
|
253 | = bar = | |
253 | $ hg phase --public --rev 0 2> ../log.err & |
|
254 | $ hg phase --public --rev 0 2> ../log.err & | |
254 |
$ $RUNTESTDIR/testlib/wait-on-file 5 |
|
255 | $ $RUNTESTDIR/testlib/wait-on-file 5 "$TESTTMP/transaction-waiting" | |
255 | $ hg up . |
|
256 | $ hg up . | |
256 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved |
|
257 | 0 files updated, 0 files merged, 0 files removed, 0 files unresolved | |
257 | (leaving bookmark bar) |
|
258 | (leaving bookmark bar) | |
258 | $ hg log -r . -T '= {activebookmark} =\n' |
|
259 | $ hg log -r . -T '= {activebookmark} =\n' | |
259 | = = |
|
260 | = = | |
260 |
$ touch |
|
261 | $ touch "$TESTTMP/transaction-continue" | |
261 | $ wait |
|
262 | $ wait | |
262 | $ hg log -r . -T '= {activebookmark} =\n' |
|
263 | $ hg log -r . -T '= {activebookmark} =\n' | |
263 | = = |
|
264 | = = |
General Comments 0
You need to be logged in to leave comments.
Login now