--- a/Plugins/VcsPlugins/vcsMercurial/HgClient.py Tue Oct 15 22:03:54 2013 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/HgClient.py Fri Oct 18 23:00:41 2013 +0200 @@ -15,7 +15,8 @@ import struct import io -from PyQt4.QtCore import QProcess, QObject, QByteArray, QCoreApplication, QThread +from PyQt4.QtCore import QProcess, QObject, QByteArray, QCoreApplication, \ + QThread from PyQt4.QtGui import QDialog from .HgUtilities import prepareProcess @@ -109,7 +110,6 @@ self.__server.waitForFinished(3000) self.__started = False -## self.__server.finished.disconnect(self.__serverFinished) self.__server.deleteLater() self.__server = None @@ -139,8 +139,9 @@ msg = msg.split("\n") if not msg[0].startswith("capabilities: "): - return False, self.trUtf8("Bad 'hello' message, expected 'capabilities: '" - " but got '{0}'.").format(msg[0]) + return False, self.trUtf8( + "Bad 'hello' message, expected 'capabilities: '" + " but got '{0}'.").format(msg[0]) self.__capabilities = msg[0][len('capabilities: '):] if not self.__capabilities: return False, self.trUtf8("'capabilities' message did not contain" @@ -151,8 +152,9 @@ return False, "'capabilities' did not contain 'runcommand'." if not msg[1].startswith("encoding: "): - return False, self.trUtf8("Bad 'hello' message, expected 'encoding: '" - " but got '{0}'.").format(msg[1]) + return False, self.trUtf8( + "Bad 'hello' message, expected 'encoding: '" + " but got '{0}'.").format(msg[1]) encoding = msg[1][len('encoding: '):] if not encoding: return False, self.trUtf8("'encoding' message did not contain" @@ -211,7 +213,8 @@ """ if not isinstance(data, bytes): data = data.encode(self.__encoding) - self.__server.write(QByteArray(struct.pack(HgClient.InputFormat, len(data)))) + self.__server.write( + QByteArray(struct.pack(HgClient.InputFormat, len(data)))) self.__server.write(QByteArray(data)) self.__server.waitForBytesWritten() @@ -221,13 +224,15 @@ @param args list of arguments for the command (list of string) @param inputChannels dictionary of input channels. The dictionary must - have the keys 'I' and 'L' and each entry must be a function receiving - the number of bytes to write. - @param outputChannels dictionary of output channels. The dictionary must - have the keys 'o' and 'e' and each entry must be a function receiving - the data. - @return result code of the command, -1 if the command server wasn't started or - -10, if the command was canceled (integer) + have the keys 'I' and 'L' and each entry must be a function + receiving the number of bytes to write. + @param outputChannels dictionary of output channels. The dictionary + must have the keys 'o' and 'e' and each entry must be a function + receiving the data. + @return result code of the command, -1 if the command server wasn't + started or -10, if the command was canceled (integer) + @exception RuntimeError raised to indicate an unexpected command + channel """ if not self.__started: return -1 @@ -280,6 +285,7 @@ @param size maximum length of the requested input (integer) @param message message sent by the server (string) + @return data entered by the user (string) """ from .HgClientPromptDialog import HgClientPromptDialog input = "" @@ -288,7 +294,8 @@ input = dlg.getInput() + '\n' return input - def runcommand(self, args, prompt=None, input=None, output=None, error=None): + def runcommand(self, args, prompt=None, input=None, output=None, + error=None): """ Public method to execute a command via the command server. @@ -300,10 +307,11 @@ It receives the max number of bytes to return. @keyparam output function receiving the data from the server (string). If a prompt function is given, this parameter will be ignored. - @keyparam error function receiving error messages from the server (string) - @return output and errors of the command server (string). In case output - and/or error functions were given, the respective return value will - be an empty string. + @keyparam error function receiving error messages from the server + (string) + @return output and errors of the command server (string). In case + output and/or error functions were given, the respective return + value will be an empty string. """ self.__commandRunning = True outputChannels = {} @@ -364,6 +372,8 @@ def wasCanceled(self): """ Public method to check, if the last command was canceled. + + @return flag indicating the cancel state (boolean) """ return self.__cancel @@ -373,3 +383,4 @@ @return flag indicating the execution of a command (boolean) """ + return self.__commandRunning