equal
deleted
inserted
replaced
6 # This software may be used and distributed according to the terms of the |
6 # This software may be used and distributed according to the terms of the |
7 # GNU General Public License version 2 or any later version. |
7 # GNU General Public License version 2 or any later version. |
8 |
8 |
9 import os |
9 import os |
10 import re |
10 import re |
|
11 from typing import ( |
|
12 Tuple, |
|
13 ) |
11 |
14 |
12 from mercurial.i18n import _ |
15 from mercurial.i18n import _ |
13 from mercurial.pycompat import open |
16 from mercurial.pycompat import open |
14 from mercurial import ( |
17 from mercurial import ( |
15 error, |
18 error, |
119 self.mtnwritefp.write(command) |
122 self.mtnwritefp.write(command) |
120 self.mtnwritefp.flush() |
123 self.mtnwritefp.flush() |
121 |
124 |
122 return self.mtnstdioreadcommandoutput(command) |
125 return self.mtnstdioreadcommandoutput(command) |
123 |
126 |
124 def mtnstdioreadpacket(self): |
127 def mtnstdioreadpacket(self) -> Tuple[bytes, bytes, int, bytes]: |
125 read = None |
128 read = None |
126 commandnbr = b'' |
129 commandnbr = b'' |
127 while read != b':': |
130 while read != b':': |
128 read = self.mtnreadfp.read(1) |
131 read = self.mtnreadfp.read(1) |
129 if not read: |
132 if not read: |
165 % (len(read), length) |
168 % (len(read), length) |
166 ) |
169 ) |
167 |
170 |
168 return (commandnbr, stream, length, read) |
171 return (commandnbr, stream, length, read) |
169 |
172 |
170 def mtnstdioreadcommandoutput(self, command): |
173 def mtnstdioreadcommandoutput(self, command) -> bytes: |
171 retval = [] |
174 retval = [] |
172 while True: |
175 while True: |
173 commandnbr, stream, length, output = self.mtnstdioreadpacket() |
176 commandnbr, stream, length, output = self.mtnstdioreadpacket() |
174 self.ui.debug( |
177 self.ui.debug( |
175 b'mtn: read packet %s:%s:%d\n' % (commandnbr, stream, length) |
178 b'mtn: read packet %s:%s:%d\n' % (commandnbr, stream, length) |