Plugins/VcsPlugins/vcsMercurial/HgClient.py

changeset 1242
dfb9609caf51
parent 1241
09c6155ee612
child 1244
ffdb35928247
equal deleted inserted replaced
1241:09c6155ee612 1242:dfb9609caf51
38 self.__server = QProcess() 38 self.__server = QProcess()
39 self.__server.setWorkingDirectory(repoPath) 39 self.__server.setWorkingDirectory(repoPath)
40 self.__started = False 40 self.__started = False
41 self.__version = None 41 self.__version = None
42 self.__encoding = Preferences.getSystem("IOEncoding") 42 self.__encoding = Preferences.getSystem("IOEncoding")
43 self.__cancel = False
43 44
44 # connect signals 45 # connect signals
45 self.__server.finished.connect(self.__serverFinished) 46 self.__server.finished.connect(self.__serverFinished)
46 47
47 # generate command line and environment 48 # generate command line and environment
188 have the keys 'I' and 'L' and each entry must be a function receiving 189 have the keys 'I' and 'L' and each entry must be a function receiving
189 the number of bytes to write. 190 the number of bytes to write.
190 @param outputChannels dictionary of output channels. The dictionary must 191 @param outputChannels dictionary of output channels. The dictionary must
191 have the keys 'o' and 'e' and each entry must be a function receiving 192 have the keys 'o' and 'e' and each entry must be a function receiving
192 the data. 193 the data.
194 @return result code of the command or -1, if the command was canceled (integer)
193 """ 195 """
194 if not self.__started: 196 if not self.__started:
195 return -1 197 return -1
196 198
197 self.__server.write(QByteArray(b'runcommand\n')) 199 self.__server.write(QByteArray(b'runcommand\n'))
198 self.__writeDataBlock('\0'.join(args)) 200 self.__writeDataBlock('\0'.join(args))
199 201
200 while True: 202 while True:
201 QCoreApplication.processEvents() 203 QCoreApplication.processEvents()
204
205 if self.__cancel:
206 return -1
207
202 if self.__server.bytesAvailable() == 0: 208 if self.__server.bytesAvailable() == 0:
203 continue 209 continue
204 channel, data = self.__readChannel() 210 channel, data = self.__readChannel()
205 211
206 # input channels 212 # input channels
251 return reply 257 return reply
252 inputChannels["L"] = func 258 inputChannels["L"] = func
253 if input is not None: 259 if input is not None:
254 inputChannels["I"] = input 260 inputChannels["I"] = input
255 261
262 self.__cancel = False
256 self.__runcommand(args, inputChannels, outputChannels) 263 self.__runcommand(args, inputChannels, outputChannels)
257 out = output.getvalue() 264 out = output.getvalue()
258 err = error.getvalue() 265 err = error.getvalue()
259 266
260 return out, err 267 return out, err
261 268
269 def cancel(self):
270 """
271 Public method to cancel the running command.
272 """
273 self.__cancel = True

eric ide

mercurial