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:
|
public:
|
||||||
struct Job {
|
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);
|
const ExitCodeInterpreter &interpreter);
|
||||||
|
|
||||||
QString workingDirectory;
|
QString workingDirectory;
|
||||||
FilePath binary;
|
CommandLine command;
|
||||||
QStringList arguments;
|
|
||||||
ExitCodeInterpreter exitCodeInterpreter;
|
ExitCodeInterpreter exitCodeInterpreter;
|
||||||
int timeoutS;
|
int timeoutS;
|
||||||
};
|
};
|
||||||
@@ -113,11 +112,10 @@ ShellCommandPrivate::~ShellCommandPrivate()
|
|||||||
delete m_progressParser;
|
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) :
|
int t, const ExitCodeInterpreter &interpreter) :
|
||||||
workingDirectory(wd),
|
workingDirectory(wd),
|
||||||
binary(b),
|
command(command),
|
||||||
arguments(a),
|
|
||||||
exitCodeInterpreter(interpreter),
|
exitCodeInterpreter(interpreter),
|
||||||
timeoutS(t)
|
timeoutS(t)
|
||||||
{
|
{
|
||||||
@@ -146,14 +144,14 @@ QString ShellCommand::displayName() const
|
|||||||
return d->m_displayName;
|
return d->m_displayName;
|
||||||
if (!d->m_jobs.isEmpty()) {
|
if (!d->m_jobs.isEmpty()) {
|
||||||
const Internal::ShellCommandPrivate::Job &job = d->m_jobs.at(0);
|
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())
|
if (!result.isEmpty())
|
||||||
result[0] = result.at(0).toTitleCase();
|
result[0] = result.at(0).toTitleCase();
|
||||||
else
|
else
|
||||||
result = tr("UNKNOWN");
|
result = tr("UNKNOWN");
|
||||||
|
|
||||||
if (!job.arguments.isEmpty())
|
if (!job.command.arguments().isEmpty())
|
||||||
result += QLatin1Char(' ') + job.arguments.at(0);
|
result += ' ' + job.command.arguments().at(0);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -195,17 +193,17 @@ void ShellCommand::addFlags(unsigned f)
|
|||||||
d->m_flags |= 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)
|
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)
|
const QString &workingDirectory, const ExitCodeInterpreter &interpreter)
|
||||||
{
|
{
|
||||||
d->m_jobs.push_back(Internal::ShellCommandPrivate::Job(workDirectory(workingDirectory), binary,
|
d->m_jobs.push_back(Internal::ShellCommandPrivate::Job(workDirectory(workingDirectory), command,
|
||||||
arguments, timeoutS, interpreter));
|
timeoutS, interpreter));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShellCommand::execute()
|
void ShellCommand::execute()
|
||||||
@@ -287,7 +285,7 @@ void ShellCommand::run(QFutureInterface<void> &future)
|
|||||||
for (int j = 0; j < count; j++) {
|
for (int j = 0; j < count; j++) {
|
||||||
const Internal::ShellCommandPrivate::Job &job = d->m_jobs.at(j);
|
const Internal::ShellCommandPrivate::Job &job = d->m_jobs.at(j);
|
||||||
SynchronousProcessResponse resp
|
SynchronousProcessResponse resp
|
||||||
= runCommand(job.binary, job.arguments, job.timeoutS, job.workingDirectory,
|
= runCommand(job.command, job.timeoutS, job.workingDirectory,
|
||||||
job.exitCodeInterpreter);
|
job.exitCodeInterpreter);
|
||||||
stdOut += resp.stdOut();
|
stdOut += resp.stdOut();
|
||||||
stdErr += resp.stdErr();
|
stdErr += resp.stdErr();
|
||||||
@@ -319,8 +317,7 @@ void ShellCommand::run(QFutureInterface<void> &future)
|
|||||||
this->deleteLater();
|
this->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
SynchronousProcessResponse ShellCommand::runCommand(const FilePath &binary,
|
SynchronousProcessResponse ShellCommand::runCommand(const CommandLine &command, int timeoutS,
|
||||||
const QStringList &arguments, int timeoutS,
|
|
||||||
const QString &workingDirectory,
|
const QString &workingDirectory,
|
||||||
const ExitCodeInterpreter &interpreter)
|
const ExitCodeInterpreter &interpreter)
|
||||||
{
|
{
|
||||||
@@ -328,7 +325,7 @@ SynchronousProcessResponse ShellCommand::runCommand(const FilePath &binary,
|
|||||||
|
|
||||||
const QString dir = workDirectory(workingDirectory);
|
const QString dir = workDirectory(workingDirectory);
|
||||||
|
|
||||||
if (binary.isEmpty()) {
|
if (command.executable().isEmpty()) {
|
||||||
response.result = SynchronousProcessResponse::StartFailed;
|
response.result = SynchronousProcessResponse::StartFailed;
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
@@ -336,23 +333,23 @@ SynchronousProcessResponse ShellCommand::runCommand(const FilePath &binary,
|
|||||||
QSharedPointer<OutputProxy> proxy(d->m_proxyFactory());
|
QSharedPointer<OutputProxy> proxy(d->m_proxyFactory());
|
||||||
|
|
||||||
if (!(d->m_flags & SuppressCommandLogging))
|
if (!(d->m_flags & SuppressCommandLogging))
|
||||||
emit proxy->appendCommand(dir, binary, arguments);
|
emit proxy->appendCommand(dir, command);
|
||||||
|
|
||||||
if ((d->m_flags & FullySynchronously)
|
if ((d->m_flags & FullySynchronously)
|
||||||
|| (!(d->m_flags & NoFullySync)
|
|| (!(d->m_flags & NoFullySync)
|
||||||
&& QThread::currentThread() == QCoreApplication::instance()->thread())) {
|
&& QThread::currentThread() == QCoreApplication::instance()->thread())) {
|
||||||
response = runFullySynchronous({binary, arguments}, proxy, timeoutS, dir, interpreter);
|
response = runFullySynchronous(command, proxy, timeoutS, dir, interpreter);
|
||||||
} else {
|
} else {
|
||||||
response = runSynchronous({binary, arguments}, proxy, timeoutS, dir, interpreter);
|
response = runSynchronous(command, proxy, timeoutS, dir, interpreter);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!d->m_aborted) {
|
if (!d->m_aborted) {
|
||||||
// Success/Fail message in appropriate window?
|
// Success/Fail message in appropriate window?
|
||||||
if (response.result == SynchronousProcessResponse::Finished) {
|
if (response.result == SynchronousProcessResponse::Finished) {
|
||||||
if (d->m_flags & ShowSuccessMessage)
|
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)) {
|
} 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 {
|
namespace Utils {
|
||||||
|
|
||||||
class FilePath;
|
class CommandLine;
|
||||||
namespace Internal { class ShellCommandPrivate; }
|
namespace Internal { class ShellCommandPrivate; }
|
||||||
|
|
||||||
class QTCREATOR_UTILS_EXPORT ProgressParser
|
class QTCREATOR_UTILS_EXPORT ProgressParser
|
||||||
@@ -79,8 +79,7 @@ signals:
|
|||||||
void append(const QString &text);
|
void append(const QString &text);
|
||||||
void appendSilently(const QString &text);
|
void appendSilently(const QString &text);
|
||||||
void appendError(const QString &text);
|
void appendError(const QString &text);
|
||||||
void appendCommand(const QString &workingDirectory, const Utils::FilePath &binary,
|
void appendCommand(const QString &workingDirectory, const Utils::CommandLine &command);
|
||||||
const QStringList &args);
|
|
||||||
void appendMessage(const QString &text);
|
void appendMessage(const QString &text);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -112,10 +111,12 @@ public:
|
|||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
void setDisplayName(const QString &name);
|
void setDisplayName(const QString &name);
|
||||||
|
|
||||||
void addJob(const FilePath &binary, const QStringList &arguments,
|
void addJob(const CommandLine &command,
|
||||||
const QString &workingDirectory = QString(), const ExitCodeInterpreter &interpreter = defaultExitCodeInterpreter);
|
const QString &workingDirectory = QString(),
|
||||||
void addJob(const FilePath &binary, const QStringList &arguments, int timeoutS,
|
const ExitCodeInterpreter &interpreter = defaultExitCodeInterpreter);
|
||||||
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 execute(); // Execute tasks asynchronously!
|
||||||
void abort();
|
void abort();
|
||||||
bool lastExecutionSuccess() const;
|
bool lastExecutionSuccess() const;
|
||||||
@@ -145,7 +146,7 @@ public:
|
|||||||
// This is called once per job in a thread.
|
// This is called once per job in a thread.
|
||||||
// When called from the UI thread it will execute fully synchronously, so no signals will
|
// When called from the UI thread it will execute fully synchronously, so no signals will
|
||||||
// be triggered!
|
// be triggered!
|
||||||
virtual SynchronousProcessResponse runCommand(const FilePath &binary, const QStringList &arguments,
|
virtual SynchronousProcessResponse runCommand(const CommandLine &command,
|
||||||
int timeoutS,
|
int timeoutS,
|
||||||
const QString &workingDirectory = QString(),
|
const QString &workingDirectory = QString(),
|
||||||
const ExitCodeInterpreter &interpreter = defaultExitCodeInterpreter);
|
const ExitCodeInterpreter &interpreter = defaultExitCodeInterpreter);
|
||||||
|
@@ -150,7 +150,7 @@ Core::ShellCommand *BazaarControl::createInitialCheckoutCommand(const QString &u
|
|||||||
QProcessEnvironment env = m_bazaarClient->processEnvironment();
|
QProcessEnvironment env = m_bazaarClient->processEnvironment();
|
||||||
env.insert(QLatin1String("BZR_PROGRESS_BAR"), QLatin1String("text"));
|
env.insert(QLatin1String("BZR_PROGRESS_BAR"), QLatin1String("text"));
|
||||||
auto command = new VcsBase::VcsCommand(baseDirectory.toString(), env);
|
auto command = new VcsBase::VcsCommand(baseDirectory.toString(), env);
|
||||||
command->addJob(m_bazaarClient->vcsBinary(), args, -1);
|
command->addJob({m_bazaarClient->vcsBinary(), args}, -1);
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1452,8 +1452,9 @@ ClearCasePlugin::runCleartool(const QString &workingDir,
|
|||||||
}
|
}
|
||||||
|
|
||||||
const SynchronousProcessResponse sp_resp =
|
const SynchronousProcessResponse sp_resp =
|
||||||
VcsBasePlugin::runVcs(workingDir, FilePath::fromUserInput(executable),
|
VcsBasePlugin::runVcs(workingDir,
|
||||||
arguments, timeOutS,
|
{FilePath::fromUserInput(executable), arguments},
|
||||||
|
timeOutS,
|
||||||
flags, outputCodec);
|
flags, outputCodec);
|
||||||
|
|
||||||
response.error = sp_resp.result != SynchronousProcessResponse::Finished;
|
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(),
|
auto command = new VcsBase::VcsCommand(baseDirectory.toString(),
|
||||||
QProcessEnvironment::systemEnvironment());
|
QProcessEnvironment::systemEnvironment());
|
||||||
command->setDisplayName(tr("CVS Checkout"));
|
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;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1109,7 +1109,7 @@ CvsResponse CvsPlugin::runCvs(const QString &workingDirectory,
|
|||||||
}
|
}
|
||||||
// Run, connect stderr to the output window
|
// Run, connect stderr to the output window
|
||||||
const SynchronousProcessResponse sp_resp =
|
const SynchronousProcessResponse sp_resp =
|
||||||
runVcs(workingDirectory, executable, client()->settings().addOptions(arguments),
|
runVcs(workingDirectory, {executable, client()->settings().addOptions(arguments)},
|
||||||
timeOutS, flags, outputCodec);
|
timeOutS, flags, outputCodec);
|
||||||
|
|
||||||
response.result = CvsResponse::OtherError;
|
response.result = CvsResponse::OtherError;
|
||||||
|
@@ -315,7 +315,7 @@ void QueryContext::start()
|
|||||||
m_progress.reportStarted();
|
m_progress.reportStarted();
|
||||||
// Order: synchronous call to error handling if something goes wrong.
|
// Order: synchronous call to error handling if something goes wrong.
|
||||||
VcsOutputWindow::appendCommand(
|
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_timer.start();
|
||||||
m_process.start(m_binary, m_arguments);
|
m_process.start(m_binary, m_arguments);
|
||||||
m_process.closeWriteChannel();
|
m_process.closeWriteChannel();
|
||||||
|
@@ -170,7 +170,7 @@ void FetchContext::start()
|
|||||||
m_progress.reportStarted();
|
m_progress.reportStarted();
|
||||||
// Order: initialize future before starting the process in case error handling is invoked.
|
// Order: initialize future before starting the process in case error handling is invoked.
|
||||||
const QStringList args = m_change->gitFetchArguments(m_server);
|
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.start(m_git.toString(), args);
|
||||||
m_process.closeWriteChannel();
|
m_process.closeWriteChannel();
|
||||||
}
|
}
|
||||||
|
@@ -243,7 +243,7 @@ int GerritServer::testConnection()
|
|||||||
static GitClient *const client = GitPlugin::client();
|
static GitClient *const client = GitPlugin::client();
|
||||||
const QStringList arguments = curlArguments() << (url(RestUrl) + accountUrlC);
|
const QStringList arguments = curlArguments() << (url(RestUrl) + accountUrlC);
|
||||||
const SynchronousProcessResponse resp = client->vcsFullySynchronousExec(
|
const SynchronousProcessResponse resp = client->vcsFullySynchronousExec(
|
||||||
QString(), FilePath::fromString(curlBinary), arguments,
|
QString(), {FilePath::fromString(curlBinary), arguments},
|
||||||
Core::ShellCommand::NoOutput);
|
Core::ShellCommand::NoOutput);
|
||||||
if (resp.result == SynchronousProcessResponse::Finished) {
|
if (resp.result == SynchronousProcessResponse::Finished) {
|
||||||
QString output = resp.stdOut();
|
QString output = resp.stdOut();
|
||||||
@@ -345,7 +345,7 @@ void GerritServer::resolveVersion(const GerritParameters &p, bool forceReload)
|
|||||||
arguments << p.portFlag << QString::number(port);
|
arguments << p.portFlag << QString::number(port);
|
||||||
arguments << hostArgument() << "gerrit" << "version";
|
arguments << hostArgument() << "gerrit" << "version";
|
||||||
const SynchronousProcessResponse resp = client->vcsFullySynchronousExec(
|
const SynchronousProcessResponse resp = client->vcsFullySynchronousExec(
|
||||||
QString(), FilePath::fromString(p.ssh), arguments,
|
QString(), {FilePath::fromString(p.ssh), arguments},
|
||||||
Core::ShellCommand::NoOutput);
|
Core::ShellCommand::NoOutput);
|
||||||
QString stdOut = resp.stdOut().trimmed();
|
QString stdOut = resp.stdOut().trimmed();
|
||||||
stdOut.remove("gerrit version ");
|
stdOut.remove("gerrit version ");
|
||||||
@@ -353,7 +353,7 @@ void GerritServer::resolveVersion(const GerritParameters &p, bool forceReload)
|
|||||||
} else {
|
} else {
|
||||||
const QStringList arguments = curlArguments() << (url(RestUrl) + versionUrlC);
|
const QStringList arguments = curlArguments() << (url(RestUrl) + versionUrlC);
|
||||||
const SynchronousProcessResponse resp = client->vcsFullySynchronousExec(
|
const SynchronousProcessResponse resp = client->vcsFullySynchronousExec(
|
||||||
QString(), FilePath::fromString(curlBinary), arguments,
|
QString(), {FilePath::fromString(curlBinary), arguments},
|
||||||
Core::ShellCommand::NoOutput);
|
Core::ShellCommand::NoOutput);
|
||||||
// REST endpoint for version is only available from 2.8 and up. Do not consider invalid
|
// REST endpoint for version is only available from 2.8 and up. Do not consider invalid
|
||||||
// if it fails.
|
// if it fails.
|
||||||
|
@@ -2421,7 +2421,7 @@ bool GitClient::tryLauchingGitK(const QProcessEnvironment &env,
|
|||||||
arguments.append(QtcProcess::splitArgs(gitkOpts, HostOsInfo::hostOs()));
|
arguments.append(QtcProcess::splitArgs(gitkOpts, HostOsInfo::hostOs()));
|
||||||
if (!fileName.isEmpty())
|
if (!fileName.isEmpty())
|
||||||
arguments << "--" << fileName;
|
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
|
// This should always use QProcess::startDetached (as not to kill
|
||||||
// the child), but that does not have an environment parameter.
|
// the child), but that does not have an environment parameter.
|
||||||
bool success = false;
|
bool success = false;
|
||||||
@@ -3147,7 +3147,7 @@ VcsCommand *GitClient::vcsExecAbortable(const QString &workingDirectory,
|
|||||||
| VcsCommand::ShowSuccessMessage);
|
| VcsCommand::ShowSuccessMessage);
|
||||||
// For rebase, Git might request an editor (which means the process keeps running until the
|
// For rebase, Git might request an editor (which means the process keeps running until the
|
||||||
// user closes it), so run without timeout.
|
// 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);
|
ConflictHandler::attachToCommand(command, abortCommand);
|
||||||
if (isRebase)
|
if (isRebase)
|
||||||
GitProgressParser::attachToCommand(command);
|
GitProgressParser::attachToCommand(command);
|
||||||
|
@@ -196,7 +196,7 @@ public:
|
|||||||
connect(&watcher, &QFutureWatcher<FileSearchResultList>::canceled,
|
connect(&watcher, &QFutureWatcher<FileSearchResultList>::canceled,
|
||||||
command.data(), &VcsCommand::cancel);
|
command.data(), &VcsCommand::cancel);
|
||||||
connect(command.data(), &VcsCommand::stdOutText, this, &GitGrepRunner::read);
|
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) {
|
switch (resp.result) {
|
||||||
case SynchronousProcessResponse::TerminatedAbnormally:
|
case SynchronousProcessResponse::TerminatedAbnormally:
|
||||||
case SynchronousProcessResponse::StartFailed:
|
case SynchronousProcessResponse::StartFailed:
|
||||||
|
@@ -159,7 +159,7 @@ Core::ShellCommand *GitVersionControl::createInitialCheckoutCommand(const QStrin
|
|||||||
|
|
||||||
auto command = new VcsBase::VcsCommand(baseDirectory.toString(), m_client->processEnvironment());
|
auto command = new VcsBase::VcsCommand(baseDirectory.toString(), m_client->processEnvironment());
|
||||||
command->addFlags(VcsBase::VcsCommand::SuppressStdErr);
|
command->addFlags(VcsBase::VcsCommand::SuppressStdErr);
|
||||||
command->addJob(m_client->vcsBinary(), args, -1);
|
command->addJob({m_client->vcsBinary(), args}, -1);
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -62,7 +62,7 @@ bool MergeTool::start(const QString &workingDirectory, const QStringList &files)
|
|||||||
m_process->setProcessEnvironment(env);
|
m_process->setProcessEnvironment(env);
|
||||||
m_process->setProcessChannelMode(QProcess::MergedChannels);
|
m_process->setProcessChannelMode(QProcess::MergedChannels);
|
||||||
const Utils::FilePath binary = GitPlugin::client()->vcsBinary();
|
const Utils::FilePath binary = GitPlugin::client()->vcsBinary();
|
||||||
VcsOutputWindow::appendCommand(workingDirectory, binary, arguments);
|
VcsOutputWindow::appendCommand(workingDirectory, {binary, arguments});
|
||||||
m_process->start(binary.toString(), arguments);
|
m_process->start(binary.toString(), arguments);
|
||||||
if (m_process->waitForStarted()) {
|
if (m_process->waitForStarted()) {
|
||||||
connect(m_process, QOverload<int, QProcess::ExitStatus>::of(&QProcess::finished),
|
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();
|
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
||||||
env.insert(QLatin1String("LANGUAGE"), QLatin1String("C"));
|
env.insert(QLatin1String("LANGUAGE"), QLatin1String("C"));
|
||||||
const SynchronousProcessResponse resp = VcsBasePlugin::runVcs(
|
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;
|
const bool ok = resp.result == SynchronousProcessResponse::Finished;
|
||||||
|
|
||||||
parsePullOutput(resp.stdOut().trimmed());
|
parsePullOutput(resp.stdOut().trimmed());
|
||||||
|
@@ -172,7 +172,7 @@ Core::ShellCommand *MercurialControl::createInitialCheckoutCommand(const QString
|
|||||||
args << QLatin1String("clone") << extraArgs << url << localName;
|
args << QLatin1String("clone") << extraArgs << url << localName;
|
||||||
auto command = new VcsBase::VcsCommand(baseDirectory.toString(),
|
auto command = new VcsBase::VcsCommand(baseDirectory.toString(),
|
||||||
mercurialClient->processEnvironment());
|
mercurialClient->processEnvironment());
|
||||||
command->addJob(mercurialClient->vcsBinary(), args, -1);
|
command->addJob({mercurialClient->vcsBinary(), args}, -1);
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1119,7 +1119,7 @@ PerforceResponse PerforcePlugin::runP4Cmd(const QString &workingDir,
|
|||||||
actualArgs.append(args);
|
actualArgs.append(args);
|
||||||
|
|
||||||
if (flags & CommandToWindow)
|
if (flags & CommandToWindow)
|
||||||
VcsOutputWindow::appendCommand(workingDir, FilePath::fromString(settings().p4BinaryPath()), actualArgs);
|
VcsOutputWindow::appendCommand(workingDir, {FilePath::fromString(settings().p4BinaryPath()), actualArgs});
|
||||||
|
|
||||||
if (flags & ShowBusyCursor)
|
if (flags & ShowBusyCursor)
|
||||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||||
|
@@ -150,7 +150,7 @@ QString SubversionClient::synchronousTopic(const QString &repository)
|
|||||||
svnVersionBinary = svnVersionBinary.left(pos + 1);
|
svnVersionBinary = svnVersionBinary.left(pos + 1);
|
||||||
svnVersionBinary.append(HostOsInfo::withExecutableSuffix("svnversion"));
|
svnVersionBinary.append(HostOsInfo::withExecutableSuffix("svnversion"));
|
||||||
const SynchronousProcessResponse result
|
const SynchronousProcessResponse result
|
||||||
= vcsFullySynchronousExec(repository, FilePath::fromString(svnVersionBinary), args);
|
= vcsFullySynchronousExec(repository, {FilePath::fromString(svnVersionBinary), args});
|
||||||
if (result.result != SynchronousProcessResponse::Finished)
|
if (result.result != SynchronousProcessResponse::Finished)
|
||||||
return QString();
|
return QString();
|
||||||
|
|
||||||
|
@@ -171,7 +171,7 @@ Core::ShellCommand *SubversionControl::createInitialCheckoutCommand(const QStrin
|
|||||||
args << extraArgs << url << localName;
|
args << extraArgs << url << localName;
|
||||||
|
|
||||||
auto command = new VcsBase::VcsCommand(baseDirectory.toString(), client->processEnvironment());
|
auto command = new VcsBase::VcsCommand(baseDirectory.toString(), client->processEnvironment());
|
||||||
command->addJob(client->vcsBinary(), args, -1);
|
command->addJob({client->vcsBinary(), args}, -1);
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -128,7 +128,7 @@ void UpdateInfoPlugin::startCheckForUpdates()
|
|||||||
d->m_checkUpdatesCommand->setDisplayName(tr("Checking for Updates"));
|
d->m_checkUpdatesCommand->setDisplayName(tr("Checking for Updates"));
|
||||||
connect(d->m_checkUpdatesCommand, &ShellCommand::stdOutText, this, &UpdateInfoPlugin::collectCheckForUpdatesOutput);
|
connect(d->m_checkUpdatesCommand, &ShellCommand::stdOutText, this, &UpdateInfoPlugin::collectCheckForUpdatesOutput);
|
||||||
connect(d->m_checkUpdatesCommand, &ShellCommand::finished, this, &UpdateInfoPlugin::checkForUpdatesFinished);
|
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
|
60 * 3, // 3 minutes timeout
|
||||||
/*workingDirectory=*/QString(),
|
/*workingDirectory=*/QString(),
|
||||||
[](int /*exitCode*/) { return Utils::SynchronousProcessResponse::Finished; });
|
[](int /*exitCode*/) { return Utils::SynchronousProcessResponse::Finished; });
|
||||||
|
@@ -138,7 +138,7 @@ void VcsBaseClientImpl::enqueueJob(VcsCommand *cmd, const QStringList &args,
|
|||||||
const QString &workingDirectory,
|
const QString &workingDirectory,
|
||||||
const ExitCodeInterpreter &interpreter) const
|
const ExitCodeInterpreter &interpreter) const
|
||||||
{
|
{
|
||||||
cmd->addJob(vcsBinary(), args, vcsTimeoutS(), workingDirectory, interpreter);
|
cmd->addJob({vcsBinary(), args}, vcsTimeoutS(), workingDirectory, interpreter);
|
||||||
cmd->execute();
|
cmd->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,15 +178,14 @@ QString VcsBaseClientImpl::stripLastNewline(const QString &in)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SynchronousProcessResponse
|
SynchronousProcessResponse
|
||||||
VcsBaseClientImpl::vcsFullySynchronousExec(const QString &workingDir, const FilePath &binary,
|
VcsBaseClientImpl::vcsFullySynchronousExec(const QString &workingDir, const CommandLine &cmdLine,
|
||||||
const QStringList &args, unsigned flags,
|
unsigned flags, int timeoutS, QTextCodec *codec) const
|
||||||
int timeoutS, QTextCodec *codec) const
|
|
||||||
{
|
{
|
||||||
VcsCommand command(workingDir, processEnvironment());
|
VcsCommand command(workingDir, processEnvironment());
|
||||||
command.addFlags(flags);
|
command.addFlags(flags);
|
||||||
if (codec)
|
if (codec)
|
||||||
command.setCodec(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)
|
void VcsBaseClientImpl::resetCachedVcsInfo(const QString &workingDir)
|
||||||
@@ -211,7 +210,7 @@ SynchronousProcessResponse
|
|||||||
VcsBaseClientImpl::vcsFullySynchronousExec(const QString &workingDir, const QStringList &args,
|
VcsBaseClientImpl::vcsFullySynchronousExec(const QString &workingDir, const QStringList &args,
|
||||||
unsigned flags, int timeoutS, QTextCodec *codec) const
|
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,
|
VcsCommand *VcsBaseClientImpl::vcsExec(const QString &workingDirectory, const QStringList &arguments,
|
||||||
@@ -233,7 +232,7 @@ SynchronousProcessResponse VcsBaseClientImpl::vcsSynchronousExec(const QString &
|
|||||||
unsigned flags,
|
unsigned flags,
|
||||||
QTextCodec *outputCodec) const
|
QTextCodec *outputCodec) const
|
||||||
{
|
{
|
||||||
return VcsBasePlugin::runVcs(workingDir, vcsBinary(), args, vcsTimeoutS(), flags,
|
return VcsBasePlugin::runVcs(workingDir, {vcsBinary(), args}, vcsTimeoutS(), flags,
|
||||||
outputCodec, processEnvironment());
|
outputCodec, processEnvironment());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -105,7 +105,7 @@ public:
|
|||||||
vcsFullySynchronousExec(const QString &workingDir, const QStringList &args,
|
vcsFullySynchronousExec(const QString &workingDir, const QStringList &args,
|
||||||
unsigned flags = 0, int timeoutS = -1, QTextCodec *codec = nullptr) const;
|
unsigned flags = 0, int timeoutS = -1, QTextCodec *codec = nullptr) const;
|
||||||
Utils::SynchronousProcessResponse
|
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;
|
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) {
|
for (const QStringList &arg : args) {
|
||||||
QTC_ASSERT(!arg.isEmpty(), continue);
|
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();
|
d->m_command->execute();
|
||||||
|
@@ -791,8 +791,7 @@ void VcsBasePlugin::setProcessEnvironment(QProcessEnvironment *e,
|
|||||||
// Run a process synchronously, returning Utils::SynchronousProcessResponse
|
// Run a process synchronously, returning Utils::SynchronousProcessResponse
|
||||||
// response struct and using the VcsBasePlugin flags as applicable
|
// response struct and using the VcsBasePlugin flags as applicable
|
||||||
SynchronousProcessResponse VcsBasePlugin::runVcs(const QString &workingDir,
|
SynchronousProcessResponse VcsBasePlugin::runVcs(const QString &workingDir,
|
||||||
const FilePath &binary,
|
const CommandLine &cmd,
|
||||||
const QStringList &arguments,
|
|
||||||
int timeOutS,
|
int timeOutS,
|
||||||
unsigned flags,
|
unsigned flags,
|
||||||
QTextCodec *outputCodec,
|
QTextCodec *outputCodec,
|
||||||
@@ -801,7 +800,7 @@ SynchronousProcessResponse VcsBasePlugin::runVcs(const QString &workingDir,
|
|||||||
VcsCommand command(workingDir, env.isEmpty() ? QProcessEnvironment::systemEnvironment() : env);
|
VcsCommand command(workingDir, env.isEmpty() ? QProcessEnvironment::systemEnvironment() : env);
|
||||||
command.addFlags(flags);
|
command.addFlags(flags);
|
||||||
command.setCodec(outputCodec);
|
command.setCodec(outputCodec);
|
||||||
return command.runCommand(binary, arguments, timeOutS);
|
return command.runCommand(cmd, timeOutS);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace VcsBase
|
} // namespace VcsBase
|
||||||
|
@@ -41,7 +41,7 @@ class QTextCodec;
|
|||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Utils {
|
namespace Utils {
|
||||||
class FilePath;
|
class CommandLine;
|
||||||
class SynchronousProcessResponse;
|
class SynchronousProcessResponse;
|
||||||
} // namespace Utils
|
} // namespace Utils
|
||||||
|
|
||||||
@@ -170,8 +170,7 @@ public:
|
|||||||
static QString source(Core::IDocument *document);
|
static QString source(Core::IDocument *document);
|
||||||
|
|
||||||
static Utils::SynchronousProcessResponse runVcs(const QString &workingDir,
|
static Utils::SynchronousProcessResponse runVcs(const QString &workingDir,
|
||||||
const Utils::FilePath &binary,
|
const Utils::CommandLine &cmd,
|
||||||
const QStringList &arguments,
|
|
||||||
int timeOutS,
|
int timeOutS,
|
||||||
unsigned flags = 0,
|
unsigned flags = 0,
|
||||||
QTextCodec *outputCodec = nullptr,
|
QTextCodec *outputCodec = nullptr,
|
||||||
|
@@ -77,14 +77,12 @@ const QProcessEnvironment VcsCommand::processEnvironment() const
|
|||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
|
|
||||||
SynchronousProcessResponse VcsCommand::runCommand(const FilePath &binary,
|
SynchronousProcessResponse VcsCommand::runCommand(const CommandLine &command, int timeoutS,
|
||||||
const QStringList &arguments, int timeoutS,
|
const QString &workingDirectory,
|
||||||
const QString &workingDirectory,
|
const ExitCodeInterpreter &interpreter)
|
||||||
const ExitCodeInterpreter &interpreter)
|
|
||||||
{
|
{
|
||||||
SynchronousProcessResponse response
|
SynchronousProcessResponse response
|
||||||
= Core::ShellCommand::runCommand(binary, arguments, timeoutS, workingDirectory,
|
= Core::ShellCommand::runCommand(command, timeoutS, workingDirectory, interpreter);
|
||||||
interpreter);
|
|
||||||
emitRepositoryChanged(workingDirectory);
|
emitRepositoryChanged(workingDirectory);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
@@ -45,8 +45,8 @@ public:
|
|||||||
|
|
||||||
const QProcessEnvironment processEnvironment() const override;
|
const QProcessEnvironment processEnvironment() const override;
|
||||||
|
|
||||||
Utils::SynchronousProcessResponse runCommand(const Utils::FilePath &binary,
|
Utils::SynchronousProcessResponse runCommand(const Utils::CommandLine &command,
|
||||||
const QStringList &arguments, int timeoutS,
|
int timeoutS,
|
||||||
const QString &workDirectory = QString(),
|
const QString &workDirectory = QString(),
|
||||||
const Utils::ExitCodeInterpreter &interpreter = Utils::defaultExitCodeInterpreter) override;
|
const Utils::ExitCodeInterpreter &interpreter = Utils::defaultExitCodeInterpreter) override;
|
||||||
|
|
||||||
|
@@ -456,12 +456,10 @@ static inline QString formatArguments(const QStringList &args)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VcsOutputWindow::msgExecutionLogEntry(const QString &workingDir,
|
QString VcsOutputWindow::msgExecutionLogEntry(const QString &workingDir, const CommandLine &command)
|
||||||
const FilePath &executable,
|
|
||||||
const QStringList &arguments)
|
|
||||||
{
|
{
|
||||||
const QString args = formatArguments(arguments);
|
const QString args = formatArguments(command.splitArguments());
|
||||||
const QString nativeExecutable = QtcProcess::quoteArg(executable.toUserOutput());
|
const QString nativeExecutable = QtcProcess::quoteArg(command.executable().toUserOutput());
|
||||||
if (workingDir.isEmpty())
|
if (workingDir.isEmpty())
|
||||||
return tr("Running: %1 %2").arg(nativeExecutable, args) + '\n';
|
return tr("Running: %1 %2").arg(nativeExecutable, args) + '\n';
|
||||||
return tr("Running in %1: %2 %3").
|
return tr("Running in %1: %2 %3").
|
||||||
@@ -473,11 +471,9 @@ void VcsOutputWindow::appendShellCommandLine(const QString &text)
|
|||||||
append(filterPasswordFromUrls(text), Command, true);
|
append(filterPasswordFromUrls(text), Command, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VcsOutputWindow::appendCommand(const QString &workingDirectory,
|
void VcsOutputWindow::appendCommand(const QString &workingDirectory, const CommandLine &command)
|
||||||
const FilePath &binary,
|
|
||||||
const QStringList &args)
|
|
||||||
{
|
{
|
||||||
appendShellCommandLine(msgExecutionLogEntry(workingDirectory, binary, args));
|
appendShellCommandLine(msgExecutionLogEntry(workingDirectory, command));
|
||||||
}
|
}
|
||||||
|
|
||||||
void VcsOutputWindow::appendMessage(const QString &text)
|
void VcsOutputWindow::appendMessage(const QString &text)
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
#include <coreplugin/ioutputpane.h>
|
#include <coreplugin/ioutputpane.h>
|
||||||
|
|
||||||
namespace Utils { class FilePath; }
|
namespace Utils { class CommandLine; }
|
||||||
namespace VcsBase {
|
namespace VcsBase {
|
||||||
|
|
||||||
namespace Internal { class VcsPlugin; }
|
namespace Internal { class VcsPlugin; }
|
||||||
@@ -66,8 +66,7 @@ public:
|
|||||||
// 'Executing <dir>: <cmd> <args>'. Hides well-known password option
|
// 'Executing <dir>: <cmd> <args>'. Hides well-known password option
|
||||||
// arguments.
|
// arguments.
|
||||||
static QString msgExecutionLogEntry(const QString &workingDir,
|
static QString msgExecutionLogEntry(const QString &workingDir,
|
||||||
const Utils::FilePath &executable,
|
const Utils::CommandLine &command);
|
||||||
const QStringList &arguments);
|
|
||||||
|
|
||||||
enum MessageStyle {
|
enum MessageStyle {
|
||||||
None,
|
None,
|
||||||
@@ -107,8 +106,7 @@ public slots:
|
|||||||
// Append a standard-formatted entry for command execution
|
// Append a standard-formatted entry for command execution
|
||||||
// (see msgExecutionLogEntry).
|
// (see msgExecutionLogEntry).
|
||||||
static void appendCommand(const QString &workingDirectory,
|
static void appendCommand(const QString &workingDirectory,
|
||||||
const Utils::FilePath &binary,
|
const Utils::CommandLine &command);
|
||||||
const QStringList &args);
|
|
||||||
|
|
||||||
// Append a blue message text and pop up.
|
// Append a blue message text and pop up.
|
||||||
static void appendMessage(const QString &text);
|
static void appendMessage(const QString &text);
|
||||||
|
@@ -310,7 +310,7 @@ void VcsCommandPage::delayedInitialize()
|
|||||||
|
|
||||||
const QString dir = wiz->expander()->expand(job.workDirectory);
|
const QString dir = wiz->expander()->expand(job.workDirectory);
|
||||||
const int timeoutS = command->defaultTimeoutS() * job.timeOutFactor;
|
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);
|
start(command);
|
||||||
|
Reference in New Issue
Block a user