Commit f2e4b2b9 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh

VCS: Invert Command -> runVcs dependency

* Unclutter runVcs
* Enable more dynamic signal/slot usage in Command

Change-Id: Ie97b17078778b0c86b74d5725a78e766828ac6d8
Reviewed-by: default avatarFriedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 80194f4e
......@@ -1377,7 +1377,6 @@ ClearCaseResponse
const Utils::SynchronousProcessResponse sp_resp =
VcsBase::VcsBasePlugin::runVcs(workingDir, executable,
arguments, timeOut,
VcsBase::VcsBasePlugin::sshPrompt(),
flags, outputCodec);
response.error = sp_resp.result != Utils::SynchronousProcessResponse::Finished;
......
......@@ -1237,7 +1237,7 @@ CvsResponse CvsPlugin::runCvs(const QString &workingDirectory,
// Run, connect stderr to the output window
const Utils::SynchronousProcessResponse sp_resp =
runVcs(workingDirectory, executable, m_settings.addOptions(arguments),
timeOut, VcsBase::VcsBasePlugin::sshPrompt(), flags, outputCodec);
timeOut, flags, outputCodec);
response.result = CvsResponse::OtherError;
response.stdErr = sp_resp.stdErr;
......
......@@ -2253,7 +2253,6 @@ VcsBase::Command *GitClient::executeGit(const QString &workingDirectory,
outputWindow()->appendCommand(workingDirectory, settings()->stringValue(GitSettings::binaryPathKey), arguments);
VcsBase::Command *command = createCommand(workingDirectory, editor, useOutputToWindow, editorLineNumber);
command->addJob(arguments, settings()->intValue(GitSettings::timeoutKey));
command->setUnixTerminalDisabled(false);
if (expectChanges)
command->addFlags(VcsBasePlugin::ExpectRepoChanges);
command->execute();
......@@ -2320,8 +2319,7 @@ Utils::SynchronousProcessResponse GitClient::synchronousGit(const QString &worki
{
return VcsBasePlugin::runVcs(workingDirectory, gitBinaryPath(), gitArguments,
settings()->intValue(GitSettings::timeoutKey) * 1000,
processEnvironment(), VcsBase::VcsBasePlugin::sshPrompt(),
flags, outputCodec);
flags, outputCodec, processEnvironment());
}
bool GitClient::fullySynchronousGit(const QString &workingDirectory,
......@@ -2330,10 +2328,11 @@ bool GitClient::fullySynchronousGit(const QString &workingDirectory,
QByteArray* errorText,
unsigned flags) const
{
return VcsBasePlugin::runFullySynchronous(workingDirectory, gitBinaryPath(), gitArguments,
processEnvironment(), outputText, errorText,
settings()->intValue(GitSettings::timeoutKey) * 1000,
flags);
VcsBase::Command command(gitBinaryPath(), workingDirectory, processEnvironment());
command.addFlags(flags);
return command.runFullySynchronous(gitArguments,
settings()->intValue(GitSettings::timeoutKey) * 1000,
outputText, errorText);
}
void GitClient::updateSubmodulesIfNeeded(const QString &workingDirectory, bool prompt)
......
......@@ -146,8 +146,7 @@ bool MercurialClient::synchronousPull(const QString &workingDir, const QString &
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
env.insert(QLatin1String("LANGUAGE"), QLatin1String("C"));
const Utils::SynchronousProcessResponse resp = VcsBase::VcsBasePlugin::runVcs(
workingDir, binary, args, timeoutSec * 1000, env,
VcsBase::VcsBasePlugin::sshPrompt(), flags);
workingDir, binary, args, timeoutSec * 1000, flags, 0, env);
const bool ok = resp.result == Utils::SynchronousProcessResponse::Finished;
parsePullOutput(resp.stdOut.trimmed());
......@@ -276,8 +275,6 @@ void MercurialClient::incoming(const QString &repositoryRoot, const QString &rep
VcsBase::VcsBaseEditorWidget *editor = createVcsEditor(Constants::DIFFLOG, title, repositoryRoot,
true, "incoming", id);
VcsBase::Command *cmd = createCommand(repository, editor);
if (!repository.isEmpty() && VcsBase::VcsBasePlugin::isSshPromptConfigured())
cmd->setUnixTerminalDisabled(true);
enqueueJob(cmd, args);
}
......@@ -293,7 +290,6 @@ void MercurialClient::outgoing(const QString &repositoryRoot)
"outgoing", repositoryRoot);
VcsBase::Command *cmd = createCommand(repositoryRoot, editor);
cmd->setUnixTerminalDisabled(VcsBase::VcsBasePlugin::isSshPromptConfigured());
enqueueJob(cmd, args);
}
......
......@@ -1120,8 +1120,7 @@ SubversionPlugin::Version SubversionPlugin::svnVersion()
args << QLatin1String("--version") << QLatin1String("-q");
const Utils::SynchronousProcessResponse response =
VcsBase::VcsBasePlugin::runVcs(QDir().absolutePath(), m_settings.binaryPath(),
args, m_settings.timeOutMs(),
VcsBase::VcsBasePlugin::sshPrompt(), 0);
args, m_settings.timeOutMs());
if (response.result == Utils::SynchronousProcessResponse::Finished &&
response.exitCode == 0) {
m_svnVersionBinary = m_settings.binaryPath();
......@@ -1156,7 +1155,7 @@ SubversionResponse SubversionPlugin::runSvn(const QString &workingDir,
const QStringList completeArguments = SubversionPlugin::addAuthenticationOptions(arguments, userName, password);
const Utils::SynchronousProcessResponse sp_resp =
VcsBase::VcsBasePlugin::runVcs(workingDir, executable, completeArguments, timeOut,
VcsBase::VcsBasePlugin::sshPrompt(), flags, outputCodec);
flags, outputCodec);
response.error = sp_resp.result != Utils::SynchronousProcessResponse::Finished;
if (response.error)
......
This diff is collapsed.
......@@ -32,6 +32,8 @@
#include "vcsbase_global.h"
#include <utils/synchronousprocess.h>
#include <QObject>
QT_BEGIN_NAMESPACE
......@@ -69,10 +71,6 @@ public:
int defaultTimeout() const;
void setDefaultTimeout(int timeout);
// Disable Terminal on UNIX (see VCS SSH handling)
bool unixTerminalDisabled() const;
void setUnixTerminalDisabled(bool);
unsigned flags() const;
void addFlags(unsigned f);
......@@ -82,8 +80,15 @@ public:
QTextCodec *codec() const;
void setCodec(QTextCodec *codec);
Utils::SynchronousProcessResponse runVcs(const QStringList &arguments, int timeoutMS);
// Make sure to not pass through the event loop at all:
bool runFullySynchronous(const QStringList &arguments, int timeoutMS,
QByteArray *outputData, QByteArray *errorData);
private:
void run(QFutureInterface<void> &future);
Utils::SynchronousProcessResponse runSynchronous(const QStringList &arguments, int timeoutMS);
signals:
void output(const QString &);
......
......@@ -319,7 +319,7 @@ Utils::SynchronousProcessResponse VcsBaseClient::vcsSynchronousExec(
const QString binary = settings()->binaryPath();
const int timeoutSec = settings()->intValue(VcsBaseClientSettings::timeoutKey);
return VcsBase::VcsBasePlugin::runVcs(workingDirectory, binary, args, timeoutSec * 1000,
VcsBase::VcsBasePlugin::sshPrompt(), flags, outputCodec);
flags, outputCodec);
}
void VcsBaseClient::annotate(const QString &workingDir, const QString &file,
......@@ -492,7 +492,6 @@ void VcsBaseClient::update(const QString &repositoryRoot, const QString &revisio
args << revisionSpec(revision) << extraOptions;
Command *cmd = createCommand(repositoryRoot);
cmd->setCookie(repositoryRoot);
cmd->setUnixTerminalDisabled(VcsBase::VcsBasePlugin::isSshPromptConfigured());
connect(cmd, SIGNAL(success(QVariant)), this, SIGNAL(changed(QVariant)), Qt::QueuedConnection);
enqueueJob(cmd, args);
}
......
This diff is collapsed.
......@@ -36,10 +36,10 @@
#include <QSharedDataPointer>
#include <QList>
#include <QProcessEnvironment>
QT_BEGIN_NAMESPACE
class QAction;
class QProcessEnvironment;
class QTextCodec;
QT_END_NAMESPACE
......@@ -150,7 +150,9 @@ public:
// Sets up SSH graphical password prompting (note that the latter
// requires a terminal-less process) and sets LANG to 'C' to force English
// (suppress LOCALE warnings/parse commands output) if desired.
static void setProcessEnvironment(QProcessEnvironment *e, bool forceCLocale);
static void setProcessEnvironment(QProcessEnvironment *e,
bool forceCLocale,
const QString &sshPasswordPrompt = sshPrompt());
// Returns SSH prompt configured in settings.
static QString sshPrompt();
// Returns whether an SSH prompt is configured.
......@@ -176,28 +178,9 @@ public:
const QString &binary,
const QStringList &arguments,
int timeOutMS,
QProcessEnvironment env,
const QString &sshPasswordPrompt,
unsigned flags = 0,
QTextCodec *outputCodec = 0);
static Utils::SynchronousProcessResponse runVcs(const QString &workingDir,
const QString &binary,
const QStringList &arguments,
int timeOutMS,
const QString &sshPasswordPrompt,
unsigned flags = 0,
QTextCodec *outputCodec = 0);
// Make sure to not pass through the event loop at all:
static bool runFullySynchronous(const QString &workingDirectory,
const QString &binary,
const QStringList &arguments,
const QProcessEnvironment &env,
QByteArray* outputText,
QByteArray *errorText,
int timeoutMS,
unsigned flags);
QTextCodec *outputCodec = 0,
const QProcessEnvironment &env = QProcessEnvironment());
// Utility to run the 'patch' command
static bool runPatch(const QByteArray &input, const QString &workingDirectory = QString(),
......@@ -245,20 +228,6 @@ private slots:
void slotTestRemoveSnapshot();
private:
static void setProcessEnvironment(QProcessEnvironment *e,
bool forceCLocale,
const QString &sshPasswordPrompt);
static Utils::SynchronousProcessResponse runVcsFullySynchronously(
const QString &workingDir,
const QString &binary,
const QStringList &arguments,
int timeOutMS,
QProcessEnvironment env,
const QString &sshPasswordPrompt,
unsigned flags,
QTextCodec *outputCodec = 0);
VcsBasePluginPrivate *d;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment