##// END OF EJS Templates
configitems: register the test 'failafterfinalize.fail' config
Boris Feld -
r34766:f3e4a5ad default
parent child Browse files
Show More
@@ -1,1004 +1,1012 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 absolute_import, print_function
17 17 >>> import os
18 18 >>> import sys
19 19 >>> from hgclient import check, readchannel, runcommand
20 20 >>> @check
21 21 ... def hellomessage(server):
22 22 ... ch, data = readchannel(server)
23 23 ... print('%c, %r' % (ch, data))
24 24 ... # run an arbitrary command to make sure the next thing the server
25 25 ... # sends isn't part of the hello message
26 26 ... runcommand(server, ['id'])
27 27 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
28 28 *** runcommand id
29 29 000000000000 tip
30 30
31 31 >>> from hgclient import check
32 32 >>> @check
33 33 ... def unknowncommand(server):
34 34 ... server.stdin.write('unknowncommand\n')
35 35 abort: unknown command unknowncommand
36 36
37 37 >>> from hgclient import check, readchannel, runcommand
38 38 >>> @check
39 39 ... def checkruncommand(server):
40 40 ... # hello block
41 41 ... readchannel(server)
42 42 ...
43 43 ... # no args
44 44 ... runcommand(server, [])
45 45 ...
46 46 ... # global options
47 47 ... runcommand(server, ['id', '--quiet'])
48 48 ...
49 49 ... # make sure global options don't stick through requests
50 50 ... runcommand(server, ['id'])
51 51 ...
52 52 ... # --config
53 53 ... runcommand(server, ['id', '--config', 'ui.quiet=True'])
54 54 ...
55 55 ... # make sure --config doesn't stick
56 56 ... runcommand(server, ['id'])
57 57 ...
58 58 ... # negative return code should be masked
59 59 ... runcommand(server, ['id', '-runknown'])
60 60 *** runcommand
61 61 Mercurial Distributed SCM
62 62
63 63 basic commands:
64 64
65 65 add add the specified files on the next commit
66 66 annotate show changeset information by line for each file
67 67 clone make a copy of an existing repository
68 68 commit commit the specified files or all outstanding changes
69 69 diff diff repository (or selected files)
70 70 export dump the header and diffs for one or more changesets
71 71 forget forget the specified files on the next commit
72 72 init create a new repository in the given directory
73 73 log show revision history of entire repository or files
74 74 merge merge another revision into working directory
75 75 pull pull changes from the specified source
76 76 push push changes to the specified destination
77 77 remove remove the specified files on the next commit
78 78 serve start stand-alone webserver
79 79 status show changed files in the working directory
80 80 summary summarize working directory state
81 81 update update working directory (or switch revisions)
82 82
83 83 (use 'hg help' for the full list of commands or 'hg -v' for details)
84 84 *** runcommand id --quiet
85 85 000000000000
86 86 *** runcommand id
87 87 000000000000 tip
88 88 *** runcommand id --config ui.quiet=True
89 89 000000000000
90 90 *** runcommand id
91 91 000000000000 tip
92 92 *** runcommand id -runknown
93 93 abort: unknown revision 'unknown'!
94 94 [255]
95 95
96 96 >>> from hgclient import check, readchannel
97 97 >>> @check
98 98 ... def inputeof(server):
99 99 ... readchannel(server)
100 100 ... server.stdin.write('runcommand\n')
101 101 ... # close stdin while server is waiting for input
102 102 ... server.stdin.close()
103 103 ...
104 104 ... # server exits with 1 if the pipe closed while reading the command
105 105 ... print('server exit code =', server.wait())
106 106 server exit code = 1
107 107
108 108 >>> from hgclient import check, readchannel, runcommand, stringio
109 109 >>> @check
110 110 ... def serverinput(server):
111 111 ... readchannel(server)
112 112 ...
113 113 ... patch = """
114 114 ... # HG changeset patch
115 115 ... # User test
116 116 ... # Date 0 0
117 117 ... # Node ID c103a3dec114d882c98382d684d8af798d09d857
118 118 ... # Parent 0000000000000000000000000000000000000000
119 119 ... 1
120 120 ...
121 121 ... diff -r 000000000000 -r c103a3dec114 a
122 122 ... --- /dev/null Thu Jan 01 00:00:00 1970 +0000
123 123 ... +++ b/a Thu Jan 01 00:00:00 1970 +0000
124 124 ... @@ -0,0 +1,1 @@
125 125 ... +1
126 126 ... """
127 127 ...
128 128 ... runcommand(server, ['import', '-'], input=stringio(patch))
129 129 ... runcommand(server, ['log'])
130 130 *** runcommand import -
131 131 applying patch from stdin
132 132 *** runcommand log
133 133 changeset: 0:eff892de26ec
134 134 tag: tip
135 135 user: test
136 136 date: Thu Jan 01 00:00:00 1970 +0000
137 137 summary: 1
138 138
139 139
140 140 check that "histedit --commands=-" can read rules from the input channel:
141 141
142 142 >>> import cStringIO
143 143 >>> from hgclient import check, readchannel, runcommand
144 144 >>> @check
145 145 ... def serverinput(server):
146 146 ... readchannel(server)
147 147 ... rules = 'pick eff892de26ec\n'
148 148 ... runcommand(server, ['histedit', '0', '--commands=-',
149 149 ... '--config', 'extensions.histedit='],
150 150 ... input=cStringIO.StringIO(rules))
151 151 *** runcommand histedit 0 --commands=- --config extensions.histedit=
152 152
153 153 check that --cwd doesn't persist between requests:
154 154
155 155 $ mkdir foo
156 156 $ touch foo/bar
157 157 >>> from hgclient import check, readchannel, runcommand
158 158 >>> @check
159 159 ... def cwd(server):
160 160 ... readchannel(server)
161 161 ... runcommand(server, ['--cwd', 'foo', 'st', 'bar'])
162 162 ... runcommand(server, ['st', 'foo/bar'])
163 163 *** runcommand --cwd foo st bar
164 164 ? bar
165 165 *** runcommand st foo/bar
166 166 ? foo/bar
167 167
168 168 $ rm foo/bar
169 169
170 170
171 171 check that local configs for the cached repo aren't inherited when -R is used:
172 172
173 173 $ cat <<EOF >> .hg/hgrc
174 174 > [ui]
175 175 > foo = bar
176 176 > EOF
177 177
178 178 >>> from hgclient import check, readchannel, runcommand, sep
179 179 >>> @check
180 180 ... def localhgrc(server):
181 181 ... readchannel(server)
182 182 ...
183 183 ... # the cached repo local hgrc contains ui.foo=bar, so showconfig should
184 184 ... # show it
185 185 ... runcommand(server, ['showconfig'], outfilter=sep)
186 186 ...
187 187 ... # but not for this repo
188 188 ... runcommand(server, ['init', 'foo'])
189 189 ... runcommand(server, ['-R', 'foo', 'showconfig', 'ui', 'defaults'])
190 190 *** runcommand showconfig
191 191 bundle.mainreporoot=$TESTTMP/repo
192 192 devel.all-warnings=true
193 193 devel.default-date=0 0
194 194 extensions.fsmonitor= (fsmonitor !)
195 195 largefiles.usercache=$TESTTMP/.cache/largefiles
196 196 ui.slash=True
197 197 ui.interactive=False
198 198 ui.mergemarkers=detailed
199 199 ui.usehttp2=true (?)
200 200 ui.foo=bar
201 201 ui.nontty=true
202 202 web.address=localhost
203 203 web\.ipv6=(?:True|False) (re)
204 204 *** runcommand init foo
205 205 *** runcommand -R foo showconfig ui defaults
206 206 ui.slash=True
207 207 ui.interactive=False
208 208 ui.mergemarkers=detailed
209 209 ui.usehttp2=true (?)
210 210 ui.nontty=true
211 211
212 212 $ rm -R foo
213 213
214 214 #if windows
215 215 $ PYTHONPATH="$TESTTMP/repo;$PYTHONPATH"
216 216 #else
217 217 $ PYTHONPATH="$TESTTMP/repo:$PYTHONPATH"
218 218 #endif
219 219
220 220 $ cat <<EOF > hook.py
221 221 > from __future__ import print_function
222 222 > import sys
223 223 > def hook(**args):
224 224 > print('hook talking')
225 225 > print('now try to read something: %r' % sys.stdin.read())
226 226 > EOF
227 227
228 228 >>> from hgclient import check, readchannel, runcommand, stringio
229 229 >>> @check
230 230 ... def hookoutput(server):
231 231 ... readchannel(server)
232 232 ... runcommand(server, ['--config',
233 233 ... 'hooks.pre-identify=python:hook.hook',
234 234 ... 'id'],
235 235 ... input=stringio('some input'))
236 236 *** runcommand --config hooks.pre-identify=python:hook.hook id
237 237 eff892de26ec tip
238 238
239 239 Clean hook cached version
240 240 $ rm hook.py*
241 241 $ rm -Rf __pycache__
242 242
243 243 $ echo a >> a
244 244 >>> import os
245 245 >>> from hgclient import check, readchannel, runcommand
246 246 >>> @check
247 247 ... def outsidechanges(server):
248 248 ... readchannel(server)
249 249 ... runcommand(server, ['status'])
250 250 ... os.system('hg ci -Am2')
251 251 ... runcommand(server, ['tip'])
252 252 ... runcommand(server, ['status'])
253 253 *** runcommand status
254 254 M a
255 255 *** runcommand tip
256 256 changeset: 1:d3a0a68be6de
257 257 tag: tip
258 258 user: test
259 259 date: Thu Jan 01 00:00:00 1970 +0000
260 260 summary: 2
261 261
262 262 *** runcommand status
263 263
264 264 >>> import os
265 265 >>> from hgclient import check, readchannel, runcommand
266 266 >>> @check
267 267 ... def bookmarks(server):
268 268 ... readchannel(server)
269 269 ... runcommand(server, ['bookmarks'])
270 270 ...
271 271 ... # changes .hg/bookmarks
272 272 ... os.system('hg bookmark -i bm1')
273 273 ... os.system('hg bookmark -i bm2')
274 274 ... runcommand(server, ['bookmarks'])
275 275 ...
276 276 ... # changes .hg/bookmarks.current
277 277 ... os.system('hg upd bm1 -q')
278 278 ... runcommand(server, ['bookmarks'])
279 279 ...
280 280 ... runcommand(server, ['bookmarks', 'bm3'])
281 281 ... f = open('a', 'ab')
282 282 ... f.write('a\n')
283 283 ... f.close()
284 284 ... runcommand(server, ['commit', '-Amm'])
285 285 ... runcommand(server, ['bookmarks'])
286 286 ... print('')
287 287 *** runcommand bookmarks
288 288 no bookmarks set
289 289 *** runcommand bookmarks
290 290 bm1 1:d3a0a68be6de
291 291 bm2 1:d3a0a68be6de
292 292 *** runcommand bookmarks
293 293 * bm1 1:d3a0a68be6de
294 294 bm2 1:d3a0a68be6de
295 295 *** runcommand bookmarks bm3
296 296 *** runcommand commit -Amm
297 297 *** runcommand bookmarks
298 298 bm1 1:d3a0a68be6de
299 299 bm2 1:d3a0a68be6de
300 300 * bm3 2:aef17e88f5f0
301 301
302 302
303 303 >>> import os
304 304 >>> from hgclient import check, readchannel, runcommand
305 305 >>> @check
306 306 ... def tagscache(server):
307 307 ... readchannel(server)
308 308 ... runcommand(server, ['id', '-t', '-r', '0'])
309 309 ... os.system('hg tag -r 0 foo')
310 310 ... runcommand(server, ['id', '-t', '-r', '0'])
311 311 *** runcommand id -t -r 0
312 312
313 313 *** runcommand id -t -r 0
314 314 foo
315 315
316 316 >>> import os
317 317 >>> from hgclient import check, readchannel, runcommand
318 318 >>> @check
319 319 ... def setphase(server):
320 320 ... readchannel(server)
321 321 ... runcommand(server, ['phase', '-r', '.'])
322 322 ... os.system('hg phase -r . -p')
323 323 ... runcommand(server, ['phase', '-r', '.'])
324 324 *** runcommand phase -r .
325 325 3: draft
326 326 *** runcommand phase -r .
327 327 3: public
328 328
329 329 $ echo a >> a
330 330 >>> from hgclient import check, readchannel, runcommand
331 331 >>> @check
332 332 ... def rollback(server):
333 333 ... readchannel(server)
334 334 ... runcommand(server, ['phase', '-r', '.', '-p'])
335 335 ... runcommand(server, ['commit', '-Am.'])
336 336 ... runcommand(server, ['rollback'])
337 337 ... runcommand(server, ['phase', '-r', '.'])
338 338 ... print('')
339 339 *** runcommand phase -r . -p
340 340 no phases changed
341 341 *** runcommand commit -Am.
342 342 *** runcommand rollback
343 343 repository tip rolled back to revision 3 (undo commit)
344 344 working directory now based on revision 3
345 345 *** runcommand phase -r .
346 346 3: public
347 347
348 348
349 349 >>> import os
350 350 >>> from hgclient import check, readchannel, runcommand
351 351 >>> @check
352 352 ... def branch(server):
353 353 ... readchannel(server)
354 354 ... runcommand(server, ['branch'])
355 355 ... os.system('hg branch foo')
356 356 ... runcommand(server, ['branch'])
357 357 ... os.system('hg branch default')
358 358 *** runcommand branch
359 359 default
360 360 marked working directory as branch foo
361 361 (branches are permanent and global, did you want a bookmark?)
362 362 *** runcommand branch
363 363 foo
364 364 marked working directory as branch default
365 365 (branches are permanent and global, did you want a bookmark?)
366 366
367 367 $ touch .hgignore
368 368 >>> import os
369 369 >>> from hgclient import check, readchannel, runcommand
370 370 >>> @check
371 371 ... def hgignore(server):
372 372 ... readchannel(server)
373 373 ... runcommand(server, ['commit', '-Am.'])
374 374 ... f = open('ignored-file', 'ab')
375 375 ... f.write('')
376 376 ... f.close()
377 377 ... f = open('.hgignore', 'ab')
378 378 ... f.write('ignored-file')
379 379 ... f.close()
380 380 ... runcommand(server, ['status', '-i', '-u'])
381 381 ... print('')
382 382 *** runcommand commit -Am.
383 383 adding .hgignore
384 384 *** runcommand status -i -u
385 385 I ignored-file
386 386
387 387
388 388 cache of non-public revisions should be invalidated on repository change
389 389 (issue4855):
390 390
391 391 >>> import os
392 392 >>> from hgclient import check, readchannel, runcommand
393 393 >>> @check
394 394 ... def phasesetscacheaftercommit(server):
395 395 ... readchannel(server)
396 396 ... # load _phasecache._phaserevs and _phasesets
397 397 ... runcommand(server, ['log', '-qr', 'draft()'])
398 398 ... # create draft commits by another process
399 399 ... for i in xrange(5, 7):
400 400 ... f = open('a', 'ab')
401 401 ... f.seek(0, os.SEEK_END)
402 402 ... f.write('a\n')
403 403 ... f.close()
404 404 ... os.system('hg commit -Aqm%d' % i)
405 405 ... # new commits should be listed as draft revisions
406 406 ... runcommand(server, ['log', '-qr', 'draft()'])
407 407 ... print('')
408 408 *** runcommand log -qr draft()
409 409 4:7966c8e3734d
410 410 *** runcommand log -qr draft()
411 411 4:7966c8e3734d
412 412 5:41f6602d1c4f
413 413 6:10501e202c35
414 414
415 415
416 416 >>> import os
417 417 >>> from hgclient import check, readchannel, runcommand
418 418 >>> @check
419 419 ... def phasesetscacheafterstrip(server):
420 420 ... readchannel(server)
421 421 ... # load _phasecache._phaserevs and _phasesets
422 422 ... runcommand(server, ['log', '-qr', 'draft()'])
423 423 ... # strip cached revisions by another process
424 424 ... os.system('hg --config extensions.strip= strip -q 5')
425 425 ... # shouldn't abort by "unknown revision '6'"
426 426 ... runcommand(server, ['log', '-qr', 'draft()'])
427 427 ... print('')
428 428 *** runcommand log -qr draft()
429 429 4:7966c8e3734d
430 430 5:41f6602d1c4f
431 431 6:10501e202c35
432 432 *** runcommand log -qr draft()
433 433 4:7966c8e3734d
434 434
435 435
436 436 cache of phase roots should be invalidated on strip (issue3827):
437 437
438 438 >>> import os
439 439 >>> from hgclient import check, readchannel, runcommand, sep
440 440 >>> @check
441 441 ... def phasecacheafterstrip(server):
442 442 ... readchannel(server)
443 443 ...
444 444 ... # create new head, 5:731265503d86
445 445 ... runcommand(server, ['update', '-C', '0'])
446 446 ... f = open('a', 'ab')
447 447 ... f.write('a\n')
448 448 ... f.close()
449 449 ... runcommand(server, ['commit', '-Am.', 'a'])
450 450 ... runcommand(server, ['log', '-Gq'])
451 451 ...
452 452 ... # make it public; draft marker moves to 4:7966c8e3734d
453 453 ... runcommand(server, ['phase', '-p', '.'])
454 454 ... # load _phasecache.phaseroots
455 455 ... runcommand(server, ['phase', '.'], outfilter=sep)
456 456 ...
457 457 ... # strip 1::4 outside server
458 458 ... os.system('hg -q --config extensions.mq= strip 1')
459 459 ...
460 460 ... # shouldn't raise "7966c8e3734d: no node!"
461 461 ... runcommand(server, ['branches'])
462 462 *** runcommand update -C 0
463 463 1 files updated, 0 files merged, 2 files removed, 0 files unresolved
464 464 (leaving bookmark bm3)
465 465 *** runcommand commit -Am. a
466 466 created new head
467 467 *** runcommand log -Gq
468 468 @ 5:731265503d86
469 469 |
470 470 | o 4:7966c8e3734d
471 471 | |
472 472 | o 3:b9b85890c400
473 473 | |
474 474 | o 2:aef17e88f5f0
475 475 | |
476 476 | o 1:d3a0a68be6de
477 477 |/
478 478 o 0:eff892de26ec
479 479
480 480 *** runcommand phase -p .
481 481 *** runcommand phase .
482 482 5: public
483 483 *** runcommand branches
484 484 default 1:731265503d86
485 485
486 486 in-memory cache must be reloaded if transaction is aborted. otherwise
487 487 changelog and manifest would have invalid node:
488 488
489 489 $ echo a >> a
490 490 >>> from hgclient import check, readchannel, runcommand
491 491 >>> @check
492 492 ... def txabort(server):
493 493 ... readchannel(server)
494 494 ... runcommand(server, ['commit', '--config', 'hooks.pretxncommit=false',
495 495 ... '-mfoo'])
496 496 ... runcommand(server, ['verify'])
497 497 *** runcommand commit --config hooks.pretxncommit=false -mfoo
498 498 transaction abort!
499 499 rollback completed
500 500 abort: pretxncommit hook exited with status 1
501 501 [255]
502 502 *** runcommand verify
503 503 checking changesets
504 504 checking manifests
505 505 crosschecking files in changesets and manifests
506 506 checking files
507 507 1 files, 2 changesets, 2 total revisions
508 508 $ hg revert --no-backup -aq
509 509
510 510 $ cat >> .hg/hgrc << EOF
511 511 > [experimental]
512 512 > stabilization=createmarkers
513 513 > EOF
514 514
515 515 >>> import os
516 516 >>> from hgclient import check, readchannel, runcommand
517 517 >>> @check
518 518 ... def obsolete(server):
519 519 ... readchannel(server)
520 520 ...
521 521 ... runcommand(server, ['up', 'null'])
522 522 ... runcommand(server, ['phase', '-df', 'tip'])
523 523 ... cmd = 'hg debugobsolete `hg log -r tip --template {node}`'
524 524 ... if os.name == 'nt':
525 525 ... cmd = 'sh -c "%s"' % cmd # run in sh, not cmd.exe
526 526 ... os.system(cmd)
527 527 ... runcommand(server, ['log', '--hidden'])
528 528 ... runcommand(server, ['log'])
529 529 *** runcommand up null
530 530 0 files updated, 0 files merged, 1 files removed, 0 files unresolved
531 531 *** runcommand phase -df tip
532 532 obsoleted 1 changesets
533 533 *** runcommand log --hidden
534 534 changeset: 1:731265503d86
535 535 tag: tip
536 536 user: test
537 537 date: Thu Jan 01 00:00:00 1970 +0000
538 538 summary: .
539 539
540 540 changeset: 0:eff892de26ec
541 541 bookmark: bm1
542 542 bookmark: bm2
543 543 bookmark: bm3
544 544 user: test
545 545 date: Thu Jan 01 00:00:00 1970 +0000
546 546 summary: 1
547 547
548 548 *** runcommand log
549 549 changeset: 0:eff892de26ec
550 550 bookmark: bm1
551 551 bookmark: bm2
552 552 bookmark: bm3
553 553 tag: tip
554 554 user: test
555 555 date: Thu Jan 01 00:00:00 1970 +0000
556 556 summary: 1
557 557
558 558
559 559 $ cat <<EOF >> .hg/hgrc
560 560 > [extensions]
561 561 > mq =
562 562 > EOF
563 563
564 564 >>> import os
565 565 >>> from hgclient import check, readchannel, runcommand
566 566 >>> @check
567 567 ... def mqoutsidechanges(server):
568 568 ... readchannel(server)
569 569 ...
570 570 ... # load repo.mq
571 571 ... runcommand(server, ['qapplied'])
572 572 ... os.system('hg qnew 0.diff')
573 573 ... # repo.mq should be invalidated
574 574 ... runcommand(server, ['qapplied'])
575 575 ...
576 576 ... runcommand(server, ['qpop', '--all'])
577 577 ... os.system('hg qqueue --create foo')
578 578 ... # repo.mq should be recreated to point to new queue
579 579 ... runcommand(server, ['qqueue', '--active'])
580 580 *** runcommand qapplied
581 581 *** runcommand qapplied
582 582 0.diff
583 583 *** runcommand qpop --all
584 584 popping 0.diff
585 585 patch queue now empty
586 586 *** runcommand qqueue --active
587 587 foo
588 588
589 589 $ cat <<EOF > dbgui.py
590 590 > import os
591 591 > import sys
592 592 > from mercurial import commands, registrar
593 593 > cmdtable = {}
594 594 > command = registrar.command(cmdtable)
595 595 > @command(b"debuggetpass", norepo=True)
596 596 > def debuggetpass(ui):
597 597 > ui.write("%s\\n" % ui.getpass())
598 598 > @command(b"debugprompt", norepo=True)
599 599 > def debugprompt(ui):
600 600 > ui.write("%s\\n" % ui.prompt("prompt:"))
601 601 > @command(b"debugreadstdin", norepo=True)
602 602 > def debugreadstdin(ui):
603 603 > ui.write("read: %r\n" % sys.stdin.read(1))
604 604 > @command(b"debugwritestdout", norepo=True)
605 605 > def debugwritestdout(ui):
606 606 > os.write(1, "low-level stdout fd and\n")
607 607 > sys.stdout.write("stdout should be redirected to /dev/null\n")
608 608 > sys.stdout.flush()
609 609 > EOF
610 610 $ cat <<EOF >> .hg/hgrc
611 611 > [extensions]
612 612 > dbgui = dbgui.py
613 613 > EOF
614 614
615 615 >>> from hgclient import check, readchannel, runcommand, stringio
616 616 >>> @check
617 617 ... def getpass(server):
618 618 ... readchannel(server)
619 619 ... runcommand(server, ['debuggetpass', '--config',
620 620 ... 'ui.interactive=True'],
621 621 ... input=stringio('1234\n'))
622 622 ... runcommand(server, ['debuggetpass', '--config',
623 623 ... 'ui.interactive=True'],
624 624 ... input=stringio('\n'))
625 625 ... runcommand(server, ['debuggetpass', '--config',
626 626 ... 'ui.interactive=True'],
627 627 ... input=stringio(''))
628 628 ... runcommand(server, ['debugprompt', '--config',
629 629 ... 'ui.interactive=True'],
630 630 ... input=stringio('5678\n'))
631 631 ... runcommand(server, ['debugreadstdin'])
632 632 ... runcommand(server, ['debugwritestdout'])
633 633 *** runcommand debuggetpass --config ui.interactive=True
634 634 password: 1234
635 635 *** runcommand debuggetpass --config ui.interactive=True
636 636 password:
637 637 *** runcommand debuggetpass --config ui.interactive=True
638 638 password: abort: response expected
639 639 [255]
640 640 *** runcommand debugprompt --config ui.interactive=True
641 641 prompt: 5678
642 642 *** runcommand debugreadstdin
643 643 read: ''
644 644 *** runcommand debugwritestdout
645 645
646 646
647 647 run commandserver in commandserver, which is silly but should work:
648 648
649 649 >>> from __future__ import print_function
650 650 >>> from hgclient import check, readchannel, runcommand, stringio
651 651 >>> @check
652 652 ... def nested(server):
653 653 ... print('%c, %r' % readchannel(server))
654 654 ... class nestedserver(object):
655 655 ... stdin = stringio('getencoding\n')
656 656 ... stdout = stringio()
657 657 ... runcommand(server, ['serve', '--cmdserver', 'pipe'],
658 658 ... output=nestedserver.stdout, input=nestedserver.stdin)
659 659 ... nestedserver.stdout.seek(0)
660 660 ... print('%c, %r' % readchannel(nestedserver)) # hello
661 661 ... print('%c, %r' % readchannel(nestedserver)) # getencoding
662 662 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
663 663 *** runcommand serve --cmdserver pipe
664 664 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
665 665 r, '*' (glob)
666 666
667 667
668 668 start without repository:
669 669
670 670 $ cd ..
671 671
672 672 >>> from __future__ import print_function
673 673 >>> from hgclient import check, readchannel, runcommand
674 674 >>> @check
675 675 ... def hellomessage(server):
676 676 ... ch, data = readchannel(server)
677 677 ... print('%c, %r' % (ch, data))
678 678 ... # run an arbitrary command to make sure the next thing the server
679 679 ... # sends isn't part of the hello message
680 680 ... runcommand(server, ['id'])
681 681 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
682 682 *** runcommand id
683 683 abort: there is no Mercurial repository here (.hg not found)
684 684 [255]
685 685
686 686 >>> from hgclient import check, readchannel, runcommand
687 687 >>> @check
688 688 ... def startwithoutrepo(server):
689 689 ... readchannel(server)
690 690 ... runcommand(server, ['init', 'repo2'])
691 691 ... runcommand(server, ['id', '-R', 'repo2'])
692 692 *** runcommand init repo2
693 693 *** runcommand id -R repo2
694 694 000000000000 tip
695 695
696 696
697 697 don't fall back to cwd if invalid -R path is specified (issue4805):
698 698
699 699 $ cd repo
700 700 $ hg serve --cmdserver pipe -R ../nonexistent
701 701 abort: repository ../nonexistent not found!
702 702 [255]
703 703 $ cd ..
704 704
705 705
706 706 unix domain socket:
707 707
708 708 $ cd repo
709 709 $ hg update -q
710 710
711 711 #if unix-socket unix-permissions
712 712
713 713 >>> from __future__ import print_function
714 714 >>> from hgclient import check, readchannel, runcommand, stringio, unixserver
715 715 >>> server = unixserver('.hg/server.sock', '.hg/server.log')
716 716 >>> def hellomessage(conn):
717 717 ... ch, data = readchannel(conn)
718 718 ... print('%c, %r' % (ch, data))
719 719 ... runcommand(conn, ['id'])
720 720 >>> check(hellomessage, server.connect)
721 721 o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob)
722 722 *** runcommand id
723 723 eff892de26ec tip bm1/bm2/bm3
724 724 >>> def unknowncommand(conn):
725 725 ... readchannel(conn)
726 726 ... conn.stdin.write('unknowncommand\n')
727 727 >>> check(unknowncommand, server.connect) # error sent to server.log
728 728 >>> def serverinput(conn):
729 729 ... readchannel(conn)
730 730 ... patch = """
731 731 ... # HG changeset patch
732 732 ... # User test
733 733 ... # Date 0 0
734 734 ... 2
735 735 ...
736 736 ... diff -r eff892de26ec -r 1ed24be7e7a0 a
737 737 ... --- a/a
738 738 ... +++ b/a
739 739 ... @@ -1,1 +1,2 @@
740 740 ... 1
741 741 ... +2
742 742 ... """
743 743 ... runcommand(conn, ['import', '-'], input=stringio(patch))
744 744 ... runcommand(conn, ['log', '-rtip', '-q'])
745 745 >>> check(serverinput, server.connect)
746 746 *** runcommand import -
747 747 applying patch from stdin
748 748 *** runcommand log -rtip -q
749 749 2:1ed24be7e7a0
750 750 >>> server.shutdown()
751 751
752 752 $ cat .hg/server.log
753 753 listening at .hg/server.sock
754 754 abort: unknown command unknowncommand
755 755 killed!
756 756 $ rm .hg/server.log
757 757
758 758 if server crashed before hello, traceback will be sent to 'e' channel as
759 759 last ditch:
760 760
761 761 $ cat <<EOF >> .hg/hgrc
762 762 > [cmdserver]
763 763 > log = inexistent/path.log
764 764 > EOF
765 765 >>> from __future__ import print_function
766 766 >>> from hgclient import check, readchannel, unixserver
767 767 >>> server = unixserver('.hg/server.sock', '.hg/server.log')
768 768 >>> def earlycrash(conn):
769 769 ... while True:
770 770 ... try:
771 771 ... ch, data = readchannel(conn)
772 772 ... if not data.startswith(' '):
773 773 ... print('%c, %r' % (ch, data))
774 774 ... except EOFError:
775 775 ... break
776 776 >>> check(earlycrash, server.connect)
777 777 e, 'Traceback (most recent call last):\n'
778 778 e, "IOError: *" (glob)
779 779 >>> server.shutdown()
780 780
781 781 $ cat .hg/server.log | grep -v '^ '
782 782 listening at .hg/server.sock
783 783 Traceback (most recent call last):
784 784 IOError: * (glob)
785 785 killed!
786 786 #endif
787 787 #if no-unix-socket
788 788
789 789 $ hg serve --cmdserver unix -a .hg/server.sock
790 790 abort: unsupported platform
791 791 [255]
792 792
793 793 #endif
794 794
795 795 $ cd ..
796 796
797 797 Test that accessing to invalid changelog cache is avoided at
798 798 subsequent operations even if repo object is reused even after failure
799 799 of transaction (see 0a7610758c42 also)
800 800
801 801 "hg log" after failure of transaction is needed to detect invalid
802 802 cache in repoview: this can't detect by "hg verify" only.
803 803
804 804 Combination of "finalization" and "empty-ness of changelog" (2 x 2 =
805 805 4) are tested, because '00changelog.i' are differently changed in each
806 806 cases.
807 807
808 808 $ cat > $TESTTMP/failafterfinalize.py <<EOF
809 809 > # extension to abort transaction after finalization forcibly
810 810 > from mercurial import commands, error, extensions, lock as lockmod
811 > from mercurial import registrar
812 > cmdtable = {}
813 > command = registrar.command(cmdtable)
814 > configtable = {}
815 > configitem = registrar.configitem(configtable)
816 > configitem('failafterfinalize', 'fail',
817 > default=None,
818 > )
811 819 > def fail(tr):
812 820 > raise error.Abort('fail after finalization')
813 821 > def reposetup(ui, repo):
814 822 > class failrepo(repo.__class__):
815 823 > def commitctx(self, ctx, error=False):
816 824 > if self.ui.configbool('failafterfinalize', 'fail'):
817 825 > # 'sorted()' by ASCII code on category names causes
818 826 > # invoking 'fail' after finalization of changelog
819 827 > # using "'cl-%i' % id(self)" as category name
820 828 > self.currenttransaction().addfinalize('zzzzzzzz', fail)
821 829 > return super(failrepo, self).commitctx(ctx, error)
822 830 > repo.__class__ = failrepo
823 831 > EOF
824 832
825 833 $ hg init repo3
826 834 $ cd repo3
827 835
828 836 $ cat <<EOF >> $HGRCPATH
829 837 > [ui]
830 838 > logtemplate = {rev} {desc|firstline} ({files})\n
831 839 >
832 840 > [extensions]
833 841 > failafterfinalize = $TESTTMP/failafterfinalize.py
834 842 > EOF
835 843
836 844 - test failure with "empty changelog"
837 845
838 846 $ echo foo > foo
839 847 $ hg add foo
840 848
841 849 (failure before finalization)
842 850
843 851 >>> from hgclient import check, readchannel, runcommand
844 852 >>> @check
845 853 ... def abort(server):
846 854 ... readchannel(server)
847 855 ... runcommand(server, ['commit',
848 856 ... '--config', 'hooks.pretxncommit=false',
849 857 ... '-mfoo'])
850 858 ... runcommand(server, ['log'])
851 859 ... runcommand(server, ['verify', '-q'])
852 860 *** runcommand commit --config hooks.pretxncommit=false -mfoo
853 861 transaction abort!
854 862 rollback completed
855 863 abort: pretxncommit hook exited with status 1
856 864 [255]
857 865 *** runcommand log
858 866 *** runcommand verify -q
859 867
860 868 (failure after finalization)
861 869
862 870 >>> from hgclient import check, readchannel, runcommand
863 871 >>> @check
864 872 ... def abort(server):
865 873 ... readchannel(server)
866 874 ... runcommand(server, ['commit',
867 875 ... '--config', 'failafterfinalize.fail=true',
868 876 ... '-mfoo'])
869 877 ... runcommand(server, ['log'])
870 878 ... runcommand(server, ['verify', '-q'])
871 879 *** runcommand commit --config failafterfinalize.fail=true -mfoo
872 880 transaction abort!
873 881 rollback completed
874 882 abort: fail after finalization
875 883 [255]
876 884 *** runcommand log
877 885 *** runcommand verify -q
878 886
879 887 - test failure with "not-empty changelog"
880 888
881 889 $ echo bar > bar
882 890 $ hg add bar
883 891 $ hg commit -mbar bar
884 892
885 893 (failure before finalization)
886 894
887 895 >>> from hgclient import check, readchannel, runcommand
888 896 >>> @check
889 897 ... def abort(server):
890 898 ... readchannel(server)
891 899 ... runcommand(server, ['commit',
892 900 ... '--config', 'hooks.pretxncommit=false',
893 901 ... '-mfoo', 'foo'])
894 902 ... runcommand(server, ['log'])
895 903 ... runcommand(server, ['verify', '-q'])
896 904 *** runcommand commit --config hooks.pretxncommit=false -mfoo foo
897 905 transaction abort!
898 906 rollback completed
899 907 abort: pretxncommit hook exited with status 1
900 908 [255]
901 909 *** runcommand log
902 910 0 bar (bar)
903 911 *** runcommand verify -q
904 912
905 913 (failure after finalization)
906 914
907 915 >>> from hgclient import check, readchannel, runcommand
908 916 >>> @check
909 917 ... def abort(server):
910 918 ... readchannel(server)
911 919 ... runcommand(server, ['commit',
912 920 ... '--config', 'failafterfinalize.fail=true',
913 921 ... '-mfoo', 'foo'])
914 922 ... runcommand(server, ['log'])
915 923 ... runcommand(server, ['verify', '-q'])
916 924 *** runcommand commit --config failafterfinalize.fail=true -mfoo foo
917 925 transaction abort!
918 926 rollback completed
919 927 abort: fail after finalization
920 928 [255]
921 929 *** runcommand log
922 930 0 bar (bar)
923 931 *** runcommand verify -q
924 932
925 933 $ cd ..
926 934
927 935 Test symlink traversal over cached audited paths:
928 936 -------------------------------------------------
929 937
930 938 #if symlink
931 939
932 940 set up symlink hell
933 941
934 942 $ mkdir merge-symlink-out
935 943 $ hg init merge-symlink
936 944 $ cd merge-symlink
937 945 $ touch base
938 946 $ hg commit -qAm base
939 947 $ ln -s ../merge-symlink-out a
940 948 $ hg commit -qAm 'symlink a -> ../merge-symlink-out'
941 949 $ hg up -q 0
942 950 $ mkdir a
943 951 $ touch a/poisoned
944 952 $ hg commit -qAm 'file a/poisoned'
945 953 $ hg log -G -T '{rev}: {desc}\n'
946 954 @ 2: file a/poisoned
947 955 |
948 956 | o 1: symlink a -> ../merge-symlink-out
949 957 |/
950 958 o 0: base
951 959
952 960
953 961 try trivial merge after update: cache of audited paths should be discarded,
954 962 and the merge should fail (issue5628)
955 963
956 964 $ hg up -q null
957 965 >>> from hgclient import check, readchannel, runcommand
958 966 >>> @check
959 967 ... def merge(server):
960 968 ... readchannel(server)
961 969 ... # audit a/poisoned as a good path
962 970 ... runcommand(server, ['up', '-qC', '2'])
963 971 ... runcommand(server, ['up', '-qC', '1'])
964 972 ... # here a is a symlink, so a/poisoned is bad
965 973 ... runcommand(server, ['merge', '2'])
966 974 *** runcommand up -qC 2
967 975 *** runcommand up -qC 1
968 976 *** runcommand merge 2
969 977 a: path conflict - a file or link has the same name as a directory
970 978 the local file has been renamed to a~aa04623eb0c3
971 979 resolve manually then use 'hg resolve --mark a'
972 980 1 files updated, 0 files merged, 0 files removed, 1 files unresolved
973 981 use 'hg resolve' to retry unresolved file merges or 'hg update -C .' to abandon
974 982 [1]
975 983 $ ls ../merge-symlink-out
976 984
977 985 cache of repo.auditor should be discarded, so matcher would never traverse
978 986 symlinks:
979 987
980 988 $ hg up -qC 0
981 989 $ touch ../merge-symlink-out/poisoned
982 990 >>> from hgclient import check, readchannel, runcommand
983 991 >>> @check
984 992 ... def files(server):
985 993 ... readchannel(server)
986 994 ... runcommand(server, ['up', '-qC', '2'])
987 995 ... # audit a/poisoned as a good path
988 996 ... runcommand(server, ['files', 'a/poisoned'])
989 997 ... runcommand(server, ['up', '-qC', '0'])
990 998 ... runcommand(server, ['up', '-qC', '1'])
991 999 ... # here 'a' is a symlink, so a/poisoned should be warned
992 1000 ... runcommand(server, ['files', 'a/poisoned'])
993 1001 *** runcommand up -qC 2
994 1002 *** runcommand files a/poisoned
995 1003 a/poisoned
996 1004 *** runcommand up -qC 0
997 1005 *** runcommand up -qC 1
998 1006 *** runcommand files a/poisoned
999 1007 abort: path 'a/poisoned' traverses symbolic link 'a'
1000 1008 [255]
1001 1009
1002 1010 $ cd ..
1003 1011
1004 1012 #endif
General Comments 0
You need to be logged in to leave comments. Login now