Plugins/VcsPlugins/vcsMercurial/HgClient.py

changeset 1256
885706dbb69f
parent 1247
a6bedc641fcd
child 1260
9488a3aceb0e
equal deleted inserted replaced
1255:e1d8a8a4d40c 1256:885706dbb69f
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 self.__cancel = False
44 self.__commandRunning = False
44 45
45 # connect signals 46 # connect signals
46 self.__server.finished.connect(self.__serverFinished) 47 self.__server.finished.connect(self.__serverFinished)
47 48
48 # generate command line and environment 49 # generate command line and environment
85 def stopServer(self): 86 def stopServer(self):
86 """ 87 """
87 Public method to stop the command server. 88 Public method to stop the command server.
88 """ 89 """
89 self.__server.closeWriteChannel() 90 self.__server.closeWriteChannel()
90 res = self.__server.waitForFinished(10000) 91 res = self.__server.waitForFinished(5000)
91 if not res: 92 if not res:
92 self.__server.terminate() 93 self.__server.terminate()
93 res = self.__server.waitForFinished(5000) 94 res = self.__server.waitForFinished(3000)
94 if not res: 95 if not res:
95 self.__server.kill() 96 self.__server.kill()
96 97
97 def restartServer(self): 98 def restartServer(self):
98 """ 99 """
250 of the output channel received so far. 251 of the output channel received so far.
251 @param input function to reply to bulk data requests by the server. 252 @param input function to reply to bulk data requests by the server.
252 It receives the max number of bytes to return. 253 It receives the max number of bytes to return.
253 @return output and errors of the command server (string) 254 @return output and errors of the command server (string)
254 """ 255 """
256 self.__commandRunning = True
257
255 output = io.StringIO() 258 output = io.StringIO()
256 error = io.StringIO() 259 error = io.StringIO()
257 outputChannels = { 260 outputChannels = {
258 "o": output.write, 261 "o": output.write,
259 "e": error.write 262 "e": error.write
271 self.__cancel = False 274 self.__cancel = False
272 self.__runcommand(args, inputChannels, outputChannels) 275 self.__runcommand(args, inputChannels, outputChannels)
273 out = output.getvalue() 276 out = output.getvalue()
274 err = error.getvalue() 277 err = error.getvalue()
275 278
279 self.__commandRunning = False
280
276 return out, err 281 return out, err
277 282
278 def cancel(self): 283 def cancel(self):
279 """ 284 """
280 Public method to cancel the running command. 285 Public method to cancel the running command.
281 """ 286 """
282 self.__cancel = True 287 self.__cancel = True
283 self.restartServer() 288 self.restartServer()
289
290 def wasCanceled(self):
291 """
292 Public method to check, if the last command was canceled.
293 """
294 return self.__cancel
295
296 def isExecuting(self):
297 """
298 Public method to check, if the server is executing a command.
299
300 @return flag indicating the execution of a command (boolean)
301 """

eric ide

mercurial