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