forked from qt-creator/qt-creator
Utils: Use CommandLine in ShellCommand
... and adapt users. Change-Id: I218523ffe34720d5fe199aa0ca6892a8dc2985fc Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
@@ -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();
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -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.
|
||||
|
@@ -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);
|
||||
|
@@ -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:
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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),
|
||||
|
@@ -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());
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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));
|
||||
|
@@ -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();
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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; });
|
||||
|
@@ -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());
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
|
||||
|
@@ -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();
|
||||
|
@@ -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
|
||||
|
@@ -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,
|
||||
|
@@ -77,14 +77,12 @@ const QProcessEnvironment VcsCommand::processEnvironment() const
|
||||
return env;
|
||||
}
|
||||
|
||||
SynchronousProcessResponse VcsCommand::runCommand(const FilePath &binary,
|
||||
const QStringList &arguments, int timeoutS,
|
||||
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;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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)
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user