diff options
29 files changed, 78 insertions, 90 deletions
diff --git a/src/libs/utils/shellcommand.cpp b/src/libs/utils/shellcommand.cpp index 99292b734a..99b0b0ace6 100644 --- a/src/libs/utils/shellcommand.cpp +++ b/src/libs/utils/shellcommand.cpp @@ -68,12 +68,11 @@ class ShellCommandPrivate { public: struct Job { - explicit Job(const QString &wd, const FilePath &b, const QStringList &a, int t, + explicit Job(const QString &wd, const CommandLine &command, int t, const ExitCodeInterpreter &interpreter); QString workingDirectory; - FilePath binary; - QStringList arguments; + CommandLine command; ExitCodeInterpreter exitCodeInterpreter; int timeoutS; }; @@ -113,11 +112,10 @@ ShellCommandPrivate::~ShellCommandPrivate() delete m_progressParser; } -ShellCommandPrivate::Job::Job(const QString &wd, const FilePath &b, const QStringList &a, +ShellCommandPrivate::Job::Job(const QString &wd, const CommandLine &command, int t, const ExitCodeInterpreter &interpreter) : workingDirectory(wd), - binary(b), - arguments(a), + command(command), exitCodeInterpreter(interpreter), timeoutS(t) { @@ -146,14 +144,14 @@ QString ShellCommand::displayName() const return d->m_displayName; if (!d->m_jobs.isEmpty()) { const Internal::ShellCommandPrivate::Job &job = d->m_jobs.at(0); - QString result = job.binary.toFileInfo().baseName(); + QString result = job.command.executable().toFileInfo().baseName(); if (!result.isEmpty()) result[0] = result.at(0).toTitleCase(); else result = tr("UNKNOWN"); - if (!job.arguments.isEmpty()) - result += QLatin1Char(' ') + job.arguments.at(0); + if (!job.command.arguments().isEmpty()) + result += ' ' + job.command.arguments().at(0); return result; } @@ -195,17 +193,17 @@ void ShellCommand::addFlags(unsigned f) d->m_flags |= f; } -void ShellCommand::addJob(const FilePath &binary, const QStringList &arguments, +void ShellCommand::addJob(const CommandLine &command, const QString &workingDirectory, const ExitCodeInterpreter &interpreter) { - addJob(binary, arguments, defaultTimeoutS(), workingDirectory, interpreter); + addJob(command, defaultTimeoutS(), workingDirectory, interpreter); } -void ShellCommand::addJob(const FilePath &binary, const QStringList &arguments, int timeoutS, +void ShellCommand::addJob(const CommandLine &command, int timeoutS, const QString &workingDirectory, const ExitCodeInterpreter &interpreter) { - d->m_jobs.push_back(Internal::ShellCommandPrivate::Job(workDirectory(workingDirectory), binary, - arguments, timeoutS, interpreter)); + d->m_jobs.push_back(Internal::ShellCommandPrivate::Job(workDirectory(workingDirectory), command, + timeoutS, interpreter)); } void ShellCommand::execute() @@ -287,7 +285,7 @@ void ShellCommand::run(QFutureInterface<void> &future) for (int j = 0; j < count; j++) { const Internal::ShellCommandPrivate::Job &job = d->m_jobs.at(j); SynchronousProcessResponse resp - = runCommand(job.binary, job.arguments, job.timeoutS, job.workingDirectory, + = runCommand(job.command, job.timeoutS, job.workingDirectory, job.exitCodeInterpreter); stdOut += resp.stdOut(); stdErr += resp.stdErr(); @@ -319,8 +317,7 @@ void ShellCommand::run(QFutureInterface<void> &future) this->deleteLater(); } -SynchronousProcessResponse ShellCommand::runCommand(const FilePath &binary, - const QStringList &arguments, int timeoutS, +SynchronousProcessResponse ShellCommand::runCommand(const CommandLine &command, int timeoutS, const QString &workingDirectory, const ExitCodeInterpreter &interpreter) { @@ -328,7 +325,7 @@ SynchronousProcessResponse ShellCommand::runCommand(const FilePath &binary, const QString dir = workDirectory(workingDirectory); - if (binary.isEmpty()) { + if (command.executable().isEmpty()) { response.result = SynchronousProcessResponse::StartFailed; return response; } @@ -336,23 +333,23 @@ SynchronousProcessResponse ShellCommand::runCommand(const FilePath &binary, QSharedPointer<OutputProxy> proxy(d->m_proxyFactory()); if (!(d->m_flags & SuppressCommandLogging)) - emit proxy->appendCommand(dir, binary, arguments); + emit proxy->appendCommand(dir, command); if ((d->m_flags & FullySynchronously) || (!(d->m_flags & NoFullySync) && QThread::currentThread() == QCoreApplication::instance()->thread())) { - response = runFullySynchronous({binary, arguments}, proxy, timeoutS, dir, interpreter); + response = runFullySynchronous(command, proxy, timeoutS, dir, interpreter); } else { - response = runSynchronous({binary, arguments}, proxy, timeoutS, dir, interpreter); + response = runSynchronous(command, proxy, timeoutS, dir, interpreter); } if (!d->m_aborted) { // Success/Fail message in appropriate window? if (response.result == SynchronousProcessResponse::Finished) { if (d->m_flags & ShowSuccessMessage) - emit proxy->appendMessage(response.exitMessage(binary.toUserOutput(), timeoutS)); + emit proxy->appendMessage(response.exitMessage(command.toUserOutput(), timeoutS)); } else if (!(d->m_flags & SuppressFailMessage)) { - emit proxy->appendError(response.exitMessage(binary.toUserOutput(), timeoutS)); + emit proxy->appendError(response.exitMessage(command.toUserOutput(), timeoutS)); } } diff --git a/src/libs/utils/shellcommand.h b/src/libs/utils/shellcommand.h index a90b4fe70e..a54e8fb401 100644 --- a/src/libs/utils/shellcommand.h +++ b/src/libs/utils/shellcommand.h @@ -46,7 +46,7 @@ QT_END_NAMESPACE namespace Utils { -class FilePath; +class CommandLine; namespace Internal { class ShellCommandPrivate; } class QTCREATOR_UTILS_EXPORT ProgressParser @@ -79,8 +79,7 @@ signals: void append(const QString &text); void appendSilently(const QString &text); void appendError(const QString &text); - void appendCommand(const QString &workingDirectory, const Utils::FilePath &binary, - const QStringList &args); + void appendCommand(const QString &workingDirectory, const Utils::CommandLine &command); void appendMessage(const QString &text); }; @@ -112,10 +111,12 @@ public: QString displayName() const; void setDisplayName(const QString &name); - void addJob(const FilePath &binary, const QStringList &arguments, - const QString &workingDirectory = QString(), const ExitCodeInterpreter &interpreter = defaultExitCodeInterpreter); - void addJob(const FilePath &binary, const QStringList &arguments, int timeoutS, - const QString &workingDirectory = QString(), const ExitCodeInterpreter &interpreter = defaultExitCodeInterpreter); + void addJob(const CommandLine &command, + const QString &workingDirectory = QString(), + const ExitCodeInterpreter &interpreter = defaultExitCodeInterpreter); + void addJob(const CommandLine &command, int timeoutS, + const QString &workingDirectory = QString(), + const ExitCodeInterpreter &interpreter = defaultExitCodeInterpreter); void execute(); // Execute tasks asynchronously! void abort(); bool lastExecutionSuccess() const; @@ -145,7 +146,7 @@ public: // This is called once per job in a thread. // When called from the UI thread it will execute fully synchronously, so no signals will // be triggered! - virtual SynchronousProcessResponse runCommand(const FilePath &binary, const QStringList &arguments, + virtual SynchronousProcessResponse runCommand(const CommandLine &command, int timeoutS, const QString &workingDirectory = QString(), const ExitCodeInterpreter &interpreter = defaultExitCodeInterpreter); diff --git a/src/plugins/bazaar/bazaarcontrol.cpp b/src/plugins/bazaar/bazaarcontrol.cpp index 7b38aa971c..e420723b62 100644 --- a/src/plugins/bazaar/bazaarcontrol.cpp +++ b/src/plugins/bazaar/bazaarcontrol.cpp @@ -150,7 +150,7 @@ Core::ShellCommand *BazaarControl::createInitialCheckoutCommand(const QString &u QProcessEnvironment env = m_bazaarClient->processEnvironment(); env.insert(QLatin1String("BZR_PROGRESS_BAR"), QLatin1String("text")); auto command = new VcsBase::VcsCommand(baseDirectory.toString(), env); - command->addJob(m_bazaarClient->vcsBinary(), args, -1); + command->addJob({m_bazaarClient->vcsBinary(), args}, -1); return command; } diff --git a/src/plugins/clearcase/clearcaseplugin.cpp b/src/plugins/clearcase/clearcaseplugin.cpp index 928afec064..0babf9f46d 100644 --- a/src/plugins/clearcase/clearcaseplugin.cpp +++ b/src/plugins/clearcase/clearcaseplugin.cpp @@ -1452,8 +1452,9 @@ ClearCasePlugin::runCleartool(const QString &workingDir, } const SynchronousProcessResponse sp_resp = - VcsBasePlugin::runVcs(workingDir, FilePath::fromUserInput(executable), - arguments, timeOutS, + VcsBasePlugin::runVcs(workingDir, + {FilePath::fromUserInput(executable), arguments}, + timeOutS, flags, outputCodec); response.error = sp_resp.result != SynchronousProcessResponse::Finished; diff --git a/src/plugins/cvs/cvscontrol.cpp b/src/plugins/cvs/cvscontrol.cpp index 454e95df63..0a88fff266 100644 --- a/src/plugins/cvs/cvscontrol.cpp +++ b/src/plugins/cvs/cvscontrol.cpp @@ -151,7 +151,7 @@ Core::ShellCommand *CvsControl::createInitialCheckoutCommand(const QString &url, auto command = new VcsBase::VcsCommand(baseDirectory.toString(), QProcessEnvironment::systemEnvironment()); command->setDisplayName(tr("CVS Checkout")); - command->addJob(m_plugin->client()->vcsBinary(), settings.addOptions(args), -1); + command->addJob({m_plugin->client()->vcsBinary(), settings.addOptions(args)}, -1); return command; } diff --git a/src/plugins/cvs/cvsplugin.cpp b/src/plugins/cvs/cvsplugin.cpp index 1d771ca31f..f46b5ffe8a 100644 --- a/src/plugins/cvs/cvsplugin.cpp +++ b/src/plugins/cvs/cvsplugin.cpp @@ -1109,7 +1109,7 @@ CvsResponse CvsPlugin::runCvs(const QString &workingDirectory, } // Run, connect stderr to the output window const SynchronousProcessResponse sp_resp = - runVcs(workingDirectory, executable, client()->settings().addOptions(arguments), + runVcs(workingDirectory, {executable, client()->settings().addOptions(arguments)}, timeOutS, flags, outputCodec); response.result = CvsResponse::OtherError; diff --git a/src/plugins/git/gerrit/gerritmodel.cpp b/src/plugins/git/gerrit/gerritmodel.cpp index ea3e311b52..0e6fcac3d5 100644 --- a/src/plugins/git/gerrit/gerritmodel.cpp +++ b/src/plugins/git/gerrit/gerritmodel.cpp @@ -315,7 +315,7 @@ void QueryContext::start() m_progress.reportStarted(); // Order: synchronous call to error handling if something goes wrong. VcsOutputWindow::appendCommand( - m_process.workingDirectory(), Utils::FilePath::fromString(m_binary), m_arguments); + m_process.workingDirectory(), {Utils::FilePath::fromString(m_binary), m_arguments}); m_timer.start(); m_process.start(m_binary, m_arguments); m_process.closeWriteChannel(); diff --git a/src/plugins/git/gerrit/gerritplugin.cpp b/src/plugins/git/gerrit/gerritplugin.cpp index 7dfdc5de61..f0aebf59d8 100644 --- a/src/plugins/git/gerrit/gerritplugin.cpp +++ b/src/plugins/git/gerrit/gerritplugin.cpp @@ -170,7 +170,7 @@ void FetchContext::start() m_progress.reportStarted(); // Order: initialize future before starting the process in case error handling is invoked. const QStringList args = m_change->gitFetchArguments(m_server); - VcsBase::VcsOutputWindow::appendCommand(m_repository, m_git, args); + VcsBase::VcsOutputWindow::appendCommand(m_repository, {m_git, args}); m_process.start(m_git.toString(), args); m_process.closeWriteChannel(); } diff --git a/src/plugins/git/gerrit/gerritserver.cpp b/src/plugins/git/gerrit/gerritserver.cpp index c07f22adcc..327ccf565b 100644 --- a/src/plugins/git/gerrit/gerritserver.cpp +++ b/src/plugins/git/gerrit/gerritserver.cpp @@ -243,7 +243,7 @@ int GerritServer::testConnection() static GitClient *const client = GitPlugin::client(); const QStringList arguments = curlArguments() << (url(RestUrl) + accountUrlC); const SynchronousProcessResponse resp = client->vcsFullySynchronousExec( - QString(), FilePath::fromString(curlBinary), arguments, + QString(), {FilePath::fromString(curlBinary), arguments}, Core::ShellCommand::NoOutput); if (resp.result == SynchronousProcessResponse::Finished) { QString output = resp.stdOut(); @@ -345,7 +345,7 @@ void GerritServer::resolveVersion(const GerritParameters &p, bool forceReload) arguments << p.portFlag << QString::number(port); arguments << hostArgument() << "gerrit" << "version"; const SynchronousProcessResponse resp = client->vcsFullySynchronousExec( - QString(), FilePath::fromString(p.ssh), arguments, + QString(), {FilePath::fromString(p.ssh), arguments}, Core::ShellCommand::NoOutput); QString stdOut = resp.stdOut().trimmed(); stdOut.remove("gerrit version "); @@ -353,7 +353,7 @@ void GerritServer::resolveVersion(const GerritParameters &p, bool forceReload) } else { const QStringList arguments = curlArguments() << (url(RestUrl) + versionUrlC); const SynchronousProcessResponse resp = client->vcsFullySynchronousExec( - QString(), FilePath::fromString(curlBinary), arguments, + QString(), {FilePath::fromString(curlBinary), arguments}, Core::ShellCommand::NoOutput); // REST endpoint for version is only available from 2.8 and up. Do not consider invalid // if it fails. diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index 92bd78b6c6..9ddcdd77e3 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -2421,7 +2421,7 @@ bool GitClient::tryLauchingGitK(const QProcessEnvironment &env, arguments.append(QtcProcess::splitArgs(gitkOpts, HostOsInfo::hostOs())); if (!fileName.isEmpty()) arguments << "--" << fileName; - VcsOutputWindow::appendCommand(workingDirectory, FilePath::fromString(binary), arguments); + VcsOutputWindow::appendCommand(workingDirectory, {FilePath::fromString(binary), arguments}); // This should always use QProcess::startDetached (as not to kill // the child), but that does not have an environment parameter. bool success = false; @@ -3147,7 +3147,7 @@ VcsCommand *GitClient::vcsExecAbortable(const QString &workingDirectory, | VcsCommand::ShowSuccessMessage); // For rebase, Git might request an editor (which means the process keeps running until the // user closes it), so run without timeout. - command->addJob(vcsBinary(), arguments, isRebase ? 0 : command->defaultTimeoutS()); + command->addJob({vcsBinary(), arguments}, isRebase ? 0 : command->defaultTimeoutS()); ConflictHandler::attachToCommand(command, abortCommand); if (isRebase) GitProgressParser::attachToCommand(command); diff --git a/src/plugins/git/gitgrep.cpp b/src/plugins/git/gitgrep.cpp index 65d698ec0b..f276a5e725 100644 --- a/src/plugins/git/gitgrep.cpp +++ b/src/plugins/git/gitgrep.cpp @@ -196,7 +196,7 @@ public: connect(&watcher, &QFutureWatcher<FileSearchResultList>::canceled, command.data(), &VcsCommand::cancel); connect(command.data(), &VcsCommand::stdOutText, this, &GitGrepRunner::read); - SynchronousProcessResponse resp = command->runCommand(client->vcsBinary(), arguments, 0); + SynchronousProcessResponse resp = command->runCommand({client->vcsBinary(), arguments}, 0); switch (resp.result) { case SynchronousProcessResponse::TerminatedAbnormally: case SynchronousProcessResponse::StartFailed: diff --git a/src/plugins/git/gitversioncontrol.cpp b/src/plugins/git/gitversioncontrol.cpp index 379eb67c64..38231527b2 100644 --- a/src/plugins/git/gitversioncontrol.cpp +++ b/src/plugins/git/gitversioncontrol.cpp @@ -159,7 +159,7 @@ Core::ShellCommand *GitVersionControl::createInitialCheckoutCommand(const QStrin auto command = new VcsBase::VcsCommand(baseDirectory.toString(), m_client->processEnvironment()); command->addFlags(VcsBase::VcsCommand::SuppressStdErr); - command->addJob(m_client->vcsBinary(), args, -1); + command->addJob({m_client->vcsBinary(), args}, -1); return command; } diff --git a/src/plugins/git/mergetool.cpp b/src/plugins/git/mergetool.cpp index 8558163dfc..9878ad900b 100644 --- a/src/plugins/git/mergetool.cpp +++ b/src/plugins/git/mergetool.cpp @@ -62,7 +62,7 @@ bool MergeTool::start(const QString &workingDirectory, const QStringList &files) m_process->setProcessEnvironment(env); m_process->setProcessChannelMode(QProcess::MergedChannels); const Utils::FilePath binary = GitPlugin::client()->vcsBinary(); - VcsOutputWindow::appendCommand(workingDirectory, binary, arguments); + VcsOutputWindow::appendCommand(workingDirectory, {binary, arguments}); m_process->start(binary.toString(), arguments); if (m_process->waitForStarted()) { connect(m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished), diff --git a/src/plugins/mercurial/mercurialclient.cpp b/src/plugins/mercurial/mercurialclient.cpp index 7d9b8dd209..0f1ee2f510 100644 --- a/src/plugins/mercurial/mercurialclient.cpp +++ b/src/plugins/mercurial/mercurialclient.cpp @@ -232,7 +232,7 @@ bool MercurialClient::synchronousPull(const QString &workingDir, const QString & QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); env.insert(QLatin1String("LANGUAGE"), QLatin1String("C")); const SynchronousProcessResponse resp = VcsBasePlugin::runVcs( - workingDir, vcsBinary(), args, vcsTimeoutS(), flags, nullptr, env); + workingDir, {vcsBinary(), args}, vcsTimeoutS(), flags, nullptr, env); const bool ok = resp.result == SynchronousProcessResponse::Finished; parsePullOutput(resp.stdOut().trimmed()); diff --git a/src/plugins/mercurial/mercurialcontrol.cpp b/src/plugins/mercurial/mercurialcontrol.cpp index 48395ad488..36783aaba5 100644 --- a/src/plugins/mercurial/mercurialcontrol.cpp +++ b/src/plugins/mercurial/mercurialcontrol.cpp @@ -172,7 +172,7 @@ Core::ShellCommand *MercurialControl::createInitialCheckoutCommand(const QString args << QLatin1String("clone") << extraArgs << url << localName; auto command = new VcsBase::VcsCommand(baseDirectory.toString(), mercurialClient->processEnvironment()); - command->addJob(mercurialClient->vcsBinary(), args, -1); + command->addJob({mercurialClient->vcsBinary(), args}, -1); return command; } diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp index 5a3d4fed48..0fb4c09b39 100644 --- a/src/plugins/perforce/perforceplugin.cpp +++ b/src/plugins/perforce/perforceplugin.cpp @@ -1119,7 +1119,7 @@ PerforceResponse PerforcePlugin::runP4Cmd(const QString &workingDir, actualArgs.append(args); if (flags & CommandToWindow) - VcsOutputWindow::appendCommand(workingDir, FilePath::fromString(settings().p4BinaryPath()), actualArgs); + VcsOutputWindow::appendCommand(workingDir, {FilePath::fromString(settings().p4BinaryPath()), actualArgs}); if (flags & ShowBusyCursor) QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); diff --git a/src/plugins/subversion/subversionclient.cpp b/src/plugins/subversion/subversionclient.cpp index 6982bb854b..7401fe37ff 100644 --- a/src/plugins/subversion/subversionclient.cpp +++ b/src/plugins/subversion/subversionclient.cpp @@ -150,7 +150,7 @@ QString SubversionClient::synchronousTopic(const QString &repository) svnVersionBinary = svnVersionBinary.left(pos + 1); svnVersionBinary.append(HostOsInfo::withExecutableSuffix("svnversion")); const SynchronousProcessResponse result - = vcsFullySynchronousExec(repository, FilePath::fromString(svnVersionBinary), args); + = vcsFullySynchronousExec(repository, {FilePath::fromString(svnVersionBinary), args}); if (result.result != SynchronousProcessResponse::Finished) return QString(); diff --git a/src/plugins/subversion/subversioncontrol.cpp b/src/plugins/subversion/subversioncontrol.cpp index 0d4a024271..70604a5650 100644 --- a/src/plugins/subversion/subversioncontrol.cpp +++ b/src/plugins/subversion/subversioncontrol.cpp @@ -171,7 +171,7 @@ Core::ShellCommand *SubversionControl::createInitialCheckoutCommand(const QStrin args << extraArgs << url << localName; auto command = new VcsBase::VcsCommand(baseDirectory.toString(), client->processEnvironment()); - command->addJob(client->vcsBinary(), args, -1); + command->addJob({client->vcsBinary(), args}, -1); return command; } diff --git a/src/plugins/updateinfo/updateinfoplugin.cpp b/src/plugins/updateinfo/updateinfoplugin.cpp index 08e644bc5e..549efee091 100644 --- a/src/plugins/updateinfo/updateinfoplugin.cpp +++ b/src/plugins/updateinfo/updateinfoplugin.cpp @@ -128,7 +128,7 @@ void UpdateInfoPlugin::startCheckForUpdates() d->m_checkUpdatesCommand->setDisplayName(tr("Checking for Updates")); connect(d->m_checkUpdatesCommand, &ShellCommand::stdOutText, this, &UpdateInfoPlugin::collectCheckForUpdatesOutput); connect(d->m_checkUpdatesCommand, &ShellCommand::finished, this, &UpdateInfoPlugin::checkForUpdatesFinished); - d->m_checkUpdatesCommand->addJob(Utils::FilePath::fromFileInfo(d->m_maintenanceTool), {"--checkupdates"}, + d->m_checkUpdatesCommand->addJob({Utils::FilePath::fromFileInfo(d->m_maintenanceTool), {"--checkupdates"}}, 60 * 3, // 3 minutes timeout /*workingDirectory=*/QString(), [](int /*exitCode*/) { return Utils::SynchronousProcessResponse::Finished; }); diff --git a/src/plugins/vcsbase/vcsbaseclient.cpp b/src/plugins/vcsbase/vcsbaseclient.cpp index 4e772f3b2c..c359060d7c 100644 --- a/src/plugins/vcsbase/vcsbaseclient.cpp +++ b/src/plugins/vcsbase/vcsbaseclient.cpp @@ -138,7 +138,7 @@ void VcsBaseClientImpl::enqueueJob(VcsCommand *cmd, const QStringList &args, const QString &workingDirectory, const ExitCodeInterpreter &interpreter) const { - cmd->addJob(vcsBinary(), args, vcsTimeoutS(), workingDirectory, interpreter); + cmd->addJob({vcsBinary(), args}, vcsTimeoutS(), workingDirectory, interpreter); cmd->execute(); } @@ -178,15 +178,14 @@ QString VcsBaseClientImpl::stripLastNewline(const QString &in) } SynchronousProcessResponse -VcsBaseClientImpl::vcsFullySynchronousExec(const QString &workingDir, const FilePath &binary, - const QStringList &args, unsigned flags, - int timeoutS, QTextCodec *codec) const +VcsBaseClientImpl::vcsFullySynchronousExec(const QString &workingDir, const CommandLine &cmdLine, + unsigned flags, int timeoutS, QTextCodec *codec) const { VcsCommand command(workingDir, processEnvironment()); command.addFlags(flags); if (codec) command.setCodec(codec); - return command.runCommand(binary, args, (timeoutS > 0) ? timeoutS : vcsTimeoutS()); + return command.runCommand(cmdLine, (timeoutS > 0) ? timeoutS : vcsTimeoutS()); } void VcsBaseClientImpl::resetCachedVcsInfo(const QString &workingDir) @@ -211,7 +210,7 @@ SynchronousProcessResponse VcsBaseClientImpl::vcsFullySynchronousExec(const QString &workingDir, const QStringList &args, unsigned flags, int timeoutS, QTextCodec *codec) const { - return vcsFullySynchronousExec(workingDir, vcsBinary(), args, flags, timeoutS, codec); + return vcsFullySynchronousExec(workingDir, {vcsBinary(), args}, flags, timeoutS, codec); } VcsCommand *VcsBaseClientImpl::vcsExec(const QString &workingDirectory, const QStringList &arguments, @@ -233,7 +232,7 @@ SynchronousProcessResponse VcsBaseClientImpl::vcsSynchronousExec(const QString & unsigned flags, QTextCodec *outputCodec) const { - return VcsBasePlugin::runVcs(workingDir, vcsBinary(), args, vcsTimeoutS(), flags, + return VcsBasePlugin::runVcs(workingDir, {vcsBinary(), args}, vcsTimeoutS(), flags, outputCodec, processEnvironment()); } diff --git a/src/plugins/vcsbase/vcsbaseclient.h b/src/plugins/vcsbase/vcsbaseclient.h index 0706d53861..96e9ca5e40 100644 --- a/src/plugins/vcsbase/vcsbaseclient.h +++ b/src/plugins/vcsbase/vcsbaseclient.h @@ -105,7 +105,7 @@ public: vcsFullySynchronousExec(const QString &workingDir, const QStringList &args, unsigned flags = 0, int timeoutS = -1, QTextCodec *codec = nullptr) const; Utils::SynchronousProcessResponse - vcsFullySynchronousExec(const QString &workingDir, const Utils::FilePath &binary, const QStringList &args, + vcsFullySynchronousExec(const QString &workingDir, const Utils::CommandLine &cmdLine, unsigned flags = 0, int timeoutS = -1, QTextCodec *codec = nullptr) const; diff --git a/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp b/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp index cb41e7e7d2..b2d989d781 100644 --- a/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp +++ b/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp @@ -260,7 +260,7 @@ void VcsBaseDiffEditorController::runCommand(const QList<QStringList> &args, uns for (const QStringList &arg : args) { QTC_ASSERT(!arg.isEmpty(), continue); - d->m_command->addJob(d->m_client->vcsBinary(), arg, d->m_client->vcsTimeoutS()); + d->m_command->addJob({d->m_client->vcsBinary(), arg}, d->m_client->vcsTimeoutS()); } d->m_command->execute(); diff --git a/src/plugins/vcsbase/vcsbaseplugin.cpp b/src/plugins/vcsbase/vcsbaseplugin.cpp index 298fdf61b3..9ae4e93486 100644 --- a/src/plugins/vcsbase/vcsbaseplugin.cpp +++ b/src/plugins/vcsbase/vcsbaseplugin.cpp @@ -791,8 +791,7 @@ void VcsBasePlugin::setProcessEnvironment(QProcessEnvironment *e, // Run a process synchronously, returning Utils::SynchronousProcessResponse // response struct and using the VcsBasePlugin flags as applicable SynchronousProcessResponse VcsBasePlugin::runVcs(const QString &workingDir, - const FilePath &binary, - const QStringList &arguments, + const CommandLine &cmd, int timeOutS, unsigned flags, QTextCodec *outputCodec, @@ -801,7 +800,7 @@ SynchronousProcessResponse VcsBasePlugin::runVcs(const QString &workingDir, VcsCommand command(workingDir, env.isEmpty() ? QProcessEnvironment::systemEnvironment() : env); command.addFlags(flags); command.setCodec(outputCodec); - return command.runCommand(binary, arguments, timeOutS); + return command.runCommand(cmd, timeOutS); } } // namespace VcsBase diff --git a/src/plugins/vcsbase/vcsbaseplugin.h b/src/plugins/vcsbase/vcsbaseplugin.h index e1bfa15ded..779092e185 100644 --- a/src/plugins/vcsbase/vcsbaseplugin.h +++ b/src/plugins/vcsbase/vcsbaseplugin.h @@ -41,7 +41,7 @@ class QTextCodec; QT_END_NAMESPACE namespace Utils { -class FilePath; +class CommandLine; class SynchronousProcessResponse; } // namespace Utils @@ -170,8 +170,7 @@ public: static QString source(Core::IDocument *document); static Utils::SynchronousProcessResponse runVcs(const QString &workingDir, - const Utils::FilePath &binary, - const QStringList &arguments, + const Utils::CommandLine &cmd, int timeOutS, unsigned flags = 0, QTextCodec *outputCodec = nullptr, diff --git a/src/plugins/vcsbase/vcscommand.cpp b/src/plugins/vcsbase/vcscommand.cpp index a659b13fec..1a5c3c27f5 100644 --- a/src/plugins/vcsbase/vcscommand.cpp +++ b/src/plugins/vcsbase/vcscommand.cpp @@ -77,14 +77,12 @@ const QProcessEnvironment VcsCommand::processEnvironment() const return env; } -SynchronousProcessResponse VcsCommand::runCommand(const FilePath &binary, - const QStringList &arguments, int timeoutS, - const QString &workingDirectory, - const ExitCodeInterpreter &interpreter) +SynchronousProcessResponse VcsCommand::runCommand(const CommandLine &command, int timeoutS, + const QString &workingDirectory, + const ExitCodeInterpreter &interpreter) { SynchronousProcessResponse response - = Core::ShellCommand::runCommand(binary, arguments, timeoutS, workingDirectory, - interpreter); + = Core::ShellCommand::runCommand(command, timeoutS, workingDirectory, interpreter); emitRepositoryChanged(workingDirectory); return response; } diff --git a/src/plugins/vcsbase/vcscommand.h b/src/plugins/vcsbase/vcscommand.h index 191b72b980..e092b25177 100644 --- a/src/plugins/vcsbase/vcscommand.h +++ b/src/plugins/vcsbase/vcscommand.h @@ -45,8 +45,8 @@ public: const QProcessEnvironment processEnvironment() const override; - Utils::SynchronousProcessResponse runCommand(const Utils::FilePath &binary, - const QStringList &arguments, int timeoutS, + Utils::SynchronousProcessResponse runCommand(const Utils::CommandLine &command, + int timeoutS, const QString &workDirectory = QString(), const Utils::ExitCodeInterpreter &interpreter = Utils::defaultExitCodeInterpreter) override; diff --git a/src/plugins/vcsbase/vcsoutputwindow.cpp b/src/plugins/vcsbase/vcsoutputwindow.cpp index 4c559a9c74..d5b4a48b8e 100644 --- a/src/plugins/vcsbase/vcsoutputwindow.cpp +++ b/src/plugins/vcsbase/vcsoutputwindow.cpp @@ -456,12 +456,10 @@ static inline QString formatArguments(const QStringList &args) return rc; } -QString VcsOutputWindow::msgExecutionLogEntry(const QString &workingDir, - const FilePath &executable, - const QStringList &arguments) +QString VcsOutputWindow::msgExecutionLogEntry(const QString &workingDir, const CommandLine &command) { - const QString args = formatArguments(arguments); - const QString nativeExecutable = QtcProcess::quoteArg(executable.toUserOutput()); + const QString args = formatArguments(command.splitArguments()); + const QString nativeExecutable = QtcProcess::quoteArg(command.executable().toUserOutput()); if (workingDir.isEmpty()) return tr("Running: %1 %2").arg(nativeExecutable, args) + '\n'; return tr("Running in %1: %2 %3"). @@ -473,11 +471,9 @@ void VcsOutputWindow::appendShellCommandLine(const QString &text) append(filterPasswordFromUrls(text), Command, true); } -void VcsOutputWindow::appendCommand(const QString &workingDirectory, - const FilePath &binary, - const QStringList &args) +void VcsOutputWindow::appendCommand(const QString &workingDirectory, const CommandLine &command) { - appendShellCommandLine(msgExecutionLogEntry(workingDirectory, binary, args)); + appendShellCommandLine(msgExecutionLogEntry(workingDirectory, command)); } void VcsOutputWindow::appendMessage(const QString &text) diff --git a/src/plugins/vcsbase/vcsoutputwindow.h b/src/plugins/vcsbase/vcsoutputwindow.h index d54b4e6306..749e824c38 100644 --- a/src/plugins/vcsbase/vcsoutputwindow.h +++ b/src/plugins/vcsbase/vcsoutputwindow.h @@ -29,7 +29,7 @@ #include <coreplugin/ioutputpane.h> -namespace Utils { class FilePath; } +namespace Utils { class CommandLine; } namespace VcsBase { namespace Internal { class VcsPlugin; } @@ -66,8 +66,7 @@ public: // 'Executing <dir>: <cmd> <args>'. Hides well-known password option // arguments. static QString msgExecutionLogEntry(const QString &workingDir, - const Utils::FilePath &executable, - const QStringList &arguments); + const Utils::CommandLine &command); enum MessageStyle { None, @@ -107,8 +106,7 @@ public slots: // Append a standard-formatted entry for command execution // (see msgExecutionLogEntry). static void appendCommand(const QString &workingDirectory, - const Utils::FilePath &binary, - const QStringList &args); + const Utils::CommandLine &command); // Append a blue message text and pop up. static void appendMessage(const QString &text); diff --git a/src/plugins/vcsbase/wizard/vcscommandpage.cpp b/src/plugins/vcsbase/wizard/vcscommandpage.cpp index f40138c1a3..653df132fd 100644 --- a/src/plugins/vcsbase/wizard/vcscommandpage.cpp +++ b/src/plugins/vcsbase/wizard/vcscommandpage.cpp @@ -310,7 +310,7 @@ void VcsCommandPage::delayedInitialize() const QString dir = wiz->expander()->expand(job.workDirectory); const int timeoutS = command->defaultTimeoutS() * job.timeOutFactor; - command->addJob(FilePath::fromUserInput(commandString), args, timeoutS, dir); + command->addJob({FilePath::fromUserInput(commandString), args}, timeoutS, dir); } start(command); |