##// END OF EJS Templates
py3: work around unicode stdio streams in contrib/hgclient.py
Yuya Nishihara -
r40351:431a8313 default
parent child Browse files
Show More
@@ -16,6 +16,13 b' except ImportError:'
16 import io
16 import io
17 stringio = io.StringIO
17 stringio = io.StringIO
18
18
19 if sys.version_info[0] >= 3:
20 stdout = sys.stdout.buffer
21 stderr = sys.stderr.buffer
22 else:
23 stdout = sys.stdout
24 stderr = sys.stderr
25
19 def connectpipe(path=None):
26 def connectpipe(path=None):
20 cmdline = [b'hg', b'serve', b'--cmdserver', b'pipe']
27 cmdline = [b'hg', b'serve', b'--cmdserver', b'pipe']
21 if path:
28 if path:
@@ -81,10 +88,10 b' def readchannel(server):'
81 def sep(text):
88 def sep(text):
82 return text.replace(b'\\', b'/')
89 return text.replace(b'\\', b'/')
83
90
84 def runcommand(server, args, output=sys.stdout, error=sys.stderr, input=None,
91 def runcommand(server, args, output=stdout, error=stderr, input=None,
85 outfilter=lambda x: x):
92 outfilter=lambda x: x):
86 print(b'*** runcommand', b' '.join(args))
93 print(b'*** runcommand', b' '.join(args))
87 sys.stdout.flush()
94 stdout.flush()
88 server.stdin.write(b'runcommand\n')
95 server.stdin.write(b'runcommand\n')
89 writeblock(server, b'\0'.join(args))
96 writeblock(server, b'\0'.join(args))
90
97
@@ -114,7 +121,7 b' def runcommand(server, args, output=sys.'
114 return
121 return
115
122
116 def check(func, connect=connectpipe):
123 def check(func, connect=connectpipe):
117 sys.stdout.flush()
124 stdout.flush()
118 server = connect()
125 server = connect()
119 try:
126 try:
120 return func(server)
127 return func(server)
General Comments 0
You need to be logged in to leave comments. Login now