Mon, 29 Aug 2011 18:06:35 +0200
Continued implementing an interface to the Mercurial command server. Modified client all all dialogs done so far to provide a cancel capability..
--- a/Plugins/VcsPlugins/vcsMercurial/HgAnnotateDialog.py Sun Aug 28 20:08:21 2011 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/HgAnnotateDialog.py Mon Aug 29 18:06:35 2011 +0200 @@ -165,7 +165,10 @@ if button == self.buttonBox.button(QDialogButtonBox.Close): self.close() elif button == self.buttonBox.button(QDialogButtonBox.Cancel): - self.__finish() + if self.__hgClient: + self.__hgClient.cancel() + else: + self.__finish() def __procFinished(self, exitCode, exitStatus): """
--- a/Plugins/VcsPlugins/vcsMercurial/HgClient.py Sun Aug 28 20:08:21 2011 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/HgClient.py Mon Aug 29 18:06:35 2011 +0200 @@ -40,6 +40,7 @@ self.__started = False self.__version = None self.__encoding = Preferences.getSystem("IOEncoding") + self.__cancel = False # connect signals self.__server.finished.connect(self.__serverFinished) @@ -190,6 +191,7 @@ @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 or -1, if the command was canceled (integer) """ if not self.__started: return -1 @@ -199,6 +201,10 @@ while True: QCoreApplication.processEvents() + + if self.__cancel: + return -1 + if self.__server.bytesAvailable() == 0: continue channel, data = self.__readChannel() @@ -253,9 +259,15 @@ if input is not None: inputChannels["I"] = input + self.__cancel = False self.__runcommand(args, inputChannels, outputChannels) out = output.getvalue() err = error.getvalue() return out, err - + + def cancel(self): + """ + Public method to cancel the running command. + """ + self.__cancel = True
--- a/Plugins/VcsPlugins/vcsMercurial/HgDialog.py Sun Aug 28 20:08:21 2011 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/HgDialog.py Mon Aug 29 18:06:35 2011 +0200 @@ -82,7 +82,10 @@ if button == self.buttonBox.button(QDialogButtonBox.Close): self.close() elif button == self.buttonBox.button(QDialogButtonBox.Cancel): - self.__finish() + if self.__hgClient: + self.__hgClient.cancel() + else: + self.__finish() def __procFinished(self, exitCode, exitStatus): """ @@ -117,6 +120,9 @@ self.__updateCommand = False if showArgs: + self.inputGroup.setEnabled(False) + self.inputGroup.hide() + self.resultbox.append(' '.join(args)) self.resultbox.append('')
--- a/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py Sun Aug 28 20:08:21 2011 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py Mon Aug 29 18:06:35 2011 +0200 @@ -650,6 +650,9 @@ args.append(self.filename) if self.__hgClient: + self.inputGroup.setEnabled(False) + self.inputGroup.hide() + out, err = self.__hgClient.runcommand(args) self.buf = out.splitlines(True) if err: @@ -937,7 +940,10 @@ self.close() elif button == self.buttonBox.button(QDialogButtonBox.Cancel): self.cancelled = True - self.__finish() + if self.__hgClient: + self.__hgClient.cancel() + else: + self.__finish() elif button == self.refreshButton: self.on_refreshButton_clicked()
--- a/Plugins/VcsPlugins/vcsMercurial/HgStatusDialog.py Sun Aug 28 20:08:21 2011 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/HgStatusDialog.py Mon Aug 29 18:06:35 2011 +0200 @@ -283,7 +283,10 @@ if button == self.buttonBox.button(QDialogButtonBox.Close): self.close() elif button == self.buttonBox.button(QDialogButtonBox.Cancel): - self.__finish() + if self.__hgClient: + self.__hgClient.cancel() + else: + self.__finish() elif button == self.refreshButton: self.on_refreshButton_clicked()