Wed, 31 Aug 2011 19:28:49 +0200
Refined the Mercurial command server interface.
diff -r e1d8a8a4d40c -r 885706dbb69f Plugins/VcsPlugins/vcsMercurial/BookmarksExtension/HgBookmarksInOutDialog.py --- a/Plugins/VcsPlugins/vcsMercurial/BookmarksExtension/HgBookmarksInOutDialog.py Wed Aug 31 18:44:04 2011 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/BookmarksExtension/HgBookmarksInOutDialog.py Wed Aug 31 19:28:49 2011 +0200 @@ -67,11 +67,15 @@ @param e close event (QCloseEvent) """ - if self.process is not None and \ - self.process.state() != QProcess.NotRunning: - self.process.terminate() - QTimer.singleShot(2000, self.process.kill) - self.process.waitForFinished(3000) + if self.__hgClient: + if self.__hgClient.isExecuting(): + self.__hgClient.cancel() + else: + if self.process is not None and \ + self.process.state() != QProcess.NotRunning: + self.process.terminate() + QTimer.singleShot(2000, self.process.kill) + self.process.waitForFinished(3000) e.accept() @@ -114,6 +118,8 @@ if out: for line in out.splitlines(): self.__processOutputLine(line) + if self.__hgClient.wasCanceled(): + break self.__finish() else: self.process.kill()
diff -r e1d8a8a4d40c -r 885706dbb69f Plugins/VcsPlugins/vcsMercurial/BookmarksExtension/HgBookmarksListDialog.py --- a/Plugins/VcsPlugins/vcsMercurial/BookmarksExtension/HgBookmarksListDialog.py Wed Aug 31 18:44:04 2011 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/BookmarksExtension/HgBookmarksListDialog.py Wed Aug 31 19:28:49 2011 +0200 @@ -55,11 +55,15 @@ @param e close event (QCloseEvent) """ - if self.process is not None and \ - self.process.state() != QProcess.NotRunning: - self.process.terminate() - QTimer.singleShot(2000, self.process.kill) - self.process.waitForFinished(3000) + if self.__hgClient: + if self.__hgClient.isExecuting(): + self.__hgClient.cancel() + else: + if self.process is not None and \ + self.process.state() != QProcess.NotRunning: + self.process.terminate() + QTimer.singleShot(2000, self.process.kill) + self.process.waitForFinished(3000) e.accept() @@ -99,6 +103,8 @@ if out: for line in out.splitlines(): self.__processOutputLine(line) + if self.__hgClient.wasCanceled(): + break self.__finish() else: self.process.kill()
diff -r e1d8a8a4d40c -r 885706dbb69f Plugins/VcsPlugins/vcsMercurial/GpgExtension/HgGpgSignaturesDialog.py --- a/Plugins/VcsPlugins/vcsMercurial/GpgExtension/HgGpgSignaturesDialog.py Wed Aug 31 18:44:04 2011 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/GpgExtension/HgGpgSignaturesDialog.py Wed Aug 31 19:28:49 2011 +0200 @@ -54,11 +54,15 @@ @param e close event (QCloseEvent) """ - if self.process is not None and \ - self.process.state() != QProcess.NotRunning: - self.process.terminate() - QTimer.singleShot(2000, self.process.kill) - self.process.waitForFinished(3000) + if self.__hgClient: + if self.__hgClient.isExecuting(): + self.__hgClient.cancel() + else: + if self.process is not None and \ + self.process.state() != QProcess.NotRunning: + self.process.terminate() + QTimer.singleShot(2000, self.process.kill) + self.process.waitForFinished(3000) e.accept() @@ -96,6 +100,8 @@ if out: for line in out.splitlines(): self.__processOutputLine(line) + if self.__hgClient.wasCanceled(): + break self.__finish() else: self.process.kill()
diff -r e1d8a8a4d40c -r 885706dbb69f Plugins/VcsPlugins/vcsMercurial/HgAnnotateDialog.py --- a/Plugins/VcsPlugins/vcsMercurial/HgAnnotateDialog.py Wed Aug 31 18:44:04 2011 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/HgAnnotateDialog.py Wed Aug 31 19:28:49 2011 +0200 @@ -65,11 +65,15 @@ @param e close event (QCloseEvent) """ - if self.process is not None and \ - self.process.state() != QProcess.NotRunning: - self.process.terminate() - QTimer.singleShot(2000, self.process.kill) - self.process.waitForFinished(3000) + if self.__hgClient: + if self.__hgClient.isExecuting(): + self.__hgClient.cancel() + else: + if self.process is not None and \ + self.process.state() != QProcess.NotRunning: + self.process.terminate() + QTimer.singleShot(2000, self.process.kill) + self.process.waitForFinished(3000) e.accept() @@ -113,6 +117,8 @@ if out: for line in out.splitlines(): self.__processOutputLine(line) + if self.__hgClient.wasCanceled(): + break self.__finish() else: self.process.kill()
diff -r e1d8a8a4d40c -r 885706dbb69f Plugins/VcsPlugins/vcsMercurial/HgClient.py --- a/Plugins/VcsPlugins/vcsMercurial/HgClient.py Wed Aug 31 18:44:04 2011 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/HgClient.py Wed Aug 31 19:28:49 2011 +0200 @@ -41,6 +41,7 @@ self.__version = None self.__encoding = Preferences.getSystem("IOEncoding") self.__cancel = False + self.__commandRunning = False # connect signals self.__server.finished.connect(self.__serverFinished) @@ -87,10 +88,10 @@ Public method to stop the command server. """ self.__server.closeWriteChannel() - res = self.__server.waitForFinished(10000) + res = self.__server.waitForFinished(5000) if not res: self.__server.terminate() - res = self.__server.waitForFinished(5000) + res = self.__server.waitForFinished(3000) if not res: self.__server.kill() @@ -252,6 +253,8 @@ It receives the max number of bytes to return. @return output and errors of the command server (string) """ + self.__commandRunning = True + output = io.StringIO() error = io.StringIO() outputChannels = { @@ -273,6 +276,8 @@ out = output.getvalue() err = error.getvalue() + self.__commandRunning = False + return out, err def cancel(self): @@ -281,3 +286,16 @@ """ self.__cancel = True self.restartServer() + + def wasCanceled(self): + """ + Public method to check, if the last command was canceled. + """ + return self.__cancel + + def isExecuting(self): + """ + Public method to check, if the server is executing a command. + + @return flag indicating the execution of a command (boolean) + """
diff -r e1d8a8a4d40c -r 885706dbb69f Plugins/VcsPlugins/vcsMercurial/HgDiffDialog.py --- a/Plugins/VcsPlugins/vcsMercurial/HgDiffDialog.py Wed Aug 31 18:44:04 2011 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/HgDiffDialog.py Wed Aug 31 19:28:49 2011 +0200 @@ -66,7 +66,8 @@ @param e close event (QCloseEvent) """ if self.__hgClient: - self.__hgClient.cancel() + if self.__hgClient.isExecuting(): + self.__hgClient.cancel() else: if self.process is not None and \ self.process.state() != QProcess.NotRunning: @@ -155,6 +156,8 @@ if out: for line in out.splitlines(True): self.__processOutputLine(line) + if self.__hgClient.wasCanceled(): + break if err: self.__showError(err)
diff -r e1d8a8a4d40c -r 885706dbb69f Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py --- a/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py Wed Aug 31 18:44:04 2011 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/HgLogBrowserDialog.py Wed Aug 31 19:28:49 2011 +0200 @@ -159,11 +159,15 @@ @param e close event (QCloseEvent) """ - if self.process is not None and \ - self.process.state() != QProcess.NotRunning: - self.process.terminate() - QTimer.singleShot(2000, self.process.kill) - self.process.waitForFinished(3000) + if self.__hgClient: + if self.__hgClient.isExecuting(): + self.__hgClient.cancel() + else: + if self.process is not None and \ + self.process.state() != QProcess.NotRunning: + self.process.terminate() + QTimer.singleShot(2000, self.process.kill) + self.process.waitForFinished(3000) e.accept()
diff -r e1d8a8a4d40c -r 885706dbb69f Plugins/VcsPlugins/vcsMercurial/HgLogDialog.py --- a/Plugins/VcsPlugins/vcsMercurial/HgLogDialog.py Wed Aug 31 18:44:04 2011 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/HgLogDialog.py Wed Aug 31 19:28:49 2011 +0200 @@ -81,7 +81,8 @@ @param e close event (QCloseEvent) """ if self.__hgClient: - self.__hgClient.cancel() + if self.__hgClient.isExecuting(): + self.__hgClient.cancel() else: if self.process is not None and \ self.process.state() != QProcess.NotRunning: @@ -153,9 +154,11 @@ out, err = self.__hgClient.runcommand(args) - if out: + if out and self.isVisible(): for line in out.splitlines(True): self.__processOutputLine(line) + if self.__hgClient.wasCanceled(): + break if err: self.__showError(err)
diff -r e1d8a8a4d40c -r 885706dbb69f Plugins/VcsPlugins/vcsMercurial/HgStatusDialog.py --- a/Plugins/VcsPlugins/vcsMercurial/HgStatusDialog.py Wed Aug 31 18:44:04 2011 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/HgStatusDialog.py Wed Aug 31 19:28:49 2011 +0200 @@ -149,11 +149,15 @@ @param e close event (QCloseEvent) """ - if self.process is not None and \ - self.process.state() != QProcess.NotRunning: - self.process.terminate() - QTimer.singleShot(2000, self.process.kill) - self.process.waitForFinished(3000) + if self.__hgClient: + if self.__hgClient.isExecuting(): + self.__hgClient.cancel() + else: + if self.process is not None and \ + self.process.state() != QProcess.NotRunning: + self.process.terminate() + QTimer.singleShot(2000, self.process.kill) + self.process.waitForFinished(3000) e.accept() @@ -212,6 +216,8 @@ if out: for line in out.splitlines(): self.__processOutputLine(line) + if self.__hgClient.wasCanceled(): + break self.__finish() else: if self.process:
diff -r e1d8a8a4d40c -r 885706dbb69f Plugins/VcsPlugins/vcsMercurial/HgTagBranchListDialog.py --- a/Plugins/VcsPlugins/vcsMercurial/HgTagBranchListDialog.py Wed Aug 31 18:44:04 2011 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/HgTagBranchListDialog.py Wed Aug 31 19:28:49 2011 +0200 @@ -56,11 +56,15 @@ @param e close event (QCloseEvent) """ - if self.process is not None and \ - self.process.state() != QProcess.NotRunning: - self.process.terminate() - QTimer.singleShot(2000, self.process.kill) - self.process.waitForFinished(3000) + if self.__hgClient: + if self.__hgClient.isExecuting(): + self.__hgClient.cancel() + else: + if self.process is not None and \ + self.process.state() != QProcess.NotRunning: + self.process.terminate() + QTimer.singleShot(2000, self.process.kill) + self.process.waitForFinished(3000) e.accept() @@ -112,6 +116,8 @@ if out: for line in out.splitlines(): self.__processOutputLine(line) + if self.__hgClient.wasCanceled(): + break self.__finish() else: self.process.kill()
diff -r e1d8a8a4d40c -r 885706dbb69f Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesDefineGuardsDialog.py --- a/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesDefineGuardsDialog.py Wed Aug 31 18:44:04 2011 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesDefineGuardsDialog.py Wed Aug 31 19:28:49 2011 +0200 @@ -56,11 +56,15 @@ @param e close event (QCloseEvent) """ - if self.process is not None and \ - self.process.state() != QProcess.NotRunning: - self.process.terminate() - QTimer.singleShot(2000, self.process.kill) - self.process.waitForFinished(3000) + if self.__hgClient: + if self.__hgClient.isExecuting(): + self.__hgClient.cancel() + else: + if self.process is not None and \ + self.process.state() != QProcess.NotRunning: + self.process.terminate() + QTimer.singleShot(2000, self.process.kill) + self.process.waitForFinished(3000) if self.__dirtyList: res = E5MessageBox.question(self,
diff -r e1d8a8a4d40c -r 885706dbb69f Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesHeaderDialog.py --- a/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesHeaderDialog.py Wed Aug 31 18:44:04 2011 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesHeaderDialog.py Wed Aug 31 19:28:49 2011 +0200 @@ -50,11 +50,15 @@ @param e close event (QCloseEvent) """ - if self.process is not None and \ - self.process.state() != QProcess.NotRunning: - self.process.terminate() - QTimer.singleShot(2000, self.process.kill) - self.process.waitForFinished(3000) + if self.__hgClient: + if self.__hgClient.isExecuting(): + self.__hgClient.cancel() + else: + if self.process is not None and \ + self.process.state() != QProcess.NotRunning: + self.process.terminate() + QTimer.singleShot(2000, self.process.kill) + self.process.waitForFinished(3000) e.accept()
diff -r e1d8a8a4d40c -r 885706dbb69f Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesListDialog.py --- a/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesListDialog.py Wed Aug 31 18:44:04 2011 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesListDialog.py Wed Aug 31 19:28:49 2011 +0200 @@ -60,11 +60,15 @@ @param e close event (QCloseEvent) """ - if self.process is not None and \ - self.process.state() != QProcess.NotRunning: - self.process.terminate() - QTimer.singleShot(2000, self.process.kill) - self.process.waitForFinished(3000) + if self.__hgClient: + if self.__hgClient.isExecuting(): + self.__hgClient.cancel() + else: + if self.process is not None and \ + self.process.state() != QProcess.NotRunning: + self.process.terminate() + QTimer.singleShot(2000, self.process.kill) + self.process.waitForFinished(3000) e.accept() @@ -121,6 +125,9 @@ if out: for line in out.splitlines(): self.__processOutputLine(line) + if self.__hgClient.wasCanceled(): + self.__mode = "" + break if self.__mode == "qseries": self.__getSeries(True) elif self.__mode == "missing": @@ -165,6 +172,8 @@ if out: for line in out.splitlines(): self.__processOutputLine(line) + if self.__hgClient.wasCanceled(): + break self.__finish() else: self.process.kill()
diff -r e1d8a8a4d40c -r 885706dbb69f Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesListGuardsDialog.py --- a/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesListGuardsDialog.py Wed Aug 31 18:44:04 2011 +0200 +++ b/Plugins/VcsPlugins/vcsMercurial/QueuesExtension/HgQueuesListGuardsDialog.py Wed Aug 31 19:28:49 2011 +0200 @@ -45,11 +45,15 @@ @param e close event (QCloseEvent) """ - if self.process is not None and \ - self.process.state() != QProcess.NotRunning: - self.process.terminate() - QTimer.singleShot(2000, self.process.kill) - self.process.waitForFinished(3000) + if self.__hgClient: + if self.__hgClient.isExecuting(): + self.__hgClient.cancel() + else: + if self.process is not None and \ + self.process.state() != QProcess.NotRunning: + self.process.terminate() + QTimer.singleShot(2000, self.process.kill) + self.process.waitForFinished(3000) e.accept()