##// END OF EJS Templates
py3: convert string literals to bytes in contrib/hgclient.py...
Yuya Nishihara -
r40350:73c2b9c9 default
parent child Browse files
Show More
@@ -17,9 +17,9 b' except ImportError:'
17 17 stringio = io.StringIO
18 18
19 19 def connectpipe(path=None):
20 cmdline = ['hg', 'serve', '--cmdserver', 'pipe']
20 cmdline = [b'hg', b'serve', b'--cmdserver', b'pipe']
21 21 if path:
22 cmdline += ['-R', path]
22 cmdline += [b'-R', path]
23 23
24 24 server = subprocess.Popen(cmdline, stdin=subprocess.PIPE,
25 25 stdout=subprocess.PIPE)
@@ -41,9 +41,9 b' class unixconnection(object):'
41 41 class unixserver(object):
42 42 def __init__(self, sockpath, logpath=None, repopath=None):
43 43 self.sockpath = sockpath
44 cmdline = ['hg', 'serve', '--cmdserver', 'unix', '-a', sockpath]
44 cmdline = [b'hg', b'serve', b'--cmdserver', b'unix', b'-a', sockpath]
45 45 if repopath:
46 cmdline += ['-R', repopath]
46 cmdline += [b'-R', repopath]
47 47 if logpath:
48 48 stdout = open(logpath, 'a')
49 49 stderr = subprocess.STDOUT
@@ -64,7 +64,7 b' class unixserver(object):'
64 64 self.server.wait()
65 65
66 66 def writeblock(server, data):
67 server.stdin.write(struct.pack('>I', len(data)))
67 server.stdin.write(struct.pack(b'>I', len(data)))
68 68 server.stdin.write(data)
69 69 server.stdin.flush()
70 70
@@ -73,43 +73,43 b' def readchannel(server):'
73 73 if not data:
74 74 raise EOFError
75 75 channel, length = struct.unpack('>cI', data)
76 if channel in 'IL':
76 if channel in b'IL':
77 77 return channel, length
78 78 else:
79 79 return channel, server.stdout.read(length)
80 80
81 81 def sep(text):
82 return text.replace('\\', '/')
82 return text.replace(b'\\', b'/')
83 83
84 84 def runcommand(server, args, output=sys.stdout, error=sys.stderr, input=None,
85 85 outfilter=lambda x: x):
86 print('*** runcommand', ' '.join(args))
86 print(b'*** runcommand', b' '.join(args))
87 87 sys.stdout.flush()
88 server.stdin.write('runcommand\n')
89 writeblock(server, '\0'.join(args))
88 server.stdin.write(b'runcommand\n')
89 writeblock(server, b'\0'.join(args))
90 90
91 91 if not input:
92 92 input = stringio()
93 93
94 94 while True:
95 95 ch, data = readchannel(server)
96 if ch == 'o':
96 if ch == b'o':
97 97 output.write(outfilter(data))
98 98 output.flush()
99 elif ch == 'e':
99 elif ch == b'e':
100 100 error.write(data)
101 101 error.flush()
102 elif ch == 'I':
102 elif ch == b'I':
103 103 writeblock(server, input.read(data))
104 elif ch == 'L':
104 elif ch == b'L':
105 105 writeblock(server, input.readline(data))
106 elif ch == 'r':
106 elif ch == b'r':
107 107 ret, = struct.unpack('>i', data)
108 108 if ret != 0:
109 print(' [%d]' % ret)
109 print(b' [%d]' % ret)
110 110 return ret
111 111 else:
112 print("unexpected channel %c: %r" % (ch, data))
112 print(b"unexpected channel %c: %r" % (ch, data))
113 113 if ch.isupper():
114 114 return
115 115
General Comments 0
You need to be logged in to leave comments. Login now