forked from qt-creator/qt-creator
Vcs: Push the binary into the Jobs of VcsCommand
This is the first step to generalizing the class for wider use. Change-Id: I40ccb5bec4fdcb9d0a67388160c867799331007b Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -105,9 +105,8 @@ VcsCommand *CloneWizard::createCommand(Utils::FileName *checkoutDir)
|
|||||||
args << client->vcsCommandString(BazaarClient::CloneCommand)
|
args << client->vcsCommandString(BazaarClient::CloneCommand)
|
||||||
<< extraOptions << cwp->repository() << cwp->directory();
|
<< extraOptions << cwp->repository() << cwp->directory();
|
||||||
|
|
||||||
auto command = new VcsCommand(settings.binaryPath(), cwp->path(),
|
auto command = new VcsCommand(cwp->path(), client->processEnvironment());
|
||||||
client->processEnvironment());
|
command->addJob(settings.binaryPath(), args, -1);
|
||||||
command->addJob(args, -1);
|
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -82,9 +82,8 @@ VcsCommand *CheckoutWizard::createCommand(Utils::FileName *checkoutDir)
|
|||||||
const QString workingDirectory = cwp->path();
|
const QString workingDirectory = cwp->path();
|
||||||
*checkoutDir = Utils::FileName::fromString(workingDirectory + QLatin1Char('/') + repository);
|
*checkoutDir = Utils::FileName::fromString(workingDirectory + QLatin1Char('/') + repository);
|
||||||
|
|
||||||
auto command = new VcsCommand(binary, workingDirectory,
|
auto command = new VcsCommand(workingDirectory, QProcessEnvironment::systemEnvironment());
|
||||||
QProcessEnvironment::systemEnvironment());
|
command->addJob(binary, settings.addOptions(args), -1);
|
||||||
command->addJob(settings.addOptions(args), -1);
|
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -123,10 +123,9 @@ VcsCommand *CloneWizardPage::createCheckoutJob(Utils::FileName *checkoutPath) co
|
|||||||
if (d->recursiveCheckBox->isChecked())
|
if (d->recursiveCheckBox->isChecked())
|
||||||
args << QLatin1String("--recursive");
|
args << QLatin1String("--recursive");
|
||||||
args << QLatin1String("--progress") << repository() << checkoutDir;
|
args << QLatin1String("--progress") << repository() << checkoutDir;
|
||||||
auto command = new VcsCommand(client->vcsBinary(), workingDirectory,
|
auto command = new VcsCommand(workingDirectory, client->processEnvironment());
|
||||||
client->processEnvironment());
|
|
||||||
command->addFlags(VcsBasePlugin::MergeOutputChannels);
|
command->addFlags(VcsBasePlugin::MergeOutputChannels);
|
||||||
command->addJob(args, -1);
|
command->addJob(client->vcsBinary(), args, -1);
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -150,7 +150,7 @@ void BaseController::runCommand(const QList<QStringList> &args, QTextCodec *code
|
|||||||
m_command->cancel();
|
m_command->cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_command = new VcsCommand(gitClient()->vcsBinary(), m_directory, gitClient()->processEnvironment());
|
m_command = new VcsCommand(m_directory, gitClient()->processEnvironment());
|
||||||
m_command->setCodec(codec ? codec : EditorManager::defaultTextCodec());
|
m_command->setCodec(codec ? codec : EditorManager::defaultTextCodec());
|
||||||
connect(m_command, &VcsCommand::output, this, &BaseController::processOutput);
|
connect(m_command, &VcsCommand::output, this, &BaseController::processOutput);
|
||||||
connect(m_command, &VcsCommand::finished, this, &BaseController::reloadFinished);
|
connect(m_command, &VcsCommand::finished, this, &BaseController::reloadFinished);
|
||||||
@@ -159,7 +159,7 @@ void BaseController::runCommand(const QList<QStringList> &args, QTextCodec *code
|
|||||||
foreach (const QStringList &arg, args) {
|
foreach (const QStringList &arg, args) {
|
||||||
QTC_ASSERT(!arg.isEmpty(), continue);
|
QTC_ASSERT(!arg.isEmpty(), continue);
|
||||||
|
|
||||||
m_command->addJob(arg, gitClient()->vcsTimeoutS());
|
m_command->addJob(gitClient()->vcsBinary(), arg, gitClient()->vcsTimeoutS());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_command->execute();
|
m_command->execute();
|
||||||
|
@@ -83,9 +83,8 @@ VcsCommand *CloneWizard::createCommand(Utils::FileName *checkoutDir)
|
|||||||
QStringList args;
|
QStringList args;
|
||||||
args << QLatin1String("clone") << cwp->repository() << directory;
|
args << QLatin1String("clone") << cwp->repository() << directory;
|
||||||
*checkoutDir = Utils::FileName::fromString(path + QLatin1Char('/') + directory);
|
*checkoutDir = Utils::FileName::fromString(path + QLatin1Char('/') + directory);
|
||||||
auto command = new VcsCommand(settings.binaryPath(), path,
|
auto command = new VcsCommand(path, QProcessEnvironment::systemEnvironment());
|
||||||
QProcessEnvironment::systemEnvironment());
|
command->addJob(settings.binaryPath(), args, -1);
|
||||||
command->addJob(args, -1);
|
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -88,9 +88,8 @@ VcsCommand *CheckoutWizard::createCommand(FileName *checkoutDir)
|
|||||||
const QString workingDirectory = cwp->path();
|
const QString workingDirectory = cwp->path();
|
||||||
*checkoutDir = FileName::fromString(workingDirectory + QLatin1Char('/') + directory);
|
*checkoutDir = FileName::fromString(workingDirectory + QLatin1Char('/') + directory);
|
||||||
|
|
||||||
auto command = new VcsCommand(binary, workingDirectory,
|
auto command = new VcsCommand(workingDirectory, QProcessEnvironment::systemEnvironment());
|
||||||
QProcessEnvironment::systemEnvironment());
|
command->addJob(binary, args, -1);
|
||||||
command->addJob(args, -1);
|
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -90,7 +90,7 @@ VcsCommand *SubversionClient::createCommitCmd(const QString &repositoryRoot,
|
|||||||
VcsCommand *cmd = createCommand(repositoryRoot);
|
VcsCommand *cmd = createCommand(repositoryRoot);
|
||||||
cmd->addFlags(VcsBasePlugin::ShowStdOutInLogWindow);
|
cmd->addFlags(VcsBasePlugin::ShowStdOutInLogWindow);
|
||||||
QStringList args(vcsCommandString(CommitCommand));
|
QStringList args(vcsCommandString(CommitCommand));
|
||||||
cmd->addJob(args << svnExtraOptions << files);
|
cmd->addJob(vcsBinary(), args << svnExtraOptions << files);
|
||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -232,7 +232,7 @@ QString DiffController::getDescription() const
|
|||||||
|
|
||||||
void DiffController::postCollectTextualDiffOutput()
|
void DiffController::postCollectTextualDiffOutput()
|
||||||
{
|
{
|
||||||
auto command = new VcsCommand(m_client->vcsBinary(), m_workingDirectory, processEnvironment());
|
auto command = new VcsCommand(m_workingDirectory, processEnvironment());
|
||||||
command->setCodec(EditorManager::defaultTextCodec());
|
command->setCodec(EditorManager::defaultTextCodec());
|
||||||
connect(command, SIGNAL(output(QString)),
|
connect(command, SIGNAL(output(QString)),
|
||||||
this, SLOT(slotTextualDiffOutputReceived(QString)));
|
this, SLOT(slotTextualDiffOutputReceived(QString)));
|
||||||
@@ -251,7 +251,7 @@ void DiffController::postCollectTextualDiffOutput()
|
|||||||
args << m_filesList;
|
args << m_filesList;
|
||||||
}
|
}
|
||||||
|
|
||||||
command->addJob(args, m_client->vcsTimeoutS());
|
command->addJob(m_client->vcsBinary(), args, m_client->vcsTimeoutS());
|
||||||
command->execute();
|
command->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -139,7 +139,7 @@ VcsCommand *VcsBaseClientImpl::createCommand(const QString &workingDirectory,
|
|||||||
VcsBaseEditorWidget *editor,
|
VcsBaseEditorWidget *editor,
|
||||||
JobOutputBindMode mode) const
|
JobOutputBindMode mode) const
|
||||||
{
|
{
|
||||||
auto cmd = new VcsCommand(vcsBinary(), workingDirectory, processEnvironment());
|
auto cmd = new VcsCommand(workingDirectory, processEnvironment());
|
||||||
cmd->setDefaultTimeoutS(vcsTimeoutS());
|
cmd->setDefaultTimeoutS(vcsTimeoutS());
|
||||||
if (editor)
|
if (editor)
|
||||||
d->bindCommandToEditor(cmd, editor);
|
d->bindCommandToEditor(cmd, editor);
|
||||||
@@ -157,7 +157,7 @@ VcsCommand *VcsBaseClientImpl::createCommand(const QString &workingDirectory,
|
|||||||
void VcsBaseClientImpl::enqueueJob(VcsCommand *cmd, const QStringList &args,
|
void VcsBaseClientImpl::enqueueJob(VcsCommand *cmd, const QStringList &args,
|
||||||
Utils::ExitCodeInterpreter *interpreter)
|
Utils::ExitCodeInterpreter *interpreter)
|
||||||
{
|
{
|
||||||
cmd->addJob(args, vcsTimeoutS(), interpreter);
|
cmd->addJob(vcsBinary(), args, vcsTimeoutS(), interpreter);
|
||||||
cmd->execute();
|
cmd->execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,7 +209,7 @@ bool VcsBaseClientImpl::vcsFullySynchronousExec(const QString &workingDir, const
|
|||||||
QByteArray internalErrorData;
|
QByteArray internalErrorData;
|
||||||
QScopedPointer<VcsCommand> command(createCommand(workingDir));
|
QScopedPointer<VcsCommand> command(createCommand(workingDir));
|
||||||
command->addFlags(flags);
|
command->addFlags(flags);
|
||||||
bool result = command->runFullySynchronous(args, vcsTimeoutS(), outputData,
|
bool result = command->runFullySynchronous(vcsBinary(), args, vcsTimeoutS(), outputData,
|
||||||
errorData ? errorData : &internalErrorData);
|
errorData ? errorData : &internalErrorData);
|
||||||
if (!internalErrorData.isEmpty() && !(flags & VcsBasePlugin::SuppressStdErrInLogWindow))
|
if (!internalErrorData.isEmpty() && !(flags & VcsBasePlugin::SuppressStdErrInLogWindow))
|
||||||
VcsOutputWindow::appendError(commandOutputFromLocal8Bit(internalErrorData));
|
VcsOutputWindow::appendError(commandOutputFromLocal8Bit(internalErrorData));
|
||||||
|
@@ -809,11 +809,10 @@ SynchronousProcessResponse VcsBasePlugin::runVcs(const QString &workingDir,
|
|||||||
QTextCodec *outputCodec,
|
QTextCodec *outputCodec,
|
||||||
const QProcessEnvironment &env)
|
const QProcessEnvironment &env)
|
||||||
{
|
{
|
||||||
VcsCommand command(binary, workingDir,
|
VcsCommand command(workingDir, env.isEmpty() ? QProcessEnvironment::systemEnvironment() : env);
|
||||||
env.isEmpty() ? QProcessEnvironment::systemEnvironment() : env);
|
|
||||||
command.addFlags(flags);
|
command.addFlags(flags);
|
||||||
command.setCodec(outputCodec);
|
command.setCodec(outputCodec);
|
||||||
return command.runVcs(arguments, timeOutS);
|
return command.runVcs(binary, arguments, timeOutS);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace VcsBase
|
} // namespace VcsBase
|
||||||
|
@@ -79,19 +79,18 @@ class VcsCommandPrivate
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
struct Job {
|
struct Job {
|
||||||
explicit Job(const QStringList &a, int t, Utils::ExitCodeInterpreter *interpreter = 0);
|
explicit Job(const Utils::FileName &b, const QStringList &a, int t,
|
||||||
|
Utils::ExitCodeInterpreter *interpreter = 0);
|
||||||
|
|
||||||
|
Utils::FileName binary;
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
int timeoutS;
|
int timeoutS;
|
||||||
Utils::ExitCodeInterpreter *exitCodeInterpreter;
|
Utils::ExitCodeInterpreter *exitCodeInterpreter;
|
||||||
};
|
};
|
||||||
|
|
||||||
VcsCommandPrivate(const Utils::FileName &binary,
|
VcsCommandPrivate(const QString &workingDirectory, const QProcessEnvironment &environment);
|
||||||
const QString &workingDirectory,
|
|
||||||
const QProcessEnvironment &environment);
|
|
||||||
~VcsCommandPrivate();
|
~VcsCommandPrivate();
|
||||||
|
|
||||||
const Utils::FileName m_binaryPath;
|
|
||||||
const QString m_workingDirectory;
|
const QString m_workingDirectory;
|
||||||
const QProcessEnvironment m_environment;
|
const QProcessEnvironment m_environment;
|
||||||
QVariant m_cookie;
|
QVariant m_cookie;
|
||||||
@@ -112,10 +111,8 @@ public:
|
|||||||
int m_lastExecExitCode;
|
int m_lastExecExitCode;
|
||||||
};
|
};
|
||||||
|
|
||||||
VcsCommandPrivate::VcsCommandPrivate(const Utils::FileName &binary,
|
VcsCommandPrivate::VcsCommandPrivate(const QString &workingDirectory,
|
||||||
const QString &workingDirectory,
|
|
||||||
const QProcessEnvironment &environment) :
|
const QProcessEnvironment &environment) :
|
||||||
m_binaryPath(binary),
|
|
||||||
m_workingDirectory(workingDirectory),
|
m_workingDirectory(workingDirectory),
|
||||||
m_environment(environment),
|
m_environment(environment),
|
||||||
m_defaultTimeoutS(10),
|
m_defaultTimeoutS(10),
|
||||||
@@ -137,7 +134,9 @@ VcsCommandPrivate::~VcsCommandPrivate()
|
|||||||
delete m_progressParser;
|
delete m_progressParser;
|
||||||
}
|
}
|
||||||
|
|
||||||
VcsCommandPrivate::Job::Job(const QStringList &a, int t, Utils::ExitCodeInterpreter *interpreter) :
|
VcsCommandPrivate::Job::Job(const Utils::FileName &b, const QStringList &a,
|
||||||
|
int t, Utils::ExitCodeInterpreter *interpreter) :
|
||||||
|
binary(b),
|
||||||
arguments(a),
|
arguments(a),
|
||||||
timeoutS(t),
|
timeoutS(t),
|
||||||
exitCodeInterpreter(interpreter)
|
exitCodeInterpreter(interpreter)
|
||||||
@@ -149,10 +148,9 @@ VcsCommandPrivate::Job::Job(const QStringList &a, int t, Utils::ExitCodeInterpre
|
|||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|
||||||
VcsCommand::VcsCommand(const Utils::FileName &binary,
|
VcsCommand::VcsCommand(const QString &workingDirectory,
|
||||||
const QString &workingDirectory,
|
|
||||||
const QProcessEnvironment &environment) :
|
const QProcessEnvironment &environment) :
|
||||||
d(new Internal::VcsCommandPrivate(binary, workingDirectory, environment))
|
d(new Internal::VcsCommandPrivate(workingDirectory, environment))
|
||||||
{
|
{
|
||||||
connect(Core::ICore::instance(), &Core::ICore::coreAboutToClose,
|
connect(Core::ICore::instance(), &Core::ICore::coreAboutToClose,
|
||||||
this, &VcsCommand::coreAboutToClose);
|
this, &VcsCommand::coreAboutToClose);
|
||||||
@@ -163,11 +161,6 @@ VcsCommand::~VcsCommand()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Utils::FileName &VcsCommand::binaryPath() const
|
|
||||||
{
|
|
||||||
return d->m_binaryPath;
|
|
||||||
}
|
|
||||||
|
|
||||||
const QString &VcsCommand::workingDirectory() const
|
const QString &VcsCommand::workingDirectory() const
|
||||||
{
|
{
|
||||||
return d->m_workingDirectory;
|
return d->m_workingDirectory;
|
||||||
@@ -198,15 +191,16 @@ void VcsCommand::addFlags(unsigned f)
|
|||||||
d->m_flags |= f;
|
d->m_flags |= f;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VcsCommand::addJob(const QStringList &arguments, Utils::ExitCodeInterpreter *interpreter)
|
void VcsCommand::addJob(const Utils::FileName &binary, const QStringList &arguments,
|
||||||
{
|
|
||||||
addJob(arguments, defaultTimeoutS(), interpreter);
|
|
||||||
}
|
|
||||||
|
|
||||||
void VcsCommand::addJob(const QStringList &arguments, int timeoutS,
|
|
||||||
Utils::ExitCodeInterpreter *interpreter)
|
Utils::ExitCodeInterpreter *interpreter)
|
||||||
{
|
{
|
||||||
d->m_jobs.push_back(Internal::VcsCommandPrivate::Job(arguments, timeoutS, interpreter));
|
addJob(binary, arguments, defaultTimeoutS(), interpreter);
|
||||||
|
}
|
||||||
|
|
||||||
|
void VcsCommand::addJob(const Utils::FileName &binary, const QStringList &arguments, int timeoutS,
|
||||||
|
Utils::ExitCodeInterpreter *interpreter)
|
||||||
|
{
|
||||||
|
d->m_jobs.push_back(Internal::VcsCommandPrivate::Job(binary, arguments, timeoutS, interpreter));
|
||||||
}
|
}
|
||||||
|
|
||||||
void VcsCommand::execute()
|
void VcsCommand::execute()
|
||||||
@@ -221,7 +215,7 @@ void VcsCommand::execute()
|
|||||||
QFuture<void> task = QtConcurrent::run(&VcsCommand::run, this);
|
QFuture<void> task = QtConcurrent::run(&VcsCommand::run, this);
|
||||||
d->m_watcher.setFuture(task);
|
d->m_watcher.setFuture(task);
|
||||||
connect(&d->m_watcher, &QFutureWatcher<void>::canceled, this, &VcsCommand::cancel);
|
connect(&d->m_watcher, &QFutureWatcher<void>::canceled, this, &VcsCommand::cancel);
|
||||||
QString binary = d->m_binaryPath.toFileInfo().baseName();
|
QString binary = d->m_jobs.at(0).binary.toFileInfo().baseName();
|
||||||
if (!binary.isEmpty())
|
if (!binary.isEmpty())
|
||||||
binary = binary.replace(0, 1, binary[0].toUpper()); // Upper the first letter
|
binary = binary.replace(0, 1, binary[0].toUpper()); // Upper the first letter
|
||||||
const QString taskName = binary + QLatin1Char(' ') + d->m_jobs.front().arguments.at(0);
|
const QString taskName = binary + QLatin1Char(' ') + d->m_jobs.front().arguments.at(0);
|
||||||
@@ -254,10 +248,7 @@ int VcsCommand::lastExecutionExitCode() const
|
|||||||
void VcsCommand::run(QFutureInterface<void> &future)
|
void VcsCommand::run(QFutureInterface<void> &future)
|
||||||
{
|
{
|
||||||
// Check that the binary path is not empty
|
// Check that the binary path is not empty
|
||||||
if (binaryPath().isEmpty()) {
|
QTC_ASSERT(!d->m_jobs.isEmpty(), return);
|
||||||
emit errorText(tr("Unable to start process, binary is empty"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QString stdOut;
|
QString stdOut;
|
||||||
QString stdErr;
|
QString stdErr;
|
||||||
@@ -272,7 +263,7 @@ void VcsCommand::run(QFutureInterface<void> &future)
|
|||||||
for (int j = 0; j < count; j++) {
|
for (int j = 0; j < count; j++) {
|
||||||
const Internal::VcsCommandPrivate::Job &job = d->m_jobs.at(j);
|
const Internal::VcsCommandPrivate::Job &job = d->m_jobs.at(j);
|
||||||
Utils::SynchronousProcessResponse resp
|
Utils::SynchronousProcessResponse resp
|
||||||
= runVcs( job.arguments, job.timeoutS, job.exitCodeInterpreter);
|
= runVcs(job.binary, job.arguments, job.timeoutS, job.exitCodeInterpreter);
|
||||||
stdOut += resp.stdOut;
|
stdOut += resp.stdOut;
|
||||||
stdErr += resp.stdErr;
|
stdErr += resp.stdErr;
|
||||||
d->m_lastExecExitCode = resp.exitCode;
|
d->m_lastExecExitCode = resp.exitCode;
|
||||||
@@ -330,24 +321,25 @@ signals:
|
|||||||
void appendMessage(const QString &text);
|
void appendMessage(const QString &text);
|
||||||
};
|
};
|
||||||
|
|
||||||
Utils::SynchronousProcessResponse VcsCommand::runVcs(const QStringList &arguments, int timeoutS,
|
Utils::SynchronousProcessResponse VcsCommand::runVcs(const Utils::FileName &binary,
|
||||||
|
const QStringList &arguments, int timeoutS,
|
||||||
Utils::ExitCodeInterpreter *interpreter)
|
Utils::ExitCodeInterpreter *interpreter)
|
||||||
{
|
{
|
||||||
Utils::SynchronousProcessResponse response;
|
Utils::SynchronousProcessResponse response;
|
||||||
OutputProxy outputProxy;
|
OutputProxy outputProxy;
|
||||||
|
|
||||||
if (d->m_binaryPath.isEmpty()) {
|
if (binary.isEmpty()) {
|
||||||
response.result = Utils::SynchronousProcessResponse::StartFailed;
|
response.result = Utils::SynchronousProcessResponse::StartFailed;
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(d->m_flags & VcsBasePlugin::SuppressCommandLogging))
|
if (!(d->m_flags & VcsBasePlugin::SuppressCommandLogging))
|
||||||
emit outputProxy.appendCommand(d->m_workingDirectory, d->m_binaryPath, arguments);
|
emit outputProxy.appendCommand(d->m_workingDirectory, binary, arguments);
|
||||||
|
|
||||||
const bool sshPromptConfigured = !d->m_sshPasswordPrompt.isEmpty();
|
const bool sshPromptConfigured = !d->m_sshPasswordPrompt.isEmpty();
|
||||||
if (debugExecution) {
|
if (debugExecution) {
|
||||||
QDebug nsp = qDebug().nospace();
|
QDebug nsp = qDebug().nospace();
|
||||||
nsp << "Command::runVcs" << d->m_workingDirectory << d->m_binaryPath << arguments
|
nsp << "Command::runVcs" << d->m_workingDirectory << binary << arguments
|
||||||
<< timeoutS;
|
<< timeoutS;
|
||||||
if (d->m_flags & VcsBasePlugin::ShowStdOutInLogWindow)
|
if (d->m_flags & VcsBasePlugin::ShowStdOutInLogWindow)
|
||||||
nsp << "stdout";
|
nsp << "stdout";
|
||||||
@@ -375,7 +367,7 @@ Utils::SynchronousProcessResponse VcsCommand::runVcs(const QStringList &argument
|
|||||||
// if (d->m_flags & ExpectRepoChanges)
|
// if (d->m_flags & ExpectRepoChanges)
|
||||||
// Core::DocumentManager::expectDirectoryChange(d->m_workingDirectory);
|
// Core::DocumentManager::expectDirectoryChange(d->m_workingDirectory);
|
||||||
if (d->m_flags & VcsBasePlugin::FullySynchronously) {
|
if (d->m_flags & VcsBasePlugin::FullySynchronously) {
|
||||||
response = runSynchronous(arguments, timeoutS, interpreter);
|
response = runSynchronous(binary, arguments, timeoutS, interpreter);
|
||||||
} else {
|
} else {
|
||||||
Utils::SynchronousProcess process;
|
Utils::SynchronousProcess process;
|
||||||
process.setExitCodeInterpreter(interpreter);
|
process.setExitCodeInterpreter(interpreter);
|
||||||
@@ -417,19 +409,16 @@ Utils::SynchronousProcessResponse VcsCommand::runVcs(const QStringList &argument
|
|||||||
process.setTimeOutMessageBoxEnabled(true);
|
process.setTimeOutMessageBoxEnabled(true);
|
||||||
|
|
||||||
// Run!
|
// Run!
|
||||||
response = process.run(d->m_binaryPath.toString(), arguments);
|
response = process.run(binary.toString(), arguments);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!d->m_aborted) {
|
if (!d->m_aborted) {
|
||||||
// Success/Fail message in appropriate window?
|
// Success/Fail message in appropriate window?
|
||||||
if (response.result == Utils::SynchronousProcessResponse::Finished) {
|
if (response.result == Utils::SynchronousProcessResponse::Finished) {
|
||||||
if (d->m_flags & VcsBasePlugin::ShowSuccessMessage) {
|
if (d->m_flags & VcsBasePlugin::ShowSuccessMessage)
|
||||||
emit outputProxy.appendMessage(response.exitMessage(d->m_binaryPath.toUserOutput(),
|
emit outputProxy.appendMessage(response.exitMessage(binary.toUserOutput(), timeoutS));
|
||||||
timeoutS));
|
|
||||||
}
|
|
||||||
} else if (!(d->m_flags & VcsBasePlugin::SuppressFailMessageInLogWindow)) {
|
} else if (!(d->m_flags & VcsBasePlugin::SuppressFailMessageInLogWindow)) {
|
||||||
emit outputProxy.appendError(response.exitMessage(d->m_binaryPath.toUserOutput(),
|
emit outputProxy.appendError(response.exitMessage(binary.toUserOutput(), timeoutS));
|
||||||
timeoutS));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emitRepositoryChanged();
|
emitRepositoryChanged();
|
||||||
@@ -437,7 +426,8 @@ Utils::SynchronousProcessResponse VcsCommand::runVcs(const QStringList &argument
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
Utils::SynchronousProcessResponse VcsCommand::runSynchronous(const QStringList &arguments,
|
Utils::SynchronousProcessResponse VcsCommand::runSynchronous(const Utils::FileName &binary,
|
||||||
|
const QStringList &arguments,
|
||||||
int timeoutS,
|
int timeoutS,
|
||||||
Utils::ExitCodeInterpreter *interpreter)
|
Utils::ExitCodeInterpreter *interpreter)
|
||||||
{
|
{
|
||||||
@@ -459,7 +449,7 @@ Utils::SynchronousProcessResponse VcsCommand::runSynchronous(const QStringList &
|
|||||||
process->setProcessChannelMode(QProcess::MergedChannels);
|
process->setProcessChannelMode(QProcess::MergedChannels);
|
||||||
|
|
||||||
// Start
|
// Start
|
||||||
process->start(d->m_binaryPath.toString(), arguments, QIODevice::ReadOnly);
|
process->start(binary.toString(), arguments, QIODevice::ReadOnly);
|
||||||
process->closeWriteChannel();
|
process->closeWriteChannel();
|
||||||
if (!process->waitForStarted()) {
|
if (!process->waitForStarted()) {
|
||||||
response.result = Utils::SynchronousProcessResponse::StartFailed;
|
response.result = Utils::SynchronousProcessResponse::StartFailed;
|
||||||
@@ -515,15 +505,14 @@ void VcsCommand::emitRepositoryChanged()
|
|||||||
Core::VcsManager::emitRepositoryChanged(d->m_workingDirectory);
|
Core::VcsManager::emitRepositoryChanged(d->m_workingDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VcsCommand::runFullySynchronous(const QStringList &arguments, int timeoutS,
|
bool VcsCommand::runFullySynchronous(const Utils::FileName &binary, const QStringList &arguments,
|
||||||
QByteArray *outputData, QByteArray *errorData)
|
int timeoutS, QByteArray *outputData, QByteArray *errorData)
|
||||||
{
|
{
|
||||||
if (d->m_binaryPath.isEmpty())
|
QTC_ASSERT(!binary.isEmpty(), return false);
|
||||||
return false;
|
|
||||||
|
|
||||||
OutputProxy outputProxy;
|
OutputProxy outputProxy;
|
||||||
if (!(d->m_flags & VcsBasePlugin::SuppressCommandLogging))
|
if (!(d->m_flags & VcsBasePlugin::SuppressCommandLogging))
|
||||||
emit outputProxy.appendCommand(d->m_workingDirectory, d->m_binaryPath, arguments);
|
emit outputProxy.appendCommand(d->m_workingDirectory, binary, arguments);
|
||||||
|
|
||||||
// TODO tell the document manager about expected repository changes
|
// TODO tell the document manager about expected repository changes
|
||||||
// if (d->m_flags & ExpectRepoChanges)
|
// if (d->m_flags & ExpectRepoChanges)
|
||||||
@@ -532,12 +521,12 @@ bool VcsCommand::runFullySynchronous(const QStringList &arguments, int timeoutS,
|
|||||||
process.setWorkingDirectory(d->m_workingDirectory);
|
process.setWorkingDirectory(d->m_workingDirectory);
|
||||||
process.setProcessEnvironment(d->m_environment);
|
process.setProcessEnvironment(d->m_environment);
|
||||||
|
|
||||||
process.start(d->m_binaryPath.toString(), arguments);
|
process.start(binary.toString(), arguments);
|
||||||
process.closeWriteChannel();
|
process.closeWriteChannel();
|
||||||
if (!process.waitForStarted()) {
|
if (!process.waitForStarted()) {
|
||||||
if (errorData) {
|
if (errorData) {
|
||||||
const QString msg = QString::fromLatin1("Unable to execute \"%1\": %2:")
|
const QString msg = QString::fromLatin1("Unable to execute \"%1\": %2:")
|
||||||
.arg(d->m_binaryPath.toUserOutput(), process.errorString());
|
.arg(binary.toUserOutput(), process.errorString());
|
||||||
*errorData = msg.toLocal8Bit();
|
*errorData = msg.toLocal8Bit();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@@ -77,20 +77,18 @@ class VCSBASE_EXPORT VcsCommand : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
VcsCommand(const Utils::FileName &binary,
|
VcsCommand(const QString &workingDirectory,
|
||||||
const QString &workingDirectory,
|
|
||||||
const QProcessEnvironment &environment);
|
const QProcessEnvironment &environment);
|
||||||
~VcsCommand();
|
~VcsCommand();
|
||||||
|
|
||||||
void addJob(const QStringList &arguments, Utils::ExitCodeInterpreter *interpreter = 0);
|
void addJob(const Utils::FileName &binary, const QStringList &arguments, Utils::ExitCodeInterpreter *interpreter = 0);
|
||||||
void addJob(const QStringList &arguments, int timeoutS,
|
void addJob(const Utils::FileName &binary, const QStringList &arguments, int timeoutS,
|
||||||
Utils::ExitCodeInterpreter *interpreter = 0);
|
Utils::ExitCodeInterpreter *interpreter = 0);
|
||||||
void execute();
|
void execute();
|
||||||
void abort();
|
void abort();
|
||||||
bool lastExecutionSuccess() const;
|
bool lastExecutionSuccess() const;
|
||||||
int lastExecutionExitCode() const;
|
int lastExecutionExitCode() const;
|
||||||
|
|
||||||
const Utils::FileName &binaryPath() const;
|
|
||||||
const QString &workingDirectory() const;
|
const QString &workingDirectory() const;
|
||||||
const QProcessEnvironment &processEnvironment() const;
|
const QProcessEnvironment &processEnvironment() const;
|
||||||
|
|
||||||
@@ -109,15 +107,15 @@ public:
|
|||||||
void setProgressParser(ProgressParser *parser);
|
void setProgressParser(ProgressParser *parser);
|
||||||
void setProgressiveOutput(bool progressive);
|
void setProgressiveOutput(bool progressive);
|
||||||
|
|
||||||
Utils::SynchronousProcessResponse runVcs(const QStringList &arguments, int timeoutS,
|
Utils::SynchronousProcessResponse runVcs(const Utils::FileName &binary, const QStringList &arguments, int timeoutS,
|
||||||
Utils::ExitCodeInterpreter *interpreter = 0);
|
Utils::ExitCodeInterpreter *interpreter = 0);
|
||||||
// Make sure to not pass through the event loop at all:
|
// Make sure to not pass through the event loop at all:
|
||||||
bool runFullySynchronous(const QStringList &arguments, int timeoutS,
|
bool runFullySynchronous(const Utils::FileName &binary, const QStringList &arguments, int timeoutS,
|
||||||
QByteArray *outputData, QByteArray *errorData);
|
QByteArray *outputData, QByteArray *errorData);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void run(QFutureInterface<void> &future);
|
void run(QFutureInterface<void> &future);
|
||||||
Utils::SynchronousProcessResponse runSynchronous(const QStringList &arguments, int timeoutS,
|
Utils::SynchronousProcessResponse runSynchronous(const Utils::FileName &binary, const QStringList &arguments, int timeoutS,
|
||||||
Utils::ExitCodeInterpreter *interpreter = 0);
|
Utils::ExitCodeInterpreter *interpreter = 0);
|
||||||
void emitRepositoryChanged();
|
void emitRepositoryChanged();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user