##// END OF EJS Templates
pypy: fix failing test files with Pypy5.6.0...
Boris Feld -
r33609:6c142f27 stable
parent child Browse files
Show More
@@ -1,908 +1,910 b''
1 1 #if windows
2 2 $ PYTHONPATH="$TESTDIR/../contrib;$PYTHONPATH"
3 3 #else
4 4 $ PYTHONPATH="$TESTDIR/../contrib:$PYTHONPATH"
5 5 #endif
6 6 $ export PYTHONPATH
7 7
8 8 typical client does not want echo-back messages, so test without it:
9 9
10 10 $ grep -v '^promptecho ' < $HGRCPATH >> $HGRCPATH.new
11 11 $ mv $HGRCPATH.new $HGRCPATH
12 12
13 13 $ hg init repo
14 14 $ cd repo
15 15
16 16 >>> from __future__ import print_function
17 17 >>> from hgclient import readchannel, runcommand, check
18 18 >>> @check
19 19 ... def hellomessage(server):
20 20 ... ch, data = readchannel(server)
21 21 ... print('%c, %r' % (ch, data))
22 22 ... # run an arbitrary command to make sure the next thing the server
23 23 ... # sends isn't part of the hello message
24 24 ... runcommand(server, ['id'])
25 25 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
26 26 *** runcommand id
27 27 000000000000 tip
28 28
29 29 >>> from hgclient import check
30 30 >>> @check
31 31 ... def unknowncommand(server):
32 32 ... server.stdin.write('unknowncommand\n')
33 33 abort: unknown command unknowncommand
34 34
35 35 >>> from hgclient import readchannel, runcommand, check
36 36 >>> @check
37 37 ... def checkruncommand(server):
38 38 ... # hello block
39 39 ... readchannel(server)
40 40 ...
41 41 ... # no args
42 42 ... runcommand(server, [])
43 43 ...
44 44 ... # global options
45 45 ... runcommand(server, ['id', '--quiet'])
46 46 ...
47 47 ... # make sure global options don't stick through requests
48 48 ... runcommand(server, ['id'])
49 49 ...
50 50 ... # --config
51 51 ... runcommand(server, ['id', '--config', 'ui.quiet=True'])
52 52 ...
53 53 ... # make sure --config doesn't stick
54 54 ... runcommand(server, ['id'])
55 55 ...
56 56 ... # negative return code should be masked
57 57 ... runcommand(server, ['id', '-runknown'])
58 58 *** runcommand
59 59 Mercurial Distributed SCM
60 60
61 61 basic commands:
62 62
63 63 add add the specified files on the next commit
64 64 annotate show changeset information by line for each file
65 65 clone make a copy of an existing repository
66 66 commit commit the specified files or all outstanding changes
67 67 diff diff repository (or selected files)
68 68 export dump the header and diffs for one or more changesets
69 69 forget forget the specified files on the next commit
70 70 init create a new repository in the given directory
71 71 log show revision history of entire repository or files
72 72 merge merge another revision into working directory
73 73 pull pull changes from the specified source
74 74 push push changes to the specified destination
75 75 remove remove the specified files on the next commit
76 76 serve start stand-alone webserver
77 77 status show changed files in the working directory
78 78 summary summarize working directory state
79 79 update update working directory (or switch revisions)
80 80
81 81 (use 'hg help' for the full list of commands or 'hg -v' for details)
82 82 *** runcommand id --quiet
83 83 000000000000
84 84 *** runcommand id
85 85 000000000000 tip
86 86 *** runcommand id --config ui.quiet=True
87 87 000000000000
88 88 *** runcommand id
89 89 000000000000 tip
90 90 *** runcommand id -runknown
91 91 abort: unknown revision 'unknown'!
92 92 [255]
93 93
94 94 >>> from hgclient import readchannel, check
95 95 >>> @check
96 96 ... def inputeof(server):
97 97 ... readchannel(server)
98 98 ... server.stdin.write('runcommand\n')
99 99 ... # close stdin while server is waiting for input
100 100 ... server.stdin.close()
101 101 ...
102 102 ... # server exits with 1 if the pipe closed while reading the command
103 103 ... print('server exit code =', server.wait())
104 104 server exit code = 1
105 105
106 106 >>> from hgclient import readchannel, runcommand, check, stringio
107 107 >>> @check
108 108 ... def serverinput(server):
109 109 ... readchannel(server)
110 110 ...
111 111 ... patch = """
112 112 ... # HG changeset patch
113 113 ... # User test
114 114 ... # Date 0 0
115 115 ... # Node ID c103a3dec114d882c98382d684d8af798d09d857
116 116 ... # Parent 0000000000000000000000000000000000000000
117 117 ... 1
118 118 ...
119 119 ... diff -r 000000000000 -r c103a3dec114 a
120 120 ... --- /dev/null Thu Jan 01 00:00:00 1970 +0000
121 121 ... +++ b/a Thu Jan 01 00:00:00 1970 +0000
122 122 ... @@ -0,0 +1,1 @@
123 123 ... +1
124 124 ... """
125 125 ...
126 126 ... runcommand(server, ['import', '-'], input=stringio(patch))
127 127 ... runcommand(server, ['log'])
128 128 *** runcommand import -
129 129 applying patch from stdin
130 130 *** runcommand log
131 131 changeset: 0:eff892de26ec
132 132 tag: tip
133 133 user: test
134 134 date: Thu Jan 01 00:00:00 1970 +0000
135 135 summary: 1
136 136
137 137
138 138 check that "histedit --commands=-" can read rules from the input channel:
139 139
140 140 >>> import cStringIO
141 141 >>> from hgclient import readchannel, runcommand, check
142 142 >>> @check
143 143 ... def serverinput(server):
144 144 ... readchannel(server)
145 145 ... rules = 'pick eff892de26ec\n'
146 146 ... runcommand(server, ['histedit', '0', '--commands=-',
147 147 ... '--config', 'extensions.histedit='],
148 148 ... input=cStringIO.StringIO(rules))
149 149 *** runcommand histedit 0 --commands=- --config extensions.histedit=
150 150
151 151 check that --cwd doesn't persist between requests:
152 152
153 153 $ mkdir foo
154 154 $ touch foo/bar
155 155 >>> from hgclient import readchannel, runcommand, check
156 156 >>> @check
157 157 ... def cwd(server):
158 158 ... readchannel(server)
159 159 ... runcommand(server, ['--cwd', 'foo', 'st', 'bar'])
160 160 ... runcommand(server, ['st', 'foo/bar'])
161 161 *** runcommand --cwd foo st bar
162 162 ? bar
163 163 *** runcommand st foo/bar
164 164 ? foo/bar
165 165
166 166 $ rm foo/bar
167 167
168 168
169 169 check that local configs for the cached repo aren't inherited when -R is used:
170 170
171 171 $ cat <<EOF >> .hg/hgrc
172 172 > [ui]
173 173 > foo = bar
174 174 > EOF
175 175
176 176 >>> from hgclient import readchannel, sep, runcommand, check
177 177 >>> @check
178 178 ... def localhgrc(server):
179 179 ... readchannel(server)
180 180 ...
181 181 ... # the cached repo local hgrc contains ui.foo=bar, so showconfig should
182 182 ... # show it
183 183 ... runcommand(server, ['showconfig'], outfilter=sep)
184 184 ...
185 185 ... # but not for this repo
186 186 ... runcommand(server, ['init', 'foo'])
187 187 ... runcommand(server, ['-R', 'foo', 'showconfig', 'ui', 'defaults'])
188 188 *** runcommand showconfig
189 189 bundle.mainreporoot=$TESTTMP/repo
190 190 devel.all-warnings=true
191 191 devel.default-date=0 0
192 192 extensions.fsmonitor= (fsmonitor !)
193 193 largefiles.usercache=$TESTTMP/.cache/largefiles
194 194 ui.slash=True
195 195 ui.interactive=False
196 196 ui.mergemarkers=detailed
197 197 ui.usehttp2=true (?)
198 198 ui.foo=bar
199 199 ui.nontty=true
200 200 web.address=localhost
201 201 web\.ipv6=(?:True|False) (re)
202 202 *** runcommand init foo
203 203 *** runcommand -R foo showconfig ui defaults
204 204 ui.slash=True
205 205 ui.interactive=False
206 206 ui.mergemarkers=detailed
207 207 ui.usehttp2=true (?)
208 208 ui.nontty=true
209 209
210 210 $ rm -R foo
211 211
212 212 #if windows
213 213 $ PYTHONPATH="$TESTTMP/repo;$PYTHONPATH"
214 214 #else
215 215 $ PYTHONPATH="$TESTTMP/repo:$PYTHONPATH"
216 216 #endif
217 217
218 218 $ cat <<EOF > hook.py
219 219 > from __future__ import print_function
220 220 > import sys
221 221 > def hook(**args):
222 222 > print('hook talking')
223 223 > print('now try to read something: %r' % sys.stdin.read())
224 224 > EOF
225 225
226 226 >>> from hgclient import readchannel, runcommand, check, stringio
227 227 >>> @check
228 228 ... def hookoutput(server):
229 229 ... readchannel(server)
230 230 ... runcommand(server, ['--config',
231 231 ... 'hooks.pre-identify=python:hook.hook',
232 232 ... 'id'],
233 233 ... input=stringio('some input'))
234 234 *** runcommand --config hooks.pre-identify=python:hook.hook id
235 235 eff892de26ec tip
236 236
237 Clean hook cached version
237 238 $ rm hook.py*
239 $ rm -Rf __pycache__
238 240
239 241 $ echo a >> a
240 242 >>> import os
241 243 >>> from hgclient import readchannel, runcommand, check
242 244 >>> @check
243 245 ... def outsidechanges(server):
244 246 ... readchannel(server)
245 247 ... runcommand(server, ['status'])
246 248 ... os.system('hg ci -Am2')
247 249 ... runcommand(server, ['tip'])
248 250 ... runcommand(server, ['status'])
249 251 *** runcommand status
250 252 M a
251 253 *** runcommand tip
252 254 changeset: 1:d3a0a68be6de
253 255 tag: tip
254 256 user: test
255 257 date: Thu Jan 01 00:00:00 1970 +0000
256 258 summary: 2
257 259
258 260 *** runcommand status
259 261
260 262 >>> import os
261 263 >>> from hgclient import readchannel, runcommand, check
262 264 >>> @check
263 265 ... def bookmarks(server):
264 266 ... readchannel(server)
265 267 ... runcommand(server, ['bookmarks'])
266 268 ...
267 269 ... # changes .hg/bookmarks
268 270 ... os.system('hg bookmark -i bm1')
269 271 ... os.system('hg bookmark -i bm2')
270 272 ... runcommand(server, ['bookmarks'])
271 273 ...
272 274 ... # changes .hg/bookmarks.current
273 275 ... os.system('hg upd bm1 -q')
274 276 ... runcommand(server, ['bookmarks'])
275 277 ...
276 278 ... runcommand(server, ['bookmarks', 'bm3'])
277 279 ... f = open('a', 'ab')
278 280 ... f.write('a\n')
279 281 ... f.close()
280 282 ... runcommand(server, ['commit', '-Amm'])
281 283 ... runcommand(server, ['bookmarks'])
282 284 *** runcommand bookmarks
283 285 no bookmarks set
284 286 *** runcommand bookmarks
285 287 bm1 1:d3a0a68be6de
286 288 bm2 1:d3a0a68be6de
287 289 *** runcommand bookmarks
288 290 * bm1 1:d3a0a68be6de
289 291 bm2 1:d3a0a68be6de
290 292 *** runcommand bookmarks bm3
291 293 *** runcommand commit -Amm
292 294 *** runcommand bookmarks
293 295 bm1 1:d3a0a68be6de
294 296 bm2 1:d3a0a68be6de
295 297 * bm3 2:aef17e88f5f0
296 298
297 299 >>> import os
298 300 >>> from hgclient import readchannel, runcommand, check
299 301 >>> @check
300 302 ... def tagscache(server):
301 303 ... readchannel(server)
302 304 ... runcommand(server, ['id', '-t', '-r', '0'])
303 305 ... os.system('hg tag -r 0 foo')
304 306 ... runcommand(server, ['id', '-t', '-r', '0'])
305 307 *** runcommand id -t -r 0
306 308
307 309 *** runcommand id -t -r 0
308 310 foo
309 311
310 312 >>> import os
311 313 >>> from hgclient import readchannel, runcommand, check
312 314 >>> @check
313 315 ... def setphase(server):
314 316 ... readchannel(server)
315 317 ... runcommand(server, ['phase', '-r', '.'])
316 318 ... os.system('hg phase -r . -p')
317 319 ... runcommand(server, ['phase', '-r', '.'])
318 320 *** runcommand phase -r .
319 321 3: draft
320 322 *** runcommand phase -r .
321 323 3: public
322 324
323 325 $ echo a >> a
324 326 >>> from hgclient import readchannel, runcommand, check
325 327 >>> @check
326 328 ... def rollback(server):
327 329 ... readchannel(server)
328 330 ... runcommand(server, ['phase', '-r', '.', '-p'])
329 331 ... runcommand(server, ['commit', '-Am.'])
330 332 ... runcommand(server, ['rollback'])
331 333 ... runcommand(server, ['phase', '-r', '.'])
332 334 *** runcommand phase -r . -p
333 335 no phases changed
334 336 *** runcommand commit -Am.
335 337 *** runcommand rollback
336 338 repository tip rolled back to revision 3 (undo commit)
337 339 working directory now based on revision 3
338 340 *** runcommand phase -r .
339 341 3: public
340 342
341 343 >>> import os
342 344 >>> from hgclient import readchannel, runcommand, check
343 345 >>> @check
344 346 ... def branch(server):
345 347 ... readchannel(server)
346 348 ... runcommand(server, ['branch'])
347 349 ... os.system('hg branch foo')
348 350 ... runcommand(server, ['branch'])
349 351 ... os.system('hg branch default')
350 352 *** runcommand branch
351 353 default
352 354 marked working directory as branch foo
353 355 (branches are permanent and global, did you want a bookmark?)
354 356 *** runcommand branch
355 357 foo
356 358 marked working directory as branch default
357 359 (branches are permanent and global, did you want a bookmark?)
358 360
359 361 $ touch .hgignore
360 362 >>> import os
361 363 >>> from hgclient import readchannel, runcommand, check
362 364 >>> @check
363 365 ... def hgignore(server):
364 366 ... readchannel(server)
365 367 ... runcommand(server, ['commit', '-Am.'])
366 368 ... f = open('ignored-file', 'ab')
367 369 ... f.write('')
368 370 ... f.close()
369 371 ... f = open('.hgignore', 'ab')
370 372 ... f.write('ignored-file')
371 373 ... f.close()
372 374 ... runcommand(server, ['status', '-i', '-u'])
373 375 *** runcommand commit -Am.
374 376 adding .hgignore
375 377 *** runcommand status -i -u
376 378 I ignored-file
377 379
378 380 cache of non-public revisions should be invalidated on repository change
379 381 (issue4855):
380 382
381 383 >>> import os
382 384 >>> from hgclient import readchannel, runcommand, check
383 385 >>> @check
384 386 ... def phasesetscacheaftercommit(server):
385 387 ... readchannel(server)
386 388 ... # load _phasecache._phaserevs and _phasesets
387 389 ... runcommand(server, ['log', '-qr', 'draft()'])
388 390 ... # create draft commits by another process
389 391 ... for i in xrange(5, 7):
390 392 ... f = open('a', 'ab')
391 393 ... f.seek(0, os.SEEK_END)
392 394 ... f.write('a\n')
393 395 ... f.close()
394 396 ... os.system('hg commit -Aqm%d' % i)
395 397 ... # new commits should be listed as draft revisions
396 398 ... runcommand(server, ['log', '-qr', 'draft()'])
397 399 *** runcommand log -qr draft()
398 400 4:7966c8e3734d
399 401 *** runcommand log -qr draft()
400 402 4:7966c8e3734d
401 403 5:41f6602d1c4f
402 404 6:10501e202c35
403 405
404 406 >>> import os
405 407 >>> from hgclient import readchannel, runcommand, check
406 408 >>> @check
407 409 ... def phasesetscacheafterstrip(server):
408 410 ... readchannel(server)
409 411 ... # load _phasecache._phaserevs and _phasesets
410 412 ... runcommand(server, ['log', '-qr', 'draft()'])
411 413 ... # strip cached revisions by another process
412 414 ... os.system('hg --config extensions.strip= strip -q 5')
413 415 ... # shouldn't abort by "unknown revision '6'"
414 416 ... runcommand(server, ['log', '-qr', 'draft()'])
415 417 *** runcommand log -qr draft()
416 418 4:7966c8e3734d
417 419 5:41f6602d1c4f
418 420 6:10501e202c35
419 421 *** runcommand log -qr draft()
420 422 4:7966c8e3734d
421 423
422 424 cache of phase roots should be invalidated on strip (issue3827):
423 425
424 426 >>> import os
425 427 >>> from hgclient import readchannel, sep, runcommand, check
426 428 >>> @check
427 429 ... def phasecacheafterstrip(server):
428 430 ... readchannel(server)
429 431 ...
430 432 ... # create new head, 5:731265503d86
431 433 ... runcommand(server, ['update', '-C', '0'])
432 434 ... f = open('a', 'ab')
433 435 ... f.write('a\n')
434 436 ... f.close()
435 437 ... runcommand(server, ['commit', '-Am.', 'a'])
436 438 ... runcommand(server, ['log', '-Gq'])
437 439 ...
438 440 ... # make it public; draft marker moves to 4:7966c8e3734d
439 441 ... runcommand(server, ['phase', '-p', '.'])
440 442 ... # load _phasecache.phaseroots
441 443 ... runcommand(server, ['phase', '.'], outfilter=sep)
442 444 ...
443 445 ... # strip 1::4 outside server
444 446 ... os.system('hg -q --config extensions.mq= strip 1')
445 447 ...
446 448 ... # shouldn't raise "7966c8e3734d: no node!"
447 449 ... runcommand(server, ['branches'])
448 450 *** runcommand update -C 0
449 451 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
450 452 (leaving bookmark bm3)
451 453 *** runcommand commit -Am. a
452 454 created new head
453 455 *** runcommand log -Gq
454 456 @ 5:731265503d86
455 457 |
456 458 | o 4:7966c8e3734d
457 459 | |
458 460 | o 3:b9b85890c400
459 461 | |
460 462 | o 2:aef17e88f5f0
461 463 | |
462 464 | o 1:d3a0a68be6de
463 465 |/
464 466 o 0:eff892de26ec
465 467
466 468 *** runcommand phase -p .
467 469 *** runcommand phase .
468 470 5: public
469 471 *** runcommand branches
470 472 default 1:731265503d86
471 473
472 474 in-memory cache must be reloaded if transaction is aborted. otherwise
473 475 changelog and manifest would have invalid node:
474 476
475 477 $ echo a >> a
476 478 >>> from hgclient import readchannel, runcommand, check
477 479 >>> @check
478 480 ... def txabort(server):
479 481 ... readchannel(server)
480 482 ... runcommand(server, ['commit', '--config', 'hooks.pretxncommit=false',
481 483 ... '-mfoo'])
482 484 ... runcommand(server, ['verify'])
483 485 *** runcommand commit --config hooks.pretxncommit=false -mfoo
484 486 transaction abort!
485 487 rollback completed
486 488 abort: pretxncommit hook exited with status 1
487 489 [255]
488 490 *** runcommand verify
489 491 checking changesets
490 492 checking manifests
491 493 crosschecking files in changesets and manifests
492 494 checking files
493 495 1 files, 2 changesets, 2 total revisions
494 496 $ hg revert --no-backup -aq
495 497
496 498 $ cat >> .hg/hgrc << EOF
497 499 > [experimental]
498 500 > evolution=createmarkers
499 501 > EOF
500 502
501 503 >>> import os
502 504 >>> from hgclient import readchannel, runcommand, check
503 505 >>> @check
504 506 ... def obsolete(server):
505 507 ... readchannel(server)
506 508 ...
507 509 ... runcommand(server, ['up', 'null'])
508 510 ... runcommand(server, ['phase', '-df', 'tip'])
509 511 ... cmd = 'hg debugobsolete `hg log -r tip --template {node}`'
510 512 ... if os.name == 'nt':
511 513 ... cmd = 'sh -c "%s"' % cmd # run in sh, not cmd.exe
512 514 ... os.system(cmd)
513 515 ... runcommand(server, ['log', '--hidden'])
514 516 ... runcommand(server, ['log'])
515 517 *** runcommand up null
516 518 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
517 519 *** runcommand phase -df tip
518 520 obsoleted 1 changesets
519 521 *** runcommand log --hidden
520 522 changeset: 1:731265503d86
521 523 tag: tip
522 524 user: test
523 525 date: Thu Jan 01 00:00:00 1970 +0000
524 526 summary: .
525 527
526 528 changeset: 0:eff892de26ec
527 529 bookmark: bm1
528 530 bookmark: bm2
529 531 bookmark: bm3
530 532 user: test
531 533 date: Thu Jan 01 00:00:00 1970 +0000
532 534 summary: 1
533 535
534 536 *** runcommand log
535 537 changeset: 0:eff892de26ec
536 538 bookmark: bm1
537 539 bookmark: bm2
538 540 bookmark: bm3
539 541 tag: tip
540 542 user: test
541 543 date: Thu Jan 01 00:00:00 1970 +0000
542 544 summary: 1
543 545
544 546
545 547 $ cat <<EOF >> .hg/hgrc
546 548 > [extensions]
547 549 > mq =
548 550 > EOF
549 551
550 552 >>> import os
551 553 >>> from hgclient import readchannel, runcommand, check
552 554 >>> @check
553 555 ... def mqoutsidechanges(server):
554 556 ... readchannel(server)
555 557 ...
556 558 ... # load repo.mq
557 559 ... runcommand(server, ['qapplied'])
558 560 ... os.system('hg qnew 0.diff')
559 561 ... # repo.mq should be invalidated
560 562 ... runcommand(server, ['qapplied'])
561 563 ...
562 564 ... runcommand(server, ['qpop', '--all'])
563 565 ... os.system('hg qqueue --create foo')
564 566 ... # repo.mq should be recreated to point to new queue
565 567 ... runcommand(server, ['qqueue', '--active'])
566 568 *** runcommand qapplied
567 569 *** runcommand qapplied
568 570 0.diff
569 571 *** runcommand qpop --all
570 572 popping 0.diff
571 573 patch queue now empty
572 574 *** runcommand qqueue --active
573 575 foo
574 576
575 577 $ cat <<EOF > dbgui.py
576 578 > import os, sys
577 579 > from mercurial import commands, registrar
578 580 > cmdtable = {}
579 581 > command = registrar.command(cmdtable)
580 582 > @command(b"debuggetpass", norepo=True)
581 583 > def debuggetpass(ui):
582 584 > ui.write("%s\\n" % ui.getpass())
583 585 > @command(b"debugprompt", norepo=True)
584 586 > def debugprompt(ui):
585 587 > ui.write("%s\\n" % ui.prompt("prompt:"))
586 588 > @command(b"debugreadstdin", norepo=True)
587 589 > def debugreadstdin(ui):
588 590 > ui.write("read: %r\n" % sys.stdin.read(1))
589 591 > @command(b"debugwritestdout", norepo=True)
590 592 > def debugwritestdout(ui):
591 593 > os.write(1, "low-level stdout fd and\n")
592 594 > sys.stdout.write("stdout should be redirected to /dev/null\n")
593 595 > sys.stdout.flush()
594 596 > EOF
595 597 $ cat <<EOF >> .hg/hgrc
596 598 > [extensions]
597 599 > dbgui = dbgui.py
598 600 > EOF
599 601
600 602 >>> from hgclient import readchannel, runcommand, check, stringio
601 603 >>> @check
602 604 ... def getpass(server):
603 605 ... readchannel(server)
604 606 ... runcommand(server, ['debuggetpass', '--config',
605 607 ... 'ui.interactive=True'],
606 608 ... input=stringio('1234\n'))
607 609 ... runcommand(server, ['debuggetpass', '--config',
608 610 ... 'ui.interactive=True'],
609 611 ... input=stringio('\n'))
610 612 ... runcommand(server, ['debuggetpass', '--config',
611 613 ... 'ui.interactive=True'],
612 614 ... input=stringio(''))
613 615 ... runcommand(server, ['debugprompt', '--config',
614 616 ... 'ui.interactive=True'],
615 617 ... input=stringio('5678\n'))
616 618 ... runcommand(server, ['debugreadstdin'])
617 619 ... runcommand(server, ['debugwritestdout'])
618 620 *** runcommand debuggetpass --config ui.interactive=True
619 621 password: 1234
620 622 *** runcommand debuggetpass --config ui.interactive=True
621 623 password:
622 624 *** runcommand debuggetpass --config ui.interactive=True
623 625 password: abort: response expected
624 626 [255]
625 627 *** runcommand debugprompt --config ui.interactive=True
626 628 prompt: 5678
627 629 *** runcommand debugreadstdin
628 630 read: ''
629 631 *** runcommand debugwritestdout
630 632
631 633
632 634 run commandserver in commandserver, which is silly but should work:
633 635
634 636 >>> from __future__ import print_function
635 637 >>> from hgclient import readchannel, runcommand, check, stringio
636 638 >>> @check
637 639 ... def nested(server):
638 640 ... print('%c, %r' % readchannel(server))
639 641 ... class nestedserver(object):
640 642 ... stdin = stringio('getencoding\n')
641 643 ... stdout = stringio()
642 644 ... runcommand(server, ['serve', '--cmdserver', 'pipe'],
643 645 ... output=nestedserver.stdout, input=nestedserver.stdin)
644 646 ... nestedserver.stdout.seek(0)
645 647 ... print('%c, %r' % readchannel(nestedserver)) # hello
646 648 ... print('%c, %r' % readchannel(nestedserver)) # getencoding
647 649 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
648 650 *** runcommand serve --cmdserver pipe
649 651 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
650 652 r, '*' (glob)
651 653
652 654
653 655 start without repository:
654 656
655 657 $ cd ..
656 658
657 659 >>> from __future__ import print_function
658 660 >>> from hgclient import readchannel, runcommand, check
659 661 >>> @check
660 662 ... def hellomessage(server):
661 663 ... ch, data = readchannel(server)
662 664 ... print('%c, %r' % (ch, data))
663 665 ... # run an arbitrary command to make sure the next thing the server
664 666 ... # sends isn't part of the hello message
665 667 ... runcommand(server, ['id'])
666 668 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
667 669 *** runcommand id
668 670 abort: there is no Mercurial repository here (.hg not found)
669 671 [255]
670 672
671 673 >>> from hgclient import readchannel, runcommand, check
672 674 >>> @check
673 675 ... def startwithoutrepo(server):
674 676 ... readchannel(server)
675 677 ... runcommand(server, ['init', 'repo2'])
676 678 ... runcommand(server, ['id', '-R', 'repo2'])
677 679 *** runcommand init repo2
678 680 *** runcommand id -R repo2
679 681 000000000000 tip
680 682
681 683
682 684 don't fall back to cwd if invalid -R path is specified (issue4805):
683 685
684 686 $ cd repo
685 687 $ hg serve --cmdserver pipe -R ../nonexistent
686 688 abort: repository ../nonexistent not found!
687 689 [255]
688 690 $ cd ..
689 691
690 692
691 693 unix domain socket:
692 694
693 695 $ cd repo
694 696 $ hg update -q
695 697
696 698 #if unix-socket unix-permissions
697 699
698 700 >>> from __future__ import print_function
699 701 >>> from hgclient import unixserver, readchannel, runcommand, check, stringio
700 702 >>> server = unixserver('.hg/server.sock', '.hg/server.log')
701 703 >>> def hellomessage(conn):
702 704 ... ch, data = readchannel(conn)
703 705 ... print('%c, %r' % (ch, data))
704 706 ... runcommand(conn, ['id'])
705 707 >>> check(hellomessage, server.connect)
706 708 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
707 709 *** runcommand id
708 710 eff892de26ec tip bm1/bm2/bm3
709 711 >>> def unknowncommand(conn):
710 712 ... readchannel(conn)
711 713 ... conn.stdin.write('unknowncommand\n')
712 714 >>> check(unknowncommand, server.connect) # error sent to server.log
713 715 >>> def serverinput(conn):
714 716 ... readchannel(conn)
715 717 ... patch = """
716 718 ... # HG changeset patch
717 719 ... # User test
718 720 ... # Date 0 0
719 721 ... 2
720 722 ...
721 723 ... diff -r eff892de26ec -r 1ed24be7e7a0 a
722 724 ... --- a/a
723 725 ... +++ b/a
724 726 ... @@ -1,1 +1,2 @@
725 727 ... 1
726 728 ... +2
727 729 ... """
728 730 ... runcommand(conn, ['import', '-'], input=stringio(patch))
729 731 ... runcommand(conn, ['log', '-rtip', '-q'])
730 732 >>> check(serverinput, server.connect)
731 733 *** runcommand import -
732 734 applying patch from stdin
733 735 *** runcommand log -rtip -q
734 736 2:1ed24be7e7a0
735 737 >>> server.shutdown()
736 738
737 739 $ cat .hg/server.log
738 740 listening at .hg/server.sock
739 741 abort: unknown command unknowncommand
740 742 killed!
741 743 $ rm .hg/server.log
742 744
743 745 if server crashed before hello, traceback will be sent to 'e' channel as
744 746 last ditch:
745 747
746 748 $ cat <<EOF >> .hg/hgrc
747 749 > [cmdserver]
748 750 > log = inexistent/path.log
749 751 > EOF
750 752 >>> from __future__ import print_function
751 753 >>> from hgclient import unixserver, readchannel, check
752 754 >>> server = unixserver('.hg/server.sock', '.hg/server.log')
753 755 >>> def earlycrash(conn):
754 756 ... while True:
755 757 ... try:
756 758 ... ch, data = readchannel(conn)
757 759 ... if not data.startswith(' '):
758 760 ... print('%c, %r' % (ch, data))
759 761 ... except EOFError:
760 762 ... break
761 763 >>> check(earlycrash, server.connect)
762 764 e, 'Traceback (most recent call last):\n'
763 765 e, "IOError: *" (glob)
764 766 >>> server.shutdown()
765 767
766 768 $ cat .hg/server.log | grep -v '^ '
767 769 listening at .hg/server.sock
768 770 Traceback (most recent call last):
769 771 IOError: * (glob)
770 772 killed!
771 773 #endif
772 774 #if no-unix-socket
773 775
774 776 $ hg serve --cmdserver unix -a .hg/server.sock
775 777 abort: unsupported platform
776 778 [255]
777 779
778 780 #endif
779 781
780 782 $ cd ..
781 783
782 784 Test that accessing to invalid changelog cache is avoided at
783 785 subsequent operations even if repo object is reused even after failure
784 786 of transaction (see 0a7610758c42 also)
785 787
786 788 "hg log" after failure of transaction is needed to detect invalid
787 789 cache in repoview: this can't detect by "hg verify" only.
788 790
789 791 Combination of "finalization" and "empty-ness of changelog" (2 x 2 =
790 792 4) are tested, because '00changelog.i' are differently changed in each
791 793 cases.
792 794
793 795 $ cat > $TESTTMP/failafterfinalize.py <<EOF
794 796 > # extension to abort transaction after finalization forcibly
795 797 > from mercurial import commands, error, extensions, lock as lockmod
796 798 > def fail(tr):
797 799 > raise error.Abort('fail after finalization')
798 800 > def reposetup(ui, repo):
799 801 > class failrepo(repo.__class__):
800 802 > def commitctx(self, ctx, error=False):
801 803 > if self.ui.configbool('failafterfinalize', 'fail'):
802 804 > # 'sorted()' by ASCII code on category names causes
803 805 > # invoking 'fail' after finalization of changelog
804 806 > # using "'cl-%i' % id(self)" as category name
805 807 > self.currenttransaction().addfinalize('zzzzzzzz', fail)
806 808 > return super(failrepo, self).commitctx(ctx, error)
807 809 > repo.__class__ = failrepo
808 810 > EOF
809 811
810 812 $ hg init repo3
811 813 $ cd repo3
812 814
813 815 $ cat <<EOF >> $HGRCPATH
814 816 > [ui]
815 817 > logtemplate = {rev} {desc|firstline} ({files})\n
816 818 >
817 819 > [extensions]
818 820 > failafterfinalize = $TESTTMP/failafterfinalize.py
819 821 > EOF
820 822
821 823 - test failure with "empty changelog"
822 824
823 825 $ echo foo > foo
824 826 $ hg add foo
825 827
826 828 (failure before finalization)
827 829
828 830 >>> from hgclient import readchannel, runcommand, check
829 831 >>> @check
830 832 ... def abort(server):
831 833 ... readchannel(server)
832 834 ... runcommand(server, ['commit',
833 835 ... '--config', 'hooks.pretxncommit=false',
834 836 ... '-mfoo'])
835 837 ... runcommand(server, ['log'])
836 838 ... runcommand(server, ['verify', '-q'])
837 839 *** runcommand commit --config hooks.pretxncommit=false -mfoo
838 840 transaction abort!
839 841 rollback completed
840 842 abort: pretxncommit hook exited with status 1
841 843 [255]
842 844 *** runcommand log
843 845 *** runcommand verify -q
844 846
845 847 (failure after finalization)
846 848
847 849 >>> from hgclient import readchannel, runcommand, check
848 850 >>> @check
849 851 ... def abort(server):
850 852 ... readchannel(server)
851 853 ... runcommand(server, ['commit',
852 854 ... '--config', 'failafterfinalize.fail=true',
853 855 ... '-mfoo'])
854 856 ... runcommand(server, ['log'])
855 857 ... runcommand(server, ['verify', '-q'])
856 858 *** runcommand commit --config failafterfinalize.fail=true -mfoo
857 859 transaction abort!
858 860 rollback completed
859 861 abort: fail after finalization
860 862 [255]
861 863 *** runcommand log
862 864 *** runcommand verify -q
863 865
864 866 - test failure with "not-empty changelog"
865 867
866 868 $ echo bar > bar
867 869 $ hg add bar
868 870 $ hg commit -mbar bar
869 871
870 872 (failure before finalization)
871 873
872 874 >>> from hgclient import readchannel, runcommand, check
873 875 >>> @check
874 876 ... def abort(server):
875 877 ... readchannel(server)
876 878 ... runcommand(server, ['commit',
877 879 ... '--config', 'hooks.pretxncommit=false',
878 880 ... '-mfoo', 'foo'])
879 881 ... runcommand(server, ['log'])
880 882 ... runcommand(server, ['verify', '-q'])
881 883 *** runcommand commit --config hooks.pretxncommit=false -mfoo foo
882 884 transaction abort!
883 885 rollback completed
884 886 abort: pretxncommit hook exited with status 1
885 887 [255]
886 888 *** runcommand log
887 889 0 bar (bar)
888 890 *** runcommand verify -q
889 891
890 892 (failure after finalization)
891 893
892 894 >>> from hgclient import readchannel, runcommand, check
893 895 >>> @check
894 896 ... def abort(server):
895 897 ... readchannel(server)
896 898 ... runcommand(server, ['commit',
897 899 ... '--config', 'failafterfinalize.fail=true',
898 900 ... '-mfoo', 'foo'])
899 901 ... runcommand(server, ['log'])
900 902 ... runcommand(server, ['verify', '-q'])
901 903 *** runcommand commit --config failafterfinalize.fail=true -mfoo foo
902 904 transaction abort!
903 905 rollback completed
904 906 abort: fail after finalization
905 907 [255]
906 908 *** runcommand log
907 909 0 bar (bar)
908 910 *** runcommand verify -q
@@ -1,419 +1,427 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/fsmonitor.state (fsmonitor !)
96 96 .hg/last-message.txt
97 97 .hg/phaseroots
98 98 .hg/requires
99 99 .hg/undo
100 100 .hg/undo.backup.dirstate
101 101 .hg/undo.backupfiles
102 102 .hg/undo.bookmarks
103 103 .hg/undo.branch
104 104 .hg/undo.desc
105 105 .hg/undo.dirstate
106 106 .hg/undo.phaseroots
107 107 $ cd ..
108 108
109 109 Non fncache repo:
110 110
111 111 $ hg --config format.usefncache=False init bar
112 112 $ cd bar
113 113 $ mkdir tst.d
114 114 $ echo foo > tst.d/Foo
115 115 $ hg ci -Amfoo
116 116 adding tst.d/Foo
117 117 $ find .hg | sort
118 118 .hg
119 119 .hg/00changelog.i
120 120 .hg/cache
121 121 .hg/cache/branch2-served
122 122 .hg/cache/rbc-names-v1
123 123 .hg/cache/rbc-revs-v1
124 124 .hg/dirstate
125 125 .hg/fsmonitor.state (fsmonitor !)
126 126 .hg/last-message.txt
127 127 .hg/requires
128 128 .hg/store
129 129 .hg/store/00changelog.i
130 130 .hg/store/00manifest.i
131 131 .hg/store/data
132 132 .hg/store/data/tst.d.hg
133 133 .hg/store/data/tst.d.hg/_foo.i
134 134 .hg/store/phaseroots
135 135 .hg/store/undo
136 136 .hg/store/undo.backupfiles
137 137 .hg/store/undo.phaseroots
138 138 .hg/undo.backup.dirstate
139 139 .hg/undo.bookmarks
140 140 .hg/undo.branch
141 141 .hg/undo.desc
142 142 .hg/undo.dirstate
143 143 $ cd ..
144 144
145 145 Encoding of reserved / long paths in the store
146 146
147 147 $ hg init r2
148 148 $ cd r2
149 149 $ cat <<EOF > .hg/hgrc
150 150 > [ui]
151 151 > portablefilenames = ignore
152 152 > EOF
153 153
154 154 $ hg import -q --bypass - <<EOF
155 155 > # HG changeset patch
156 156 > # User test
157 157 > # Date 0 0
158 158 > # Node ID 1c7a2f7cb77be1a0def34e4c7cabc562ad98fbd7
159 159 > # Parent 0000000000000000000000000000000000000000
160 160 > 1
161 161 >
162 162 > 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
163 163 > new file mode 100644
164 164 > --- /dev/null
165 165 > +++ b/12345678/12345678/12345678/12345678/12345678/12345678/12345678/12345/xxxxxxxxx-xxxxxxxxx-xxxxxxxxx-123456789-12.3456789-12345-ABCDEFGHIJKLMNOPRSTUVWXYZ-abcdefghjiklmnopqrstuvwxyz
166 166 > @@ -0,0 +1,1 @@
167 167 > +foo
168 168 > 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
169 169 > new file mode 100644
170 170 > --- /dev/null
171 171 > +++ b/AUX/SECOND/X.PRN/FOURTH/FI:FTH/SIXTH/SEVENTH/EIGHTH/NINETH/TENTH/ELEVENTH/LOREMIPSUM.TXT
172 172 > @@ -0,0 +1,1 @@
173 173 > +foo
174 174 > diff --git a/Project Planning/Resources/AnotherLongDirectoryName/Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt b/Project Planning/Resources/AnotherLongDirectoryName/Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt
175 175 > new file mode 100644
176 176 > --- /dev/null
177 177 > +++ b/Project Planning/Resources/AnotherLongDirectoryName/Followedbyanother/AndAnother/AndThenAnExtremelyLongFileName.txt
178 178 > @@ -0,0 +1,1 @@
179 179 > +foo
180 180 > 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
181 181 > new file mode 100644
182 182 > --- /dev/null
183 183 > +++ b/bla.aux/prn/PRN/lpt/com3/nul/coma/foo.NUL/normal.c
184 184 > @@ -0,0 +1,1 @@
185 185 > +foo
186 186 > 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
187 187 > new file mode 100644
188 188 > --- /dev/null
189 189 > +++ b/enterprise/openesbaddons/contrib-imola/corba-bc/netbeansplugin/wsdlExtension/src/main/java/META-INF/services/org.netbeans.modules.xml.wsdl.bindingsupport.spi.ExtensibilityElementTemplateProvider
190 190 > @@ -0,0 +1,1 @@
191 191 > +foo
192 192 > EOF
193 193
194 194 $ find .hg/store -name *.i | sort
195 195 .hg/store/00changelog.i
196 196 .hg/store/00manifest.i
197 197 .hg/store/data/bla.aux/pr~6e/_p_r_n/lpt/co~6d3/nu~6c/coma/foo._n_u_l/normal.c.i
198 198 .hg/store/dh/12345678/12345678/12345678/12345678/12345678/12345678/12345678/12345/xxxxxx168e07b38e65eff86ab579afaaa8e30bfbe0f35f.i
199 199 .hg/store/dh/au~78/second/x.prn/fourth/fi~3afth/sixth/seventh/eighth/nineth/tenth/loremia20419e358ddff1bf8751e38288aff1d7c32ec05.i
200 200 .hg/store/dh/enterpri/openesba/contrib-/corba-bc/netbeans/wsdlexte/src/main/java/org.net7018f27961fdf338a598a40c4683429e7ffb9743.i
201 201 .hg/store/dh/project_/resource/anotherl/followed/andanoth/andthenanextremelylongfilename0d8e1f4187c650e2f1fdca9fd90f786bc0976b6b.i
202 202
203 203 $ cd ..
204 204
205 205 Aborting lock does not prevent fncache writes
206 206
207 207 $ cat > exceptionext.py <<EOF
208 208 > import os
209 209 > from mercurial import commands, error
210 210 > from mercurial.extensions import wrapcommand, wrapfunction
211 211 >
212 212 > def lockexception(orig, vfs, lockname, wait, releasefn, *args, **kwargs):
213 213 > def releasewrap():
214 214 > l.held = False # ensure __del__ is a noop
215 215 > raise error.Abort("forced lock failure")
216 216 > l = orig(vfs, lockname, wait, releasewrap, *args, **kwargs)
217 217 > return l
218 218 >
219 219 > def reposetup(ui, repo):
220 220 > wrapfunction(repo, '_lock', lockexception)
221 221 >
222 222 > cmdtable = {}
223 223 >
224 224 > # wrap "commit" command to prevent wlock from being '__del__()'-ed
225 225 > # at the end of dispatching (for intentional "forced lcok failure")
226 226 > def commitwrap(orig, ui, repo, *pats, **opts):
227 227 > repo = repo.unfiltered() # to use replaced repo._lock certainly
228 228 > wlock = repo.wlock()
229 229 > try:
230 230 > return orig(ui, repo, *pats, **opts)
231 231 > finally:
232 232 > # multiple 'relase()' is needed for complete releasing wlock,
233 233 > # because "forced" abort at last releasing store lock
234 234 > # prevents wlock from being released at same 'lockmod.release()'
235 235 > for i in range(wlock.held):
236 236 > wlock.release()
237 237 >
238 238 > def extsetup(ui):
239 239 > wrapcommand(commands.table, "commit", commitwrap)
240 240 > EOF
241 241 $ extpath=`pwd`/exceptionext.py
242 242 $ hg init fncachetxn
243 243 $ cd fncachetxn
244 244 $ printf "[extensions]\nexceptionext=$extpath\n" >> .hg/hgrc
245 245 $ touch y
246 246 $ hg ci -qAm y
247 247 abort: forced lock failure
248 248 [255]
249 249 $ cat .hg/store/fncache
250 250 data/y.i
251 251
252 252 Aborting transaction prevents fncache change
253 253
254 254 $ cat > ../exceptionext.py <<EOF
255 255 > import os
256 256 > from mercurial import commands, error, localrepo
257 257 > from mercurial.extensions import wrapfunction
258 258 >
259 259 > def wrapper(orig, self, *args, **kwargs):
260 260 > tr = orig(self, *args, **kwargs)
261 261 > def fail(tr):
262 262 > raise error.Abort("forced transaction failure")
263 263 > # zzz prefix to ensure it sorted after store.write
264 264 > tr.addfinalize('zzz-forcefails', fail)
265 265 > return tr
266 266 >
267 267 > def uisetup(ui):
268 268 > wrapfunction(localrepo.localrepository, 'transaction', wrapper)
269 269 >
270 270 > cmdtable = {}
271 271 >
272 272 > EOF
273
274 Clean cached version
273 275 $ rm -f "${extpath}c"
276 $ rm -Rf "`dirname $extpath`/__pycache__"
277
274 278 $ touch z
275 279 $ hg ci -qAm z
276 280 transaction abort!
277 281 rollback completed
278 282 abort: forced transaction failure
279 283 [255]
280 284 $ cat .hg/store/fncache
281 285 data/y.i
282 286
283 287 Aborted transactions can be recovered later
284 288
285 289 $ cat > ../exceptionext.py <<EOF
286 290 > import os
287 291 > from mercurial import commands, error, transaction, localrepo
288 292 > from mercurial.extensions import wrapfunction
289 293 >
290 294 > def trwrapper(orig, self, *args, **kwargs):
291 295 > tr = orig(self, *args, **kwargs)
292 296 > def fail(tr):
293 297 > raise error.Abort("forced transaction failure")
294 298 > # zzz prefix to ensure it sorted after store.write
295 299 > tr.addfinalize('zzz-forcefails', fail)
296 300 > return tr
297 301 >
298 302 > def abortwrapper(orig, self, *args, **kwargs):
299 303 > raise error.Abort("forced transaction failure")
300 304 >
301 305 > def uisetup(ui):
302 306 > wrapfunction(localrepo.localrepository, 'transaction', trwrapper)
303 307 > wrapfunction(transaction.transaction, '_abort', abortwrapper)
304 308 >
305 309 > cmdtable = {}
306 310 >
307 311 > EOF
312
313 Clean cached versions
308 314 $ rm -f "${extpath}c"
315 $ rm -Rf "`dirname $extpath`/__pycache__"
316
309 317 $ hg up -q 1
310 318 $ touch z
311 319 $ hg ci -qAm z 2>/dev/null
312 320 [255]
313 321 $ cat .hg/store/fncache | sort
314 322 data/y.i
315 323 data/z.i
316 324 $ hg recover
317 325 rolling back interrupted transaction
318 326 checking changesets
319 327 checking manifests
320 328 crosschecking files in changesets and manifests
321 329 checking files
322 330 1 files, 1 changesets, 1 total revisions
323 331 $ cat .hg/store/fncache
324 332 data/y.i
325 333
326 334 $ cd ..
327 335
328 336 debugrebuildfncache does nothing unless repo has fncache requirement
329 337
330 338 $ hg --config format.usefncache=false init nofncache
331 339 $ cd nofncache
332 340 $ hg debugrebuildfncache
333 341 (not rebuilding fncache because repository does not support fncache)
334 342
335 343 $ cd ..
336 344
337 345 debugrebuildfncache works on empty repository
338 346
339 347 $ hg init empty
340 348 $ cd empty
341 349 $ hg debugrebuildfncache
342 350 fncache already up to date
343 351 $ cd ..
344 352
345 353 debugrebuildfncache on an up to date repository no-ops
346 354
347 355 $ hg init repo
348 356 $ cd repo
349 357 $ echo initial > foo
350 358 $ echo initial > .bar
351 359 $ hg commit -A -m initial
352 360 adding .bar
353 361 adding foo
354 362
355 363 $ cat .hg/store/fncache | sort
356 364 data/.bar.i
357 365 data/foo.i
358 366
359 367 $ hg debugrebuildfncache
360 368 fncache already up to date
361 369
362 370 debugrebuildfncache restores deleted fncache file
363 371
364 372 $ rm -f .hg/store/fncache
365 373 $ hg debugrebuildfncache
366 374 adding data/.bar.i
367 375 adding data/foo.i
368 376 2 items added, 0 removed from fncache
369 377
370 378 $ cat .hg/store/fncache | sort
371 379 data/.bar.i
372 380 data/foo.i
373 381
374 382 Rebuild after rebuild should no-op
375 383
376 384 $ hg debugrebuildfncache
377 385 fncache already up to date
378 386
379 387 A single missing file should get restored, an extra file should be removed
380 388
381 389 $ cat > .hg/store/fncache << EOF
382 390 > data/foo.i
383 391 > data/bad-entry.i
384 392 > EOF
385 393
386 394 $ hg debugrebuildfncache
387 395 removing data/bad-entry.i
388 396 adding data/.bar.i
389 397 1 items added, 1 removed from fncache
390 398
391 399 $ cat .hg/store/fncache | sort
392 400 data/.bar.i
393 401 data/foo.i
394 402
395 403 $ cd ..
396 404
397 405 Try a simple variation without dotencode to ensure fncache is ignorant of encoding
398 406
399 407 $ hg --config format.dotencode=false init nodotencode
400 408 $ cd nodotencode
401 409 $ echo initial > foo
402 410 $ echo initial > .bar
403 411 $ hg commit -A -m initial
404 412 adding .bar
405 413 adding foo
406 414
407 415 $ cat .hg/store/fncache | sort
408 416 data/.bar.i
409 417 data/foo.i
410 418
411 419 $ rm .hg/store/fncache
412 420 $ hg debugrebuildfncache
413 421 adding data/.bar.i
414 422 adding data/foo.i
415 423 2 items added, 0 removed from fncache
416 424
417 425 $ cat .hg/store/fncache | sort
418 426 data/.bar.i
419 427 data/foo.i
General Comments 0
You need to be logged in to leave comments. Login now