Plugins/VcsPlugins/vcsMercurial/HgClient.py

changeset 1325
8dd723182a16
parent 1323
3126121aeb4f
child 1365
8f8cad8f989e
equal deleted inserted replaced
1324:370e8b9cfc23 1325:8dd723182a16
25 """ 25 """
26 InputFormat = ">I" 26 InputFormat = ">I"
27 OutputFormat = ">cI" 27 OutputFormat = ">cI"
28 OutputFormatSize = struct.calcsize(OutputFormat) 28 OutputFormatSize = struct.calcsize(OutputFormat)
29 ReturnFormat = ">i" 29 ReturnFormat = ">i"
30
31 Channels = (b"I", b"L", b"o", b"e", b"r", b"d")
30 32
31 def __init__(self, repoPath, encoding, parent=None): 33 def __init__(self, repoPath, encoding, parent=None):
32 """ 34 """
33 Constructor 35 Constructor
34 36
171 Private method to read data from the command server. 173 Private method to read data from the command server.
172 174
173 @return tuple of channel designator and channel data 175 @return tuple of channel designator and channel data
174 (string, integer or string or bytes) 176 (string, integer or string or bytes)
175 """ 177 """
178 additionalData = b""
179
176 if self.__server.bytesAvailable() > 0 or \ 180 if self.__server.bytesAvailable() > 0 or \
177 self.__server.waitForReadyRead(10000): 181 self.__server.waitForReadyRead(10000):
182 while bytes(self.__server.peek(1)) not in HgClient.Channels:
183 additionalData += bytes(self.__server.read(1))
184 if additionalData:
185 return ("o", str(additionalData, self.__encoding, "replace"))
186
178 data = bytes(self.__server.read(HgClient.OutputFormatSize)) 187 data = bytes(self.__server.read(HgClient.OutputFormatSize))
179 if not data: 188 if not data:
180 return "", "" 189 return "", ""
181 190
182 if data.startswith(b" L") and self.__server.bytesAvailable() > 0:
183 # workaround for an issue in the Mercurial command server
184 data = data[1:] + bytes(self.__server.read(1))
185 channel, length = struct.unpack(HgClient.OutputFormat, data) 191 channel, length = struct.unpack(HgClient.OutputFormat, data)
186 channel = channel.decode(self.__encoding) 192 channel = channel.decode(self.__encoding)
187 if channel in "IL": 193 if channel in "IL":
188 return channel, length 194 return channel, length
189 else: 195 else:

eric ide

mercurial