forked from qt-creator/qt-creator
Vcs: Simplify VcsCommand::runCommand interface
The timeout and exit code interpreter properties are already accessible via the SynchronousProcess parameter. Change-Id: I1ba9c768a781009df65b5070a1d017c41d7e2663 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -274,8 +274,9 @@ void ShellCommand::run(QFutureInterface<void> &future)
|
||||
for (int j = 0; j < count; j++) {
|
||||
const Internal::ShellCommandPrivate::Job &job = d->m_jobs.at(j);
|
||||
SynchronousProcess proc;
|
||||
runCommand(proc, job.command, job.timeoutS, job.workingDirectory,
|
||||
job.exitCodeInterpreter);
|
||||
proc.setExitCodeInterpreter(job.exitCodeInterpreter);
|
||||
proc.setTimeoutS(job.timeoutS);
|
||||
runCommand(proc, job.command, job.workingDirectory);
|
||||
stdOut += proc.stdOut();
|
||||
stdErr += proc.stdErr();
|
||||
d->m_lastExecExitCode = proc.exitCode();
|
||||
@@ -307,9 +308,8 @@ void ShellCommand::run(QFutureInterface<void> &future)
|
||||
}
|
||||
|
||||
void ShellCommand::runCommand(SynchronousProcess &proc,
|
||||
const CommandLine &command, int timeoutS,
|
||||
const QString &workingDirectory,
|
||||
const ExitCodeInterpreter &interpreter)
|
||||
const CommandLine &command,
|
||||
const QString &workingDirectory)
|
||||
{
|
||||
const QString dir = workDirectory(workingDirectory);
|
||||
|
||||
@@ -323,9 +323,6 @@ void ShellCommand::runCommand(SynchronousProcess &proc,
|
||||
if (!(d->m_flags & SuppressCommandLogging))
|
||||
emit proxy->appendCommand(dir, command);
|
||||
|
||||
proc.setTimeoutS(timeoutS);
|
||||
proc.setExitCodeInterpreter(interpreter);
|
||||
|
||||
if ((d->m_flags & FullySynchronously)
|
||||
|| (!(d->m_flags & NoFullySync)
|
||||
&& QThread::currentThread() == QCoreApplication::instance()->thread())) {
|
||||
|
@@ -144,9 +144,7 @@ public:
|
||||
// be triggered!
|
||||
virtual void runCommand(Utils::SynchronousProcess &process,
|
||||
const CommandLine &command,
|
||||
int timeoutS,
|
||||
const QString &workingDirectory = QString(),
|
||||
const ExitCodeInterpreter &interpreter = {});
|
||||
const QString &workingDirectory = QString());
|
||||
|
||||
void cancel();
|
||||
|
||||
|
@@ -1668,11 +1668,12 @@ ClearCasePluginPrivate::runCleartool(const QString &workingDir,
|
||||
}
|
||||
|
||||
SynchronousProcess proc;
|
||||
proc.setTimeoutS(timeOutS);
|
||||
|
||||
VcsCommand command(workingDir, Environment::systemEnvironment());
|
||||
command.addFlags(flags);
|
||||
command.setCodec(outputCodec);
|
||||
command.runCommand(proc, {executable, arguments}, timeOutS);
|
||||
command.runCommand(proc, {executable, arguments});
|
||||
|
||||
response.error = proc.result() != QtcProcess::Finished;
|
||||
if (response.error)
|
||||
|
@@ -1447,11 +1447,12 @@ CvsResponse CvsPluginPrivate::runCvs(const QString &workingDirectory,
|
||||
}
|
||||
// Run, connect stderr to the output window
|
||||
SynchronousProcess proc;
|
||||
proc.setTimeoutS(timeOutS);
|
||||
|
||||
VcsCommand command(workingDirectory, Environment::systemEnvironment());
|
||||
command.addFlags(flags);
|
||||
command.setCodec(outputCodec);
|
||||
command.runCommand(proc, {executable, m_settings.addOptions(arguments)}, timeOutS);
|
||||
command.runCommand(proc, {executable, m_settings.addOptions(arguments)});
|
||||
|
||||
response.result = CvsResponse::OtherError;
|
||||
response.stdErr = proc.stdErr();
|
||||
|
@@ -195,7 +195,8 @@ public:
|
||||
watcher.setFuture(m_fi.future());
|
||||
connect(command.data(), &VcsCommand::stdOutText, this, &GitGrepRunner::read);
|
||||
SynchronousProcess proc;
|
||||
command->runCommand(proc, {GitClient::instance()->vcsBinary(), arguments}, 0);
|
||||
proc.setTimeoutS(0);
|
||||
command->runCommand(proc, {GitClient::instance()->vcsBinary(), arguments});
|
||||
switch (proc.result()) {
|
||||
case QtcProcess::TerminatedAbnormally:
|
||||
case QtcProcess::StartFailed:
|
||||
|
@@ -179,10 +179,11 @@ bool MercurialClient::synchronousPull(const QString &workingDir, const QString &
|
||||
Environment env = Environment::systemEnvironment();
|
||||
env.set("LANGUAGE", "C");
|
||||
SynchronousProcess proc;
|
||||
proc.setTimeoutS(vcsTimeoutS());
|
||||
|
||||
VcsCommand command(workingDir, env);
|
||||
command.addFlags(flags);
|
||||
command.runCommand(proc, {vcsBinary(), args}, vcsTimeoutS());
|
||||
command.runCommand(proc, {vcsBinary(), args});
|
||||
|
||||
const bool ok = proc.result() == QtcProcess::Finished;
|
||||
|
||||
|
@@ -162,7 +162,8 @@ void VcsBaseClientImpl::vcsFullySynchronousExec(SynchronousProcess &proc,
|
||||
command.addFlags(flags);
|
||||
if (codec)
|
||||
command.setCodec(codec);
|
||||
command.runCommand(proc, cmdLine, (timeoutS > 0) ? timeoutS : vcsTimeoutS());
|
||||
proc.setTimeoutS(timeoutS > 0 ? timeoutS : vcsTimeoutS());
|
||||
command.runCommand(proc, cmdLine);
|
||||
}
|
||||
|
||||
void VcsBaseClientImpl::resetCachedVcsInfo(const QString &workingDir)
|
||||
@@ -211,9 +212,10 @@ void VcsBaseClientImpl::vcsSynchronousExec(SynchronousProcess &proc, const QStri
|
||||
{
|
||||
Environment env = processEnvironment();
|
||||
VcsCommand command(workingDir, env.size() == 0 ? Environment::systemEnvironment() : env);
|
||||
proc.setTimeoutS(vcsTimeoutS());
|
||||
command.addFlags(flags);
|
||||
command.setCodec(outputCodec);
|
||||
command.runCommand(proc, {vcsBinary(), args}, vcsTimeoutS());
|
||||
command.runCommand(proc, {vcsBinary(), args});
|
||||
}
|
||||
|
||||
int VcsBaseClientImpl::vcsTimeoutS() const
|
||||
|
@@ -78,11 +78,9 @@ const Environment VcsCommand::processEnvironment() const
|
||||
|
||||
void VcsCommand::runCommand(SynchronousProcess &proc,
|
||||
const CommandLine &command,
|
||||
int timeoutS,
|
||||
const QString &workingDirectory,
|
||||
const ExitCodeInterpreter &interpreter)
|
||||
const QString &workingDirectory)
|
||||
{
|
||||
ShellCommand::runCommand(proc, command, timeoutS, workingDirectory, interpreter);
|
||||
ShellCommand::runCommand(proc, command, workingDirectory);
|
||||
emitRepositoryChanged(workingDirectory);
|
||||
}
|
||||
|
||||
|
@@ -47,9 +47,7 @@ public:
|
||||
|
||||
void runCommand(Utils::SynchronousProcess &process,
|
||||
const Utils::CommandLine &command,
|
||||
int timeoutS,
|
||||
const QString &workDirectory = QString(),
|
||||
const Utils::ExitCodeInterpreter &interpreter = {}) override;
|
||||
const QString &workDirectory = {}) override;
|
||||
|
||||
private:
|
||||
void emitRepositoryChanged(const QString &workingDirectory);
|
||||
|
Reference in New Issue
Block a user