forked from qt-creator/qt-creator
VCS: Fix time-out handling for synchronous processes.
Introduce static utilities to Utils::SynchronousProcess for synchronous processes that mimicks the handling of Utils::SynchronousProcess (apply timeout after no more data are available on stdout/stderr as opposed to waitForFinished()). Task-number: QTCREATORBUG-777
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/synchronousprocess.h>
|
||||
#include <vcsbase/vcsbaseeditor.h>
|
||||
#include <vcsbase/vcsbaseoutputwindow.h>
|
||||
|
||||
@@ -82,14 +83,16 @@ bool MercurialClient::add(const QString &workingDir, const QString &filename)
|
||||
{
|
||||
QStringList args;
|
||||
args << QLatin1String("add") << filename;
|
||||
return executeHgSynchronously(workingDir, args);
|
||||
QByteArray stdOut;
|
||||
return executeHgSynchronously(workingDir, args, &stdOut);
|
||||
}
|
||||
|
||||
bool MercurialClient::remove(const QString &workingDir, const QString &filename)
|
||||
{
|
||||
QStringList args;
|
||||
args << QLatin1String("remove") << filename;
|
||||
return executeHgSynchronously(workingDir, args);
|
||||
QByteArray stdOut;
|
||||
return executeHgSynchronously(workingDir, args, &stdOut);
|
||||
}
|
||||
|
||||
bool MercurialClient::manifestSync(const QString &repository, const QString &relativeFilename)
|
||||
@@ -135,19 +138,17 @@ bool MercurialClient::executeHgSynchronously(const QString &workingDir,
|
||||
|
||||
hgProcess.closeWriteChannel();
|
||||
|
||||
if (!hgProcess.waitForFinished(settings.timeoutMilliSeconds())) {
|
||||
hgProcess.terminate();
|
||||
QByteArray stdErr;
|
||||
if (!Utils::SynchronousProcess::readDataFromProcess(hgProcess, settings.timeoutMilliSeconds(),
|
||||
output, &stdErr)) {
|
||||
Utils::SynchronousProcess::stopProcess(hgProcess);
|
||||
outputWindow->appendError(MercurialJobRunner::msgTimeout(settings.timeoutSeconds()));
|
||||
return false;
|
||||
}
|
||||
if (!stdErr.isEmpty())
|
||||
outputWindow->append(QString::fromLocal8Bit(stdErr));
|
||||
|
||||
if ((hgProcess.exitStatus() == QProcess::NormalExit) && (hgProcess.exitCode() == 0)) {
|
||||
if (output)
|
||||
*output = hgProcess.readAllStandardOutput();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return hgProcess.exitStatus() == QProcess::NormalExit && hgProcess.exitCode() == 0;
|
||||
}
|
||||
|
||||
QString MercurialClient::branchQuerySync(const QString &repositoryRoot)
|
||||
|
||||
Reference in New Issue
Block a user