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