Show More
@@ -13,14 +13,14 b' typical client does not want echo-back m' | |||
|
13 | 13 | $ hg init repo |
|
14 | 14 | $ cd repo |
|
15 | 15 | |
|
16 |
>>> from __future__ import absolute_import |
|
|
16 | >>> from __future__ import absolute_import | |
|
17 | 17 | >>> import os |
|
18 | 18 | >>> import sys |
|
19 | >>> from hgclient import check, readchannel, runcommand | |
|
19 | >>> from hgclient import bprint, check, readchannel, runcommand | |
|
20 | 20 | >>> @check |
|
21 | 21 | ... def hellomessage(server): |
|
22 | 22 | ... ch, data = readchannel(server) |
|
23 | ... print(b'%c, %r' % (ch, data)) | |
|
23 | ... bprint(b'%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, [b'id']) |
@@ -93,7 +93,7 b' typical client does not want echo-back m' | |||
|
93 | 93 | abort: unknown revision 'unknown'! |
|
94 | 94 | [255] |
|
95 | 95 | |
|
96 | >>> from hgclient import check, readchannel | |
|
96 | >>> from hgclient import bprint, check, readchannel | |
|
97 | 97 | >>> @check |
|
98 | 98 | ... def inputeof(server): |
|
99 | 99 | ... readchannel(server) |
@@ -102,7 +102,7 b' typical client does not want echo-back m' | |||
|
102 | 102 | ... server.stdin.close() |
|
103 | 103 | ... |
|
104 | 104 | ... # server exits with 1 if the pipe closed while reading the command |
|
105 | ... print(b'server exit code =', server.wait()) | |
|
105 | ... bprint(b'server exit code =', b'%d' % server.wait()) | |
|
106 | 106 | server exit code = 1 |
|
107 | 107 | |
|
108 | 108 | >>> from hgclient import check, readchannel, runcommand, stringio |
@@ -235,11 +235,11 b' check that local configs for the cached ' | |||
|
235 | 235 | #endif |
|
236 | 236 | |
|
237 | 237 | $ cat <<EOF > hook.py |
|
238 | > from __future__ import print_function | |
|
239 | 238 | > import sys |
|
239 | > from hgclient import bprint | |
|
240 | 240 | > def hook(**args): |
|
241 | > print(b'hook talking') | |
|
242 | > print(b'now try to read something: %r' % sys.stdin.read()) | |
|
241 | > bprint(b'hook talking') | |
|
242 | > bprint(b'now try to read something: %r' % sys.stdin.read()) | |
|
243 | 243 | > EOF |
|
244 | 244 | |
|
245 | 245 | >>> from hgclient import check, readchannel, runcommand, stringio |
@@ -281,7 +281,7 b' Clean hook cached version' | |||
|
281 | 281 | *** runcommand status |
|
282 | 282 | |
|
283 | 283 | >>> import os |
|
284 | >>> from hgclient import check, readchannel, runcommand | |
|
284 | >>> from hgclient import bprint, check, readchannel, runcommand | |
|
285 | 285 | >>> @check |
|
286 | 286 | ... def bookmarks(server): |
|
287 | 287 | ... readchannel(server) |
@@ -302,7 +302,7 b' Clean hook cached version' | |||
|
302 | 302 | ... f.close() |
|
303 | 303 | ... runcommand(server, [b'commit', b'-Amm']) |
|
304 | 304 | ... runcommand(server, [b'bookmarks']) |
|
305 | ... print(b'') | |
|
305 | ... bprint(b'') | |
|
306 | 306 | *** runcommand bookmarks |
|
307 | 307 | no bookmarks set |
|
308 | 308 | *** runcommand bookmarks |
@@ -346,7 +346,7 b' Clean hook cached version' | |||
|
346 | 346 | 3: public |
|
347 | 347 | |
|
348 | 348 | $ echo a >> a |
|
349 | >>> from hgclient import check, readchannel, runcommand | |
|
349 | >>> from hgclient import bprint, check, readchannel, runcommand | |
|
350 | 350 | >>> @check |
|
351 | 351 | ... def rollback(server): |
|
352 | 352 | ... readchannel(server) |
@@ -354,7 +354,7 b' Clean hook cached version' | |||
|
354 | 354 | ... runcommand(server, [b'commit', b'-Am.']) |
|
355 | 355 | ... runcommand(server, [b'rollback']) |
|
356 | 356 | ... runcommand(server, [b'phase', b'-r', b'.']) |
|
357 | ... print(b'') | |
|
357 | ... bprint(b'') | |
|
358 | 358 | *** runcommand phase -r . -p |
|
359 | 359 | no phases changed |
|
360 | 360 | *** runcommand commit -Am. |
@@ -385,7 +385,7 b' Clean hook cached version' | |||
|
385 | 385 | |
|
386 | 386 | $ touch .hgignore |
|
387 | 387 | >>> import os |
|
388 | >>> from hgclient import check, readchannel, runcommand | |
|
388 | >>> from hgclient import bprint, check, readchannel, runcommand | |
|
389 | 389 | >>> @check |
|
390 | 390 | ... def hgignore(server): |
|
391 | 391 | ... readchannel(server) |
@@ -397,7 +397,7 b' Clean hook cached version' | |||
|
397 | 397 | ... f.write(b'ignored-file') |
|
398 | 398 | ... f.close() |
|
399 | 399 | ... runcommand(server, [b'status', b'-i', b'-u']) |
|
400 | ... print(b'') | |
|
400 | ... bprint(b'') | |
|
401 | 401 | *** runcommand commit -Am. |
|
402 | 402 | adding .hgignore |
|
403 | 403 | *** runcommand status -i -u |
@@ -408,7 +408,7 b' cache of non-public revisions should be ' | |||
|
408 | 408 | (issue4855): |
|
409 | 409 | |
|
410 | 410 | >>> import os |
|
411 | >>> from hgclient import check, readchannel, runcommand | |
|
411 | >>> from hgclient import bprint, check, readchannel, runcommand | |
|
412 | 412 | >>> @check |
|
413 | 413 | ... def phasesetscacheaftercommit(server): |
|
414 | 414 | ... readchannel(server) |
@@ -423,7 +423,7 b' cache of non-public revisions should be ' | |||
|
423 | 423 | ... os.system('hg commit -Aqm%d' % i) |
|
424 | 424 | ... # new commits should be listed as draft revisions |
|
425 | 425 | ... runcommand(server, [b'log', b'-qr', b'draft()']) |
|
426 | ... print(b'') | |
|
426 | ... bprint(b'') | |
|
427 | 427 | *** runcommand log -qr draft() |
|
428 | 428 | 4:7966c8e3734d |
|
429 | 429 | *** runcommand log -qr draft() |
@@ -433,7 +433,7 b' cache of non-public revisions should be ' | |||
|
433 | 433 | |
|
434 | 434 | |
|
435 | 435 | >>> import os |
|
436 | >>> from hgclient import check, readchannel, runcommand | |
|
436 | >>> from hgclient import bprint, check, readchannel, runcommand | |
|
437 | 437 | >>> @check |
|
438 | 438 | ... def phasesetscacheafterstrip(server): |
|
439 | 439 | ... readchannel(server) |
@@ -443,7 +443,7 b' cache of non-public revisions should be ' | |||
|
443 | 443 | ... os.system('hg --config extensions.strip= strip -q 5') |
|
444 | 444 | ... # shouldn't abort by "unknown revision '6'" |
|
445 | 445 | ... runcommand(server, [b'log', b'-qr', b'draft()']) |
|
446 | ... print(b'') | |
|
446 | ... bprint(b'') | |
|
447 | 447 | *** runcommand log -qr draft() |
|
448 | 448 | 4:7966c8e3734d |
|
449 | 449 | 5:41f6602d1c4f |
@@ -668,19 +668,18 b' changelog and manifest would have invali' | |||
|
668 | 668 | |
|
669 | 669 | run commandserver in commandserver, which is silly but should work: |
|
670 | 670 | |
|
671 | >>> from __future__ import print_function | |
|
672 | >>> from hgclient import check, readchannel, runcommand, stringio | |
|
671 | >>> from hgclient import bprint, check, readchannel, runcommand, stringio | |
|
673 | 672 | >>> @check |
|
674 | 673 | ... def nested(server): |
|
675 | ... print(b'%c, %r' % readchannel(server)) | |
|
674 | ... bprint(b'%c, %r' % readchannel(server)) | |
|
676 | 675 | ... class nestedserver(object): |
|
677 | 676 | ... stdin = stringio(b'getencoding\n') |
|
678 | 677 | ... stdout = stringio() |
|
679 | 678 | ... runcommand(server, [b'serve', b'--cmdserver', b'pipe'], |
|
680 | 679 | ... output=nestedserver.stdout, input=nestedserver.stdin) |
|
681 | 680 | ... nestedserver.stdout.seek(0) |
|
682 | ... print(b'%c, %r' % readchannel(nestedserver)) # hello | |
|
683 | ... print(b'%c, %r' % readchannel(nestedserver)) # getencoding | |
|
681 | ... bprint(b'%c, %r' % readchannel(nestedserver)) # hello | |
|
682 | ... bprint(b'%c, %r' % readchannel(nestedserver)) # getencoding | |
|
684 | 683 | o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob) |
|
685 | 684 | *** runcommand serve --cmdserver pipe |
|
686 | 685 | o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob) |
@@ -691,12 +690,11 b' start without repository:' | |||
|
691 | 690 | |
|
692 | 691 | $ cd .. |
|
693 | 692 | |
|
694 | >>> from __future__ import print_function | |
|
695 | >>> from hgclient import check, readchannel, runcommand | |
|
693 | >>> from hgclient import bprint, check, readchannel, runcommand | |
|
696 | 694 | >>> @check |
|
697 | 695 | ... def hellomessage(server): |
|
698 | 696 | ... ch, data = readchannel(server) |
|
699 | ... print(b'%c, %r' % (ch, data)) | |
|
697 | ... bprint(b'%c, %r' % (ch, data)) | |
|
700 | 698 | ... # run an arbitrary command to make sure the next thing the server |
|
701 | 699 | ... # sends isn't part of the hello message |
|
702 | 700 | ... runcommand(server, [b'id']) |
@@ -732,12 +730,11 b' unix domain socket:' | |||
|
732 | 730 | |
|
733 | 731 | #if unix-socket unix-permissions |
|
734 | 732 | |
|
735 | >>> from __future__ import print_function | |
|
736 | >>> from hgclient import check, readchannel, runcommand, stringio, unixserver | |
|
733 | >>> from hgclient import bprint, check, readchannel, runcommand, stringio, unixserver | |
|
737 | 734 | >>> server = unixserver(b'.hg/server.sock', b'.hg/server.log') |
|
738 | 735 | >>> def hellomessage(conn): |
|
739 | 736 | ... ch, data = readchannel(conn) |
|
740 | ... print(b'%c, %r' % (ch, data)) | |
|
737 | ... bprint(b'%c, %r' % (ch, data)) | |
|
741 | 738 | ... runcommand(conn, [b'id']) |
|
742 | 739 | >>> check(hellomessage, server.connect) |
|
743 | 740 | o, 'capabilities: getencoding runcommand\nencoding: *\npid: *' (glob) |
@@ -784,15 +781,14 b' unix domain socket:' | |||
|
784 | 781 | > [cmdserver] |
|
785 | 782 | > log = inexistent/path.log |
|
786 | 783 | > EOF |
|
787 | >>> from __future__ import print_function | |
|
788 | >>> from hgclient import check, readchannel, unixserver | |
|
784 | >>> from hgclient import bprint, check, readchannel, unixserver | |
|
789 | 785 | >>> server = unixserver(b'.hg/server.sock', b'.hg/server.log') |
|
790 | 786 | >>> def earlycrash(conn): |
|
791 | 787 | ... while True: |
|
792 | 788 | ... try: |
|
793 | 789 | ... ch, data = readchannel(conn) |
|
794 | 790 | ... if not data.startswith(b' '): |
|
795 | ... print(b'%c, %r' % (ch, data)) | |
|
791 | ... bprint(b'%c, %r' % (ch, data)) | |
|
796 | 792 | ... except EOFError: |
|
797 | 793 | ... break |
|
798 | 794 | >>> check(earlycrash, server.connect) |
General Comments 0
You need to be logged in to leave comments.
Login now