##// END OF EJS Templates
test-fncache: ensure lock doesn't look held to __del__...
Augie Fackler -
r27168:8a829fc8 default
parent child Browse files
Show More
@@ -1,400 +1,401 b''
1 1 Init repo1:
2 2
3 3 $ hg init repo1
4 4 $ cd repo1
5 5 $ echo "some text" > a
6 6 $ hg add
7 7 adding a
8 8 $ hg ci -m first
9 9 $ cat .hg/store/fncache | sort
10 10 data/a.i
11 11
12 12 Testing a.i/b:
13 13
14 14 $ mkdir a.i
15 15 $ echo "some other text" > a.i/b
16 16 $ hg add
17 17 adding a.i/b (glob)
18 18 $ hg ci -m second
19 19 $ cat .hg/store/fncache | sort
20 20 data/a.i
21 21 data/a.i.hg/b.i
22 22
23 23 Testing a.i.hg/c:
24 24
25 25 $ mkdir a.i.hg
26 26 $ echo "yet another text" > a.i.hg/c
27 27 $ hg add
28 28 adding a.i.hg/c (glob)
29 29 $ hg ci -m third
30 30 $ cat .hg/store/fncache | sort
31 31 data/a.i
32 32 data/a.i.hg.hg/c.i
33 33 data/a.i.hg/b.i
34 34
35 35 Testing verify:
36 36
37 37 $ hg verify
38 38 checking changesets
39 39 checking manifests
40 40 crosschecking files in changesets and manifests
41 41 checking files
42 42 3 files, 3 changesets, 3 total revisions
43 43
44 44 $ rm .hg/store/fncache
45 45
46 46 $ hg verify
47 47 checking changesets
48 48 checking manifests
49 49 crosschecking files in changesets and manifests
50 50 checking files
51 51 warning: revlog 'data/a.i' not in fncache!
52 52 warning: revlog 'data/a.i.hg/c.i' not in fncache!
53 53 warning: revlog 'data/a.i/b.i' not in fncache!
54 54 3 files, 3 changesets, 3 total revisions
55 55 3 warnings encountered!
56 56 hint: run "hg debugrebuildfncache" to recover from corrupt fncache
57 57
58 58 Follow the hint to make sure it works
59 59
60 60 $ hg debugrebuildfncache
61 61 adding data/a.i
62 62 adding data/a.i.hg/c.i
63 63 adding data/a.i/b.i
64 64 3 items added, 0 removed from fncache
65 65
66 66 $ hg verify
67 67 checking changesets
68 68 checking manifests
69 69 crosschecking files in changesets and manifests
70 70 checking files
71 71 3 files, 3 changesets, 3 total revisions
72 72
73 73 $ cd ..
74 74
75 75 Non store repo:
76 76
77 77 $ hg --config format.usestore=False init foo
78 78 $ cd foo
79 79 $ mkdir tst.d
80 80 $ echo foo > tst.d/foo
81 81 $ hg ci -Amfoo
82 82 adding tst.d/foo
83 83 $ find .hg | sort
84 84 .hg
85 85 .hg/00changelog.i
86 86 .hg/00manifest.i
87 87 .hg/cache
88 88 .hg/cache/branch2-served
89 89 .hg/cache/rbc-names-v1
90 90 .hg/cache/rbc-revs-v1
91 91 .hg/data
92 92 .hg/data/tst.d.hg
93 93 .hg/data/tst.d.hg/foo.i
94 94 .hg/dirstate
95 95 .hg/last-message.txt
96 96 .hg/phaseroots
97 97 .hg/requires
98 98 .hg/undo
99 99 .hg/undo.backup.dirstate
100 100 .hg/undo.backupfiles
101 101 .hg/undo.bookmarks
102 102 .hg/undo.branch
103 103 .hg/undo.desc
104 104 .hg/undo.dirstate
105 105 .hg/undo.phaseroots
106 106 $ cd ..
107 107
108 108 Non fncache repo:
109 109
110 110 $ hg --config format.usefncache=False init bar
111 111 $ cd bar
112 112 $ mkdir tst.d
113 113 $ echo foo > tst.d/Foo
114 114 $ hg ci -Amfoo
115 115 adding tst.d/Foo
116 116 $ find .hg | sort
117 117 .hg
118 118 .hg/00changelog.i
119 119 .hg/cache
120 120 .hg/cache/branch2-served
121 121 .hg/cache/rbc-names-v1
122 122 .hg/cache/rbc-revs-v1
123 123 .hg/dirstate
124 124 .hg/last-message.txt
125 125 .hg/requires
126 126 .hg/store
127 127 .hg/store/00changelog.i
128 128 .hg/store/00manifest.i
129 129 .hg/store/data
130 130 .hg/store/data/tst.d.hg
131 131 .hg/store/data/tst.d.hg/_foo.i
132 132 .hg/store/phaseroots
133 133 .hg/store/undo
134 134 .hg/store/undo.backupfiles
135 135 .hg/store/undo.phaseroots
136 136 .hg/undo.backup.dirstate
137 137 .hg/undo.bookmarks
138 138 .hg/undo.branch
139 139 .hg/undo.desc
140 140 .hg/undo.dirstate
141 141 $ cd ..
142 142
143 143 Encoding of reserved / long paths in the store
144 144
145 145 $ hg init r2
146 146 $ cd r2
147 147 $ cat <<EOF > .hg/hgrc
148 148 > [ui]
149 149 > portablefilenames = ignore
150 150 > EOF
151 151
152 152 $ hg import -q --bypass - <<EOF
153 153 > # HG changeset patch
154 154 > # User test
155 155 > # Date 0 0
156 156 > # Node ID 1c7a2f7cb77be1a0def34e4c7cabc562ad98fbd7
157 157 > # Parent 0000000000000000000000000000000000000000
158 158 > 1
159 159 >
160 160 > diff --git a/12345678/12345678/12345678/12345678/12345678/12345678/12345678/12345/xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-123456789-12.3456789-12345-ABCDEFGHIJKLMNOPRSTUVWXYZ-abcdefghjiklmnopqrstuvwxyz b/12345678/12345678/12345678/12345678/12345678/12345678/12345678/12345/xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-123456789-12.3456789-12345-ABCDEFGHIJKLMNOPRSTUVWXYZ-abcdefghjiklmnopqrstuvwxyz
161 161 > new file mode 100644
162 162 > --- /dev/null
163 163 > +++ b/12345678/12345678/12345678/12345678/12345678/12345678/12345678/12345/xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-123456789-12.3456789-12345-ABCDEFGHIJKLMNOPRSTUVWXYZ-abcdefghjiklmnopqrstuvwxyz
164 164 > @@ -0,0 +1,1 @@
165 165 > +foo
166 166 > diff --git a/AUX/SECOND/X.PRN/FOURTH/FI:FTH/SIXTH/SEVENTH/EIGHTH/NINETH/TENTH/ELEVENTH/LOREMIPSUM.TXT b/AUX/SECOND/X.PRN/FOURTH/FI:FTH/SIXTH/SEVENTH/EIGHTH/NINETH/TENTH/ELEVENTH/LOREMIPSUM.TXT
167 167 > new file mode 100644
168 168 > --- /dev/null
169 169 > +++ b/AUX/SECOND/X.PRN/FOURTH/FI:FTH/SIXTH/SEVENTH/EIGHTH/NINETH/TENTH/ELEVENTH/LOREMIPSUM.TXT
170 170 > @@ -0,0 +1,1 @@
171 171 > +foo
172 172 > diff --git a/Project Planning/Resources/AnotherLongDirectoryName/Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt b/Project Planning/Resources/AnotherLongDirectoryName/Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt
173 173 > new file mode 100644
174 174 > --- /dev/null
175 175 > +++ b/Project Planning/Resources/AnotherLongDirectoryName/Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt
176 176 > @@ -0,0 +1,1 @@
177 177 > +foo
178 178 > diff --git a/bla.aux/prn/PRN/lpt/com3/nul/coma/foo.NUL/normal.c b/bla.aux/prn/PRN/lpt/com3/nul/coma/foo.NUL/normal.c
179 179 > new file mode 100644
180 180 > --- /dev/null
181 181 > +++ b/bla.aux/prn/PRN/lpt/com3/nul/coma/foo.NUL/normal.c
182 182 > @@ -0,0 +1,1 @@
183 183 > +foo
184 184 > diff --git a/enterprise/openesbaddons/contrib-imola/corba-bc/netbeansplugin/wsdlExtension/src/main/java/META-INF/services/org.netbeans.modules.xml.wsdl.bindingsupport.spi.ExtensibilityElementTemplateProvider b/enterprise/openesbaddons/contrib-imola/corba-bc/netbeansplugin/wsdlExtension/src/main/java/META-INF/services/org.netbeans.modules.xml.wsdl.bindingsupport.spi.ExtensibilityElementTemplateProvider
185 185 > new file mode 100644
186 186 > --- /dev/null
187 187 > +++ b/enterprise/openesbaddons/contrib-imola/corba-bc/netbeansplugin/wsdlExtension/src/main/java/META-INF/services/org.netbeans.modules.xml.wsdl.bindingsupport.spi.ExtensibilityElementTemplateProvider
188 188 > @@ -0,0 +1,1 @@
189 189 > +foo
190 190 > EOF
191 191
192 192 $ find .hg/store -name *.i | sort
193 193 .hg/store/00changelog.i
194 194 .hg/store/00manifest.i
195 195 .hg/store/data/bla.aux/pr~6e/_p_r_n/lpt/co~6d3/nu~6c/coma/foo._n_u_l/normal.c.i
196 196 .hg/store/dh/12345678/12345678/12345678/12345678/12345678/12345678/12345678/12345/xxxxxx168e07b38e65eff86ab579afaaa8e30bfbe0f35f.i
197 197 .hg/store/dh/au~78/second/x.prn/fourth/fi~3afth/sixth/seventh/eighth/nineth/tenth/loremia20419e358ddff1bf8751e38288aff1d7c32ec05.i
198 198 .hg/store/dh/enterpri/openesba/contrib-/corba-bc/netbeans/wsdlexte/src/main/java/org.net7018f27961fdf338a598a40c4683429e7ffb9743.i
199 199 .hg/store/dh/project_/resource/anotherl/followed/andanoth/andthenanextremelylongfilename0d8e1f4187c650e2f1fdca9fd90f786bc0976b6b.i
200 200
201 201 $ cd ..
202 202
203 203 Aborting lock does not prevent fncache writes
204 204
205 205 $ cat > exceptionext.py <<EOF
206 206 > import os
207 207 > from mercurial import commands, error
208 208 > from mercurial.extensions import wrapfunction
209 209 >
210 210 > def lockexception(orig, vfs, lockname, wait, releasefn, *args, **kwargs):
211 211 > def releasewrap():
212 > l.held = False # ensure __del__ is a noop
212 213 > raise error.Abort("forced lock failure")
213 > return orig(vfs, lockname, wait, releasewrap, *args, **kwargs)
214 > l = orig(vfs, lockname, wait, releasewrap, *args, **kwargs)
215 > return l
214 216 >
215 217 > def reposetup(ui, repo):
216 218 > wrapfunction(repo, '_lock', lockexception)
217 219 >
218 220 > cmdtable = {}
219 221 >
220 222 > EOF
221 223 $ extpath=`pwd`/exceptionext.py
222 224 $ hg init fncachetxn
223 225 $ cd fncachetxn
224 226 $ printf "[extensions]\nexceptionext=$extpath\n" >> .hg/hgrc
225 227 $ touch y
226 228 $ hg ci -qAm y
227 229 abort: forced lock failure
228 Exception mercurial.error.Abort: Abort('forced lock failure',) in <bound method lock.__del__ of <mercurial.lock.lock object at *>> ignored (glob)
229 230 [255]
230 231 $ cat .hg/store/fncache
231 232 data/y.i
232 233
233 234 Aborting transaction prevents fncache change
234 235
235 236 $ cat > ../exceptionext.py <<EOF
236 237 > import os
237 238 > from mercurial import commands, error, localrepo
238 239 > from mercurial.extensions import wrapfunction
239 240 >
240 241 > def wrapper(orig, self, *args, **kwargs):
241 242 > tr = orig(self, *args, **kwargs)
242 243 > def fail(tr):
243 244 > raise error.Abort("forced transaction failure")
244 245 > # zzz prefix to ensure it sorted after store.write
245 246 > tr.addfinalize('zzz-forcefails', fail)
246 247 > return tr
247 248 >
248 249 > def uisetup(ui):
249 250 > wrapfunction(localrepo.localrepository, 'transaction', wrapper)
250 251 >
251 252 > cmdtable = {}
252 253 >
253 254 > EOF
254 255 $ rm -f "${extpath}c"
255 256 $ touch z
256 257 $ hg ci -qAm z
257 258 transaction abort!
258 259 rollback completed
259 260 abort: forced transaction failure
260 261 [255]
261 262 $ cat .hg/store/fncache
262 263 data/y.i
263 264
264 265 Aborted transactions can be recovered later
265 266
266 267 $ cat > ../exceptionext.py <<EOF
267 268 > import os
268 269 > from mercurial import commands, error, transaction, localrepo
269 270 > from mercurial.extensions import wrapfunction
270 271 >
271 272 > def trwrapper(orig, self, *args, **kwargs):
272 273 > tr = orig(self, *args, **kwargs)
273 274 > def fail(tr):
274 275 > raise error.Abort("forced transaction failure")
275 276 > # zzz prefix to ensure it sorted after store.write
276 277 > tr.addfinalize('zzz-forcefails', fail)
277 278 > return tr
278 279 >
279 280 > def abortwrapper(orig, self, *args, **kwargs):
280 281 > raise error.Abort("forced transaction failure")
281 282 >
282 283 > def uisetup(ui):
283 284 > wrapfunction(localrepo.localrepository, 'transaction', trwrapper)
284 285 > wrapfunction(transaction.transaction, '_abort', abortwrapper)
285 286 >
286 287 > cmdtable = {}
287 288 >
288 289 > EOF
289 290 $ rm -f "${extpath}c"
290 291 $ hg up -q 1
291 292 $ touch z
292 293 $ hg ci -qAm z 2>/dev/null
293 294 [255]
294 295 $ cat .hg/store/fncache | sort
295 296 data/y.i
296 297 data/z.i
297 298 $ hg recover
298 299 rolling back interrupted transaction
299 300 checking changesets
300 301 checking manifests
301 302 crosschecking files in changesets and manifests
302 303 checking files
303 304 1 files, 1 changesets, 1 total revisions
304 305 $ cat .hg/store/fncache
305 306 data/y.i
306 307
307 308 $ cd ..
308 309
309 310 debugrebuildfncache does nothing unless repo has fncache requirement
310 311
311 312 $ hg --config format.usefncache=false init nofncache
312 313 $ cd nofncache
313 314 $ hg debugrebuildfncache
314 315 (not rebuilding fncache because repository does not support fncache)
315 316
316 317 $ cd ..
317 318
318 319 debugrebuildfncache works on empty repository
319 320
320 321 $ hg init empty
321 322 $ cd empty
322 323 $ hg debugrebuildfncache
323 324 fncache already up to date
324 325 $ cd ..
325 326
326 327 debugrebuildfncache on an up to date repository no-ops
327 328
328 329 $ hg init repo
329 330 $ cd repo
330 331 $ echo initial > foo
331 332 $ echo initial > .bar
332 333 $ hg commit -A -m initial
333 334 adding .bar
334 335 adding foo
335 336
336 337 $ cat .hg/store/fncache | sort
337 338 data/.bar.i
338 339 data/foo.i
339 340
340 341 $ hg debugrebuildfncache
341 342 fncache already up to date
342 343
343 344 debugrebuildfncache restores deleted fncache file
344 345
345 346 $ rm -f .hg/store/fncache
346 347 $ hg debugrebuildfncache
347 348 adding data/.bar.i
348 349 adding data/foo.i
349 350 2 items added, 0 removed from fncache
350 351
351 352 $ cat .hg/store/fncache | sort
352 353 data/.bar.i
353 354 data/foo.i
354 355
355 356 Rebuild after rebuild should no-op
356 357
357 358 $ hg debugrebuildfncache
358 359 fncache already up to date
359 360
360 361 A single missing file should get restored, an extra file should be removed
361 362
362 363 $ cat > .hg/store/fncache << EOF
363 364 > data/foo.i
364 365 > data/bad-entry.i
365 366 > EOF
366 367
367 368 $ hg debugrebuildfncache
368 369 removing data/bad-entry.i
369 370 adding data/.bar.i
370 371 1 items added, 1 removed from fncache
371 372
372 373 $ cat .hg/store/fncache | sort
373 374 data/.bar.i
374 375 data/foo.i
375 376
376 377 $ cd ..
377 378
378 379 Try a simple variation without dotencode to ensure fncache is ignorant of encoding
379 380
380 381 $ hg --config format.dotencode=false init nodotencode
381 382 $ cd nodotencode
382 383 $ echo initial > foo
383 384 $ echo initial > .bar
384 385 $ hg commit -A -m initial
385 386 adding .bar
386 387 adding foo
387 388
388 389 $ cat .hg/store/fncache | sort
389 390 data/.bar.i
390 391 data/foo.i
391 392
392 393 $ rm .hg/store/fncache
393 394 $ hg debugrebuildfncache
394 395 adding data/.bar.i
395 396 adding data/foo.i
396 397 2 items added, 0 removed from fncache
397 398
398 399 $ cat .hg/store/fncache | sort
399 400 data/.bar.i
400 401 data/foo.i
General Comments 0
You need to be logged in to leave comments. Login now