Show More
@@ -2,6 +2,7 b'' | |||||
2 |
|
2 | |||
3 | from __future__ import absolute_import, print_function |
|
3 | from __future__ import absolute_import, print_function | |
4 | import os |
|
4 | import os | |
|
5 | import re | |||
5 | import signal |
|
6 | import signal | |
6 | import socket |
|
7 | import socket | |
7 | import struct |
|
8 | import struct | |
@@ -19,9 +20,14 b' except ImportError:' | |||||
19 | if sys.version_info[0] >= 3: |
|
20 | if sys.version_info[0] >= 3: | |
20 | stdout = sys.stdout.buffer |
|
21 | stdout = sys.stdout.buffer | |
21 | stderr = sys.stderr.buffer |
|
22 | stderr = sys.stderr.buffer | |
|
23 | def bprint(*args): | |||
|
24 | # remove b'' as well for ease of test migration | |||
|
25 | pargs = [re.sub(br'''\bb(['"])''', br'\1', b'%s' % a) for a in args] | |||
|
26 | stdout.write(b' '.join(pargs) + b'\n') | |||
22 | else: |
|
27 | else: | |
23 | stdout = sys.stdout |
|
28 | stdout = sys.stdout | |
24 | stderr = sys.stderr |
|
29 | stderr = sys.stderr | |
|
30 | bprint = print | |||
25 |
|
31 | |||
26 | def connectpipe(path=None): |
|
32 | def connectpipe(path=None): | |
27 | cmdline = [b'hg', b'serve', b'--cmdserver', b'pipe'] |
|
33 | cmdline = [b'hg', b'serve', b'--cmdserver', b'pipe'] | |
@@ -90,7 +96,7 b' def sep(text):' | |||||
90 |
|
96 | |||
91 | def runcommand(server, args, output=stdout, error=stderr, input=None, |
|
97 | def runcommand(server, args, output=stdout, error=stderr, input=None, | |
92 | outfilter=lambda x: x): |
|
98 | outfilter=lambda x: x): | |
93 | print(b'*** runcommand', b' '.join(args)) |
|
99 | bprint(b'*** runcommand', b' '.join(args)) | |
94 | stdout.flush() |
|
100 | stdout.flush() | |
95 | server.stdin.write(b'runcommand\n') |
|
101 | server.stdin.write(b'runcommand\n') | |
96 | writeblock(server, b'\0'.join(args)) |
|
102 | writeblock(server, b'\0'.join(args)) | |
@@ -113,10 +119,10 b' def runcommand(server, args, output=stdo' | |||||
113 | elif ch == b'r': |
|
119 | elif ch == b'r': | |
114 | ret, = struct.unpack('>i', data) |
|
120 | ret, = struct.unpack('>i', data) | |
115 | if ret != 0: |
|
121 | if ret != 0: | |
116 | print(b' [%d]' % ret) |
|
122 | bprint(b' [%d]' % ret) | |
117 | return ret |
|
123 | return ret | |
118 | else: |
|
124 | else: | |
119 | print(b"unexpected channel %c: %r" % (ch, data)) |
|
125 | bprint(b"unexpected channel %c: %r" % (ch, data)) | |
120 | if ch.isupper(): |
|
126 | if ch.isupper(): | |
121 | return |
|
127 | return | |
122 |
|
128 |
General Comments 0
You need to be logged in to leave comments.
Login now