--- a/Plugins/VcsPlugins/vcsMercurial/HgClient.py Thu Sep 15 18:33:53 2011 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/HgClient.py Thu Sep 15 19:38:39 2011 +0200 @@ -12,6 +12,9 @@ from PyQt4.QtCore import QProcess, QProcessEnvironment, QObject, QByteArray, \ QCoreApplication +from PyQt4.QtGui import QDialog + +from .HgClientPromptDialog import HgClientPromptDialog import Preferences @@ -176,6 +179,9 @@ if not data: return "", "" + if data.startswith(b" L") and self.__server.bytesAvailable() > 0: + # workaround for an issue in the Mercurial command server + data = data[1:] + bytes(self.__server.read(1)) channel, length = struct.unpack(HgClient.OutputFormat, data) channel = channel.decode(self.__encoding) if channel in "IL": @@ -233,7 +239,11 @@ # input channels if channel in inputChannels: - self.__writeDataBlock(inputChannels[channel](data)) + input = inputChannels[channel](data) + if channel == "L": + # echo the input to the output if it was a prompt + outputChannels["o"](input) + self.__writeDataBlock(input) # output channels elif channel in outputChannels: @@ -252,6 +262,19 @@ else: pass + def __prompt(self, size, message): + """ + Private method to prompt the user for some input. + + @param size maximum length of the requested input (integer) + @param message message sent by the server (string) + """ + input = "" + dlg = HgClientPromptDialog(size, message) + if dlg.exec_() == QDialog.Accepted: + input = dlg.getInput() + '\n' + return input + def runcommand(self, args, prompt=None, input=None, output=None, error=None): """ Public method to execute a command via the command server. @@ -291,6 +314,11 @@ reply = prompt(size, outputBuffer.getvalue()) return reply inputChannels["L"] = func + else: + def myprompt(size): + reply = self.__prompt(size, outputBuffer.getvalue()) + return reply + inputChannels["L"] = myprompt if input is not None: inputChannels["I"] = input