Commit eed4d1e1 authored by cerf's avatar cerf Committed by Tobias Hunger

vcsbase: make settings mutable inside VCSBaseClient

VCSBaseClient takes now a pointer to VCSBaseClientSettings, so settings
can be changed within the VCS client. For example diff settings can now
be loaded and saved from within the VCS client.
This impacts the Bazaar and Mercurial plugins

Change-Id: I84882b1f3355e0ca2597704f48f589dca42fd661
Merge-request: 344
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
Reviewed-on: http://codereview.qt.nokia.com/452Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
parent 2f97c709
......@@ -48,16 +48,21 @@
namespace Bazaar {
namespace Internal {
BazaarClient::BazaarClient(const VCSBase::VCSBaseClientSettings &settings) :
BazaarClient::BazaarClient(BazaarSettings *settings) :
VCSBase::VCSBaseClient(settings)
{
}
BazaarSettings *BazaarClient::settings() const
{
return dynamic_cast<BazaarSettings *>(VCSBase::VCSBaseClient::settings());
}
bool BazaarClient::synchronousSetUserId()
{
QStringList args;
args << QLatin1String("whoami")
<< QString("%1 <%2>").arg(settings().userName()).arg(settings().email());
<< QString("%1 <%2>").arg(settings()->userName()).arg(settings()->email());
QByteArray stdOut;
return vcsFullySynchronousExec(QDir::currentPath(), args, &stdOut);
}
......
......@@ -33,6 +33,7 @@
#ifndef BAZAARCLIENT_H
#define BAZAARCLIENT_H
#include "bazaarsettings.h"
#include "branchinfo.h"
#include <vcsbase/vcsbaseclient.h>
......@@ -40,11 +41,15 @@ namespace Bazaar {
namespace Internal {
struct BazaarDiffParameters;
class BazaarSettings;
class BazaarClient : public VCSBase::VCSBaseClient
{
Q_OBJECT
public:
BazaarClient(const VCSBase::VCSBaseClientSettings &settings);
BazaarClient(BazaarSettings *settings);
BazaarSettings *settings() const;
bool synchronousSetUserId();
BranchInfo synchronousBranchQuery(const QString &repositoryRoot) const;
......
......@@ -69,7 +69,7 @@ bool BazaarControl::managesDirectory(const QString &directory, QString *topLevel
bool BazaarControl::isConfigured() const
{
const QString binary = m_bazaarClient->settings().binary();
const QString binary = m_bazaarClient->settings()->binary();
if (binary.isEmpty())
return false;
QFileInfo fi(binary);
......
......@@ -153,7 +153,7 @@ bool BazaarPlugin::initialize(const QStringList &arguments, QString *errorMessag
typedef VCSBase::VCSEditorFactory<BazaarEditor> BazaarEditorFactory;
m_client = new BazaarClient(m_bazaarSettings);
m_client = new BazaarClient(&m_bazaarSettings);
initializeVcs(new BazaarControl(m_client));
m_core = Core::ICore::instance();
......
......@@ -51,7 +51,7 @@
namespace Mercurial {
namespace Internal {
MercurialClient::MercurialClient(const VCSBase::VCSBaseClientSettings &settings) :
MercurialClient::MercurialClient(VCSBase::VCSBaseClientSettings *settings) :
VCSBase::VCSBaseClient(settings)
{
}
......
......@@ -43,7 +43,7 @@ class MercurialClient : public VCSBase::VCSBaseClient
{
Q_OBJECT
public:
MercurialClient(const VCSBase::VCSBaseClientSettings &settings);
MercurialClient(VCSBase::VCSBaseClientSettings *settings);
virtual bool synchronousClone(const QString &workingDir,
const QString &srcLocation,
const QString &dstLocation,
......
......@@ -69,7 +69,7 @@ bool MercurialControl::managesDirectory(const QString &directory, QString *topLe
bool MercurialControl::isConfigured() const
{
const QString binary = mercurialClient->settings().binary();
const QString binary = mercurialClient->settings()->binary();
if (binary.isEmpty())
return false;
QFileInfo fi(binary);
......
......@@ -156,7 +156,7 @@ bool MercurialPlugin::initialize(const QStringList & /* arguments */, QString *
{
typedef VCSBase::VCSEditorFactory<MercurialEditor> MercurialEditorFactory;
m_client = new MercurialClient(mercurialSettings);
m_client = new MercurialClient(&mercurialSettings);
initializeVcs(new MercurialControl(m_client));
core = Core::ICore::instance();
......
......@@ -80,19 +80,19 @@ namespace VCSBase {
class VCSBaseClientPrivate
{
public:
explicit VCSBaseClientPrivate(const VCSBaseClientSettings &settings);
explicit VCSBaseClientPrivate(VCSBaseClientSettings *settings);
VCSJobRunner *m_jobManager;
Core::ICore *m_core;
const VCSBaseClientSettings& m_clientSettings;
VCSBaseClientSettings* m_clientSettings;
};
VCSBaseClientPrivate::VCSBaseClientPrivate(const VCSBaseClientSettings &settings) :
VCSBaseClientPrivate::VCSBaseClientPrivate(VCSBaseClientSettings *settings) :
m_jobManager(0), m_core(Core::ICore::instance()), m_clientSettings(settings)
{
}
VCSBaseClient::VCSBaseClient(const VCSBaseClientSettings &settings) :
VCSBaseClient::VCSBaseClient(VCSBaseClientSettings *settings) :
d(new VCSBaseClientPrivate(settings))
{
qRegisterMetaType<QVariant>();
......@@ -197,8 +197,8 @@ bool VCSBaseClient::vcsFullySynchronousExec(const QString &workingDir,
vcsProcess.setWorkingDirectory(workingDir);
VCSJobRunner::setProcessEnvironment(&vcsProcess);
const QString binary = d->m_clientSettings.binary();
const QStringList arguments = d->m_clientSettings.standardArguments() + args;
const QString binary = settings()->binary();
const QStringList arguments = settings()->standardArguments() + args;
VCSBase::VCSBaseOutputWindow *outputWindow = VCSBase::VCSBaseOutputWindow::instance();
outputWindow->appendCommand(workingDir, binary, args);
......@@ -213,10 +213,10 @@ bool VCSBaseClient::vcsFullySynchronousExec(const QString &workingDir,
vcsProcess.closeWriteChannel();
QByteArray stdErr;
if (!Utils::SynchronousProcess::readDataFromProcess(vcsProcess, d->m_clientSettings.timeoutMilliSeconds(),
if (!Utils::SynchronousProcess::readDataFromProcess(vcsProcess, settings()->timeoutMilliSeconds(),
output, &stdErr, true)) {
Utils::SynchronousProcess::stopProcess(vcsProcess);
outputWindow->appendError(VCSJobRunner::msgTimeout(binary, d->m_clientSettings.timeoutSeconds()));
outputWindow->appendError(VCSJobRunner::msgTimeout(binary, settings()->timeoutSeconds()));
return false;
}
if (!stdErr.isEmpty())
......@@ -231,10 +231,10 @@ Utils::SynchronousProcessResponse VCSBaseClient::vcsSynchronousExec(
unsigned flags,
QTextCodec *outputCodec)
{
const QString binary = d->m_clientSettings.binary();
const QStringList arguments = d->m_clientSettings.standardArguments() + args;
const QString binary = settings()->binary();
const QStringList arguments = settings()->standardArguments() + args;
return VCSBase::VCSBasePlugin::runVCS(workingDirectory, binary, arguments,
d->m_clientSettings.timeoutMilliSeconds(),
settings()->timeoutMilliSeconds(),
flags, outputCodec);
}
......@@ -441,7 +441,7 @@ void VCSBaseClient::commit(const QString &repositoryRoot,
enqueueJob(job);
}
const VCSBaseClientSettings &VCSBaseClient::settings() const
VCSBaseClientSettings *VCSBaseClient::settings() const
{
return d->m_clientSettings;
}
......@@ -449,9 +449,9 @@ const VCSBaseClientSettings &VCSBaseClient::settings() const
void VCSBaseClient::settingsChanged()
{
if (d->m_jobManager) {
d->m_jobManager->setSettings(d->m_clientSettings.binary(),
d->m_clientSettings.standardArguments(),
d->m_clientSettings.timeoutMilliSeconds());
d->m_jobManager->setSettings(settings()->binary(),
settings()->standardArguments(),
settings()->timeoutMilliSeconds());
d->m_jobManager->restart();
}
}
......@@ -464,7 +464,7 @@ void VCSBaseClient::initializeDiffEditor(const QString & /* workingDir */, const
QString VCSBaseClient::vcsEditorTitle(const QString &vcsCmd, const QString &sourceId) const
{
return QFileInfo(d->m_clientSettings.binary()).baseName() +
return QFileInfo(settings()->binary()).baseName() +
QLatin1Char(' ') + vcsCmd + QLatin1Char(' ') +
QFileInfo(sourceId).fileName();
}
......@@ -503,9 +503,9 @@ void VCSBaseClient::enqueueJob(const QSharedPointer<VCSJob> &job)
{
if (!d->m_jobManager) {
d->m_jobManager = new VCSJobRunner();
d->m_jobManager->setSettings(d->m_clientSettings.binary(),
d->m_clientSettings.standardArguments(),
d->m_clientSettings.timeoutMilliSeconds());
d->m_jobManager->setSettings(settings()->binary(),
settings()->standardArguments(),
settings()->timeoutMilliSeconds());
d->m_jobManager->start();
}
d->m_jobManager->enqueueJob(job);
......
......@@ -66,7 +66,7 @@ class VCSBASE_EXPORT VCSBaseClient : public QObject
{
Q_OBJECT
public:
explicit VCSBaseClient(const VCSBaseClientSettings &settings);
explicit VCSBaseClient(VCSBaseClientSettings *settings);
~VCSBaseClient();
virtual bool synchronousCreateRepository(const QString &workingDir);
virtual bool synchronousClone(const QString &workingDir,
......@@ -103,7 +103,7 @@ public:
virtual QString findTopLevelForFile(const QFileInfo &file) const = 0;
const VCSBaseClientSettings &settings() const;
virtual VCSBaseClientSettings *settings() const;
signals:
void parsedStatus(const QList<QPair<QString, QString> > &statusList);
......
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