Commit 10b667ad authored by cerf's avatar cerf Committed by Tobias Hunger

vcsbase: add mechanism to ease management of VCS settings

Management of VCS settings was rather laborious (see BazaarSettings,
GitSettings, ...).
To overcome this, the base class VCSBaseClientSettings is now
equipped with a mechanism factorizing redundant code for VCS settings,
like operator=(), operator==(), writeSettings(), ...
Heir classes of VCSBaseClientSettings only need to declare the
settings (key + default value).

Bazaar and Mercurial plugins are impacted.

Change-Id: I7e4093a6d9476f3c8954f4d104f1b26ac185beb9
Merge-request: 2204
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
Reviewed-on: http://codereview.qt-project.org/4889Reviewed-by: default avatarQt Sanity Bot <qt_sanity_bot@ovi.com>
parent a67d8205
......@@ -62,7 +62,9 @@ bool BazaarClient::synchronousSetUserId()
{
QStringList args;
args << QLatin1String("whoami")
<< QString("%1 <%2>").arg(settings()->userName()).arg(settings()->email());
<< QString("%1 <%2>")
.arg(settings()->stringValue(BazaarSettings::userNameKey))
.arg(settings()->stringValue(BazaarSettings::userEmailKey));
QByteArray stdOut;
return vcsFullySynchronousExec(QDir::currentPath(), args, &stdOut);
}
......@@ -217,9 +219,9 @@ public:
VCSBase::VCSBaseEditorParameterWidget(parent), m_client(client), m_params(p)
{
mapSetting(addToggleButton(QLatin1String("-w"), tr("Ignore whitespace")),
&client->settings()->diffIgnoreWhiteSpace);
client->settings()->boolPointer(BazaarSettings::diffIgnoreWhiteSpaceKey));
mapSetting(addToggleButton(QLatin1String("-B"), tr("Ignore blank lines")),
&client->settings()->diffIgnoreBlankLines);
client->settings()->boolPointer(BazaarSettings::diffIgnoreBlankLinesKey));
}
QStringList arguments() const
......@@ -262,13 +264,13 @@ public:
{
mapSetting(addToggleButton(QLatin1String("--verbose"), tr("Verbose"),
tr("Show files changed in each revision")),
&m_client->settings()->logVerbose);
m_client->settings()->boolPointer(BazaarSettings::logVerboseKey));
mapSetting(addToggleButton(QLatin1String("--forward"), tr("Forward"),
tr("Show from oldest to newest")),
&m_client->settings()->logForward);
m_client->settings()->boolPointer(BazaarSettings::logForwardKey));
mapSetting(addToggleButton(QLatin1String("--include-merges"), tr("Include merges"),
tr("Show merged revisions")),
&m_client->settings()->logIncludeMerges);
m_client->settings()->boolPointer(BazaarSettings::logIncludeMergesKey));
QList<ComboBoxItem> logChoices;
logChoices << ComboBoxItem(tr("Detailed"), QLatin1String("long"))
......@@ -276,7 +278,7 @@ public:
<< ComboBoxItem(tr("One line"), QLatin1String("line"))
<< ComboBoxItem(tr("GNU ChangeLog"), QLatin1String("gnu-changelog"));
mapSetting(addComboBox(QLatin1String("--log-format"), logChoices),
&m_client->settings()->logFormat);
m_client->settings()->stringPointer(BazaarSettings::logFormatKey));
}
void executeCommand()
......
......@@ -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()->stringValue(BazaarSettings::binaryPathKey);
if (binary.isEmpty())
return false;
QFileInfo fi(binary);
......
......@@ -391,7 +391,7 @@ void BazaarPlugin::logRepository()
const VCSBase::VCSBasePluginState state = currentState();
QTC_ASSERT(state.hasTopLevel(), return);
QStringList extraOptions;
extraOptions += QString("--limit=%1").arg(settings().logCount());
extraOptions += QString("--limit=%1").arg(settings().intValue(BazaarSettings::logCountKey));
m_client->log(state.topLevel(), QStringList(), extraOptions);
}
......@@ -592,8 +592,8 @@ void BazaarPlugin::showCommitWidget(const QList<VCSBase::VCSBaseClient::StatusIt
commitEditor->setDisplayName(msg);
const BranchInfo branch = m_client->synchronousBranchQuery(m_submitRepository);
commitEditor->setFields(branch, m_bazaarSettings.userName(),
m_bazaarSettings.email(), status);
commitEditor->setFields(branch, m_bazaarSettings.stringValue(BazaarSettings::userNameKey),
m_bazaarSettings.stringValue(BazaarSettings::userEmailKey), status);
commitEditor->registerActions(m_editorUndo, m_editorRedo, m_editorCommit, m_editorDiff);
connect(commitEditor, SIGNAL(diffSelectedFiles(QStringList)),
......@@ -624,11 +624,11 @@ bool BazaarPlugin::submitEditorAboutToClose(VCSBase::VCSBaseSubmitEditor *submit
if (!editorFile || !commitEditor)
return true;
bool dummyPrompt = m_bazaarSettings.prompt();
bool dummyPrompt = m_bazaarSettings.boolValue(BazaarSettings::promptOnSubmitKey);
const VCSBase::VCSBaseSubmitEditor::PromptSubmitResult response =
commitEditor->promptSubmit(tr("Close Commit Editor"), tr("Do you want to commit the changes?"),
tr("Message check failed. Do you want to proceed?"),
&dummyPrompt, m_bazaarSettings.prompt());
&dummyPrompt, dummyPrompt);
switch (response) {
case VCSBase::VCSBaseSubmitEditor::SubmitCanceled:
......
......@@ -38,81 +38,30 @@
namespace Bazaar {
namespace Internal {
const QLatin1String diffIgnoreWhiteSpaceKey("diffIgnoreWhiteSpace");
const QLatin1String diffIgnoreBlankLinesKey("diffIgnoreBlankLines");
const QLatin1String logVerboseKey("logVerbose");
const QLatin1String logForwardKey("logForward");
const QLatin1String logIncludeMergesKey("logIncludeMerges");
const QLatin1String logFormatKey("logFormat");
const QLatin1String BazaarSettings::diffIgnoreWhiteSpaceKey("diffIgnoreWhiteSpace");
const QLatin1String BazaarSettings::diffIgnoreBlankLinesKey("diffIgnoreBlankLines");
const QLatin1String BazaarSettings::logVerboseKey("logVerbose");
const QLatin1String BazaarSettings::logForwardKey("logForward");
const QLatin1String BazaarSettings::logIncludeMergesKey("logIncludeMerges");
const QLatin1String BazaarSettings::logFormatKey("logFormat");
BazaarSettings::BazaarSettings() :
diffIgnoreWhiteSpace(false),
diffIgnoreBlankLines(false),
logVerbose(false),
logForward(false),
logIncludeMerges(false),
logFormat(QLatin1String("long"))
BazaarSettings::BazaarSettings()
{
setSettingsGroup(QLatin1String(Constants::BAZAAR));
setDefaultBinary(QLatin1String(Constants::BAZAARDEFAULT));
}
BazaarSettings& BazaarSettings::operator=(const BazaarSettings& other)
{
VCSBase::VCSBaseClientSettings::operator=(other);
if (this != &other) {
diffIgnoreWhiteSpace = other.diffIgnoreWhiteSpace;
diffIgnoreBlankLines = other.diffIgnoreBlankLines;
logVerbose = other.logVerbose;
logForward = other.logForward;
logIncludeMerges = other.logIncludeMerges;
logFormat = other.logFormat;
}
return *this;
// Override default binary path
declareKey(binaryPathKey, QLatin1String(Constants::BAZAARDEFAULT));
declareKey(diffIgnoreWhiteSpaceKey, false);
declareKey(diffIgnoreBlankLinesKey, false);
declareKey(logVerboseKey, false);
declareKey(logForwardKey, false);
declareKey(logIncludeMergesKey, false);
declareKey(logFormatKey, QLatin1String("long"));
}
bool BazaarSettings::sameUserId(const BazaarSettings& other) const
{
return userName() == other.userName() && email() == other.email();
}
void BazaarSettings::writeSettings(QSettings *settings) const
{
VCSBaseClientSettings::writeSettings(settings);
settings->beginGroup(settingsGroup());
settings->setValue(diffIgnoreWhiteSpaceKey, diffIgnoreWhiteSpace);
settings->setValue(diffIgnoreBlankLinesKey, diffIgnoreBlankLines);
settings->setValue(logVerboseKey, logVerbose);
settings->setValue(logForwardKey, logForward);
settings->setValue(logIncludeMergesKey, logIncludeMerges);
settings->setValue(logFormatKey, logFormat);
settings->endGroup();
}
void BazaarSettings::readSettings(const QSettings *settings)
{
VCSBaseClientSettings::readSettings(settings);
const QString keyRoot = settingsGroup() + QLatin1Char('/');
diffIgnoreWhiteSpace = settings->value(keyRoot + diffIgnoreWhiteSpaceKey, false).toBool();
diffIgnoreBlankLines = settings->value(keyRoot + diffIgnoreBlankLinesKey, false).toBool();
logVerbose = settings->value(keyRoot + logVerboseKey, false).toBool();
logForward = settings->value(keyRoot + logForwardKey, false).toBool();
logIncludeMerges = settings->value(keyRoot + logIncludeMergesKey, false).toBool();
logFormat = settings->value(keyRoot + logFormatKey, QLatin1String("long")).toString();
}
bool BazaarSettings::equals(const VCSBaseClientSettings &rhs) const
{
const BazaarSettings *bzrRhs = dynamic_cast<const BazaarSettings *>(&rhs);
if (bzrRhs == 0)
return false;
return VCSBaseClientSettings::equals(rhs)
&& diffIgnoreWhiteSpace == bzrRhs->diffIgnoreWhiteSpace
&& diffIgnoreBlankLines == bzrRhs->diffIgnoreBlankLines
&& logVerbose == bzrRhs->logVerbose
&& logForward == bzrRhs->logForward
&& logIncludeMerges == bzrRhs->logIncludeMerges
&& logFormat == bzrRhs->logFormat;
return stringValue(userNameKey) == other.stringValue(userNameKey) &&
stringValue(userEmailKey) == other.stringValue(userEmailKey);
}
} // namespace Internal
......
......@@ -41,21 +41,15 @@ namespace Internal {
class BazaarSettings : public VCSBase::VCSBaseClientSettings
{
public:
static const QLatin1String diffIgnoreWhiteSpaceKey;
static const QLatin1String diffIgnoreBlankLinesKey;
static const QLatin1String logVerboseKey;
static const QLatin1String logForwardKey;
static const QLatin1String logIncludeMergesKey;
static const QLatin1String logFormatKey;
BazaarSettings();
BazaarSettings& operator=(const BazaarSettings& other);
bool sameUserId(const BazaarSettings& other) const;
virtual void writeSettings(QSettings *settings) const;
virtual void readSettings(const QSettings *settings);
virtual bool equals(const VCSBaseClientSettings &rhs) const;
bool diffIgnoreWhiteSpace;
bool diffIgnoreBlankLines;
bool logVerbose;
bool logForward;
bool logIncludeMerges;
QString logFormat;
};
} // namespace Internal
......
......@@ -89,7 +89,6 @@ QSharedPointer<VCSBase::AbstractCheckoutJob> CloneWizard::createJob(const QList<
return QSharedPointer<VCSBase::AbstractCheckoutJob>();
const BazaarSettings &settings = BazaarPlugin::instance()->settings();
QStringList args = settings.standardArguments();
*checkoutPath = page->path() + QLatin1Char('/') + page->directory();
const CloneOptionsPanel *panel = page->cloneOptionsPanel();
......@@ -111,10 +110,11 @@ QSharedPointer<VCSBase::AbstractCheckoutJob> CloneWizard::createJob(const QList<
if (!panel->revision().isEmpty())
extraOptions << QLatin1String("-r") << panel->revision();
const BazaarClient *client = BazaarPlugin::instance()->client();
QStringList args;
args << client->vcsCommandString(BazaarClient::CloneCommand)
<< extraOptions << page->repository() << page->directory();
VCSBase::ProcessCheckoutJob *job = new VCSBase::ProcessCheckoutJob;
job->addStep(settings.binary(), args, page->path());
job->addStep(settings.stringValue(BazaarSettings::binaryPathKey), args, page->path());
return QSharedPointer<VCSBase::AbstractCheckoutJob>(job);
}
......@@ -54,24 +54,24 @@ OptionsPageWidget::OptionsPageWidget(QWidget *parent) :
BazaarSettings OptionsPageWidget::settings() const
{
BazaarSettings rc;
rc.setBinary(m_ui.commandChooser->path());
rc.setUserName(m_ui.defaultUsernameLineEdit->text().trimmed());
rc.setEmail(m_ui.defaultEmailLineEdit->text().trimmed());
rc.setLogCount(m_ui.logEntriesCount->value());
rc.setTimeoutSeconds(m_ui.timeout->value());
rc.setPrompt(m_ui.promptOnSubmitCheckBox->isChecked());
return rc;
BazaarSettings s = BazaarPlugin::instance()->settings();
s.setValue(BazaarSettings::binaryPathKey, m_ui.commandChooser->path());
s.setValue(BazaarSettings::userNameKey, m_ui.defaultUsernameLineEdit->text().trimmed());
s.setValue(BazaarSettings::userEmailKey, m_ui.defaultEmailLineEdit->text().trimmed());
s.setValue(BazaarSettings::logCountKey, m_ui.logEntriesCount->value());
s.setValue(BazaarSettings::timeoutKey, m_ui.timeout->value());
s.setValue(BazaarSettings::promptOnSubmitKey, m_ui.promptOnSubmitCheckBox->isChecked());
return s;
}
void OptionsPageWidget::setSettings(const BazaarSettings &s)
{
m_ui.commandChooser->setPath(s.binary());
m_ui.defaultUsernameLineEdit->setText(s.userName());
m_ui.defaultEmailLineEdit->setText(s.email());
m_ui.logEntriesCount->setValue(s.logCount());
m_ui.timeout->setValue(s.timeoutSeconds());
m_ui.promptOnSubmitCheckBox->setChecked(s.prompt());
m_ui.commandChooser->setPath(s.stringValue(BazaarSettings::binaryPathKey));
m_ui.defaultUsernameLineEdit->setText(s.stringValue(BazaarSettings::userNameKey));
m_ui.defaultEmailLineEdit->setText(s.stringValue(BazaarSettings::userEmailKey));
m_ui.logEntriesCount->setValue(s.intValue(BazaarSettings::logCountKey));
m_ui.timeout->setValue(s.intValue(BazaarSettings::timeoutKey));
m_ui.promptOnSubmitCheckBox->setChecked(s.boolValue(BazaarSettings::promptOnSubmitKey));
}
QString OptionsPageWidget::searchKeywords() const
......
......@@ -86,13 +86,13 @@ QSharedPointer<VCSBase::AbstractCheckoutJob> CloneWizard::createJob(const QList<
const MercurialSettings &settings = MercurialPlugin::instance()->settings();
QStringList args = settings.standardArguments();
QString path = page->path();
QString directory = page->directory();
QStringList args;
args << QLatin1String("clone") << page->repository() << directory;
*checkoutPath = path + QLatin1Char('/') + directory;
VCSBase::ProcessCheckoutJob *job = new VCSBase::ProcessCheckoutJob;
job->addStep(settings.binary(), args, path);
job->addStep(settings.stringValue(MercurialSettings::binaryPathKey), args, path);
return QSharedPointer<VCSBase::AbstractCheckoutJob>(job);
}
......@@ -423,9 +423,9 @@ public:
VCSBase::VCSBaseEditorParameterWidget(parent), m_client(client), m_params(p)
{
mapSetting(addToggleButton(QLatin1String("-w"), tr("Ignore whitespace")),
&client->settings()->diffIgnoreWhiteSpace);
client->settings()->boolPointer(MercurialSettings::diffIgnoreWhiteSpaceKey));
mapSetting(addToggleButton(QLatin1String("-B"), tr("Ignore blank lines")),
&client->settings()->diffIgnoreBlankLines);
client->settings()->boolPointer(MercurialSettings::diffIgnoreBlankLinesKey));
}
void executeCommand()
......
......@@ -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()->stringValue(MercurialSettings::binaryPathKey);
if (binary.isEmpty())
return false;
QFileInfo fi(binary);
......
......@@ -203,11 +203,6 @@ void MercurialPlugin::setSettings(const MercurialSettings &settings)
}
}
QStringList MercurialPlugin::standardArguments() const
{
return mercurialSettings.standardArguments();
}
void MercurialPlugin::createMenu()
{
Core::Context context(Core::Constants::C_GLOBAL);
......@@ -614,8 +609,9 @@ void MercurialPlugin::showCommitWidget(const QList<VCSBase::VCSBaseClient::Statu
QString branch = m_client->branchQuerySync(m_submitRepository);
commitEditor->setFields(m_submitRepository, branch, mercurialSettings.userName(),
mercurialSettings.email(), status);
commitEditor->setFields(m_submitRepository, branch,
mercurialSettings.stringValue(MercurialSettings::userNameKey),
mercurialSettings.stringValue(MercurialSettings::userEmailKey), status);
commitEditor->registerActions(editorUndo, editorRedo, editorCommit, editorDiff);
connect(commitEditor, SIGNAL(diffSelectedFiles(QStringList)),
......@@ -646,11 +642,11 @@ bool MercurialPlugin::submitEditorAboutToClose(VCSBase::VCSBaseSubmitEditor *sub
if (!editorFile || !commitEditor)
return true;
bool dummyPrompt = mercurialSettings.prompt();
bool dummyPrompt = mercurialSettings.boolValue(MercurialSettings::promptOnSubmitKey);
const VCSBase::VCSBaseSubmitEditor::PromptSubmitResult response =
commitEditor->promptSubmit(tr("Close Commit Editor"), tr("Do you want to commit the changes?"),
tr("Message check failed. Do you want to proceed?"),
&dummyPrompt, mercurialSettings.prompt());
&dummyPrompt, dummyPrompt);
switch (response) {
case VCSBase::VCSBaseSubmitEditor::SubmitCanceled:
......
......@@ -91,8 +91,6 @@ public:
static MercurialPlugin *instance() { return m_instance; }
MercurialClient *client() const { return m_client; }
QStringList standardArguments() const;
const MercurialSettings &settings() const;
void setSettings(const MercurialSettings &settings);
......
......@@ -38,53 +38,16 @@
namespace Mercurial {
namespace Internal {
const QLatin1String diffIgnoreWhiteSpaceKey("diffIgnoreWhiteSpace");
const QLatin1String diffIgnoreBlankLinesKey("diffIgnoreBlankLines");
const QLatin1String MercurialSettings::diffIgnoreWhiteSpaceKey("diffIgnoreWhiteSpace");
const QLatin1String MercurialSettings::diffIgnoreBlankLinesKey("diffIgnoreBlankLines");
MercurialSettings::MercurialSettings() :
diffIgnoreWhiteSpace(false),
diffIgnoreBlankLines(false)
MercurialSettings::MercurialSettings()
{
setSettingsGroup(QLatin1String("Mercurial"));
setDefaultBinary(QLatin1String(Constants::MERCURIALDEFAULT));
// Override default binary path
declareKey(binaryPathKey, QLatin1String(Constants::MERCURIALDEFAULT));
declareKey(diffIgnoreWhiteSpaceKey, false);
declareKey(diffIgnoreBlankLinesKey, false);
}
MercurialSettings& MercurialSettings::operator=(const MercurialSettings& other)
{
VCSBase::VCSBaseClientSettings::operator=(other);
if (this != &other) {
diffIgnoreWhiteSpace = other.diffIgnoreWhiteSpace;
diffIgnoreBlankLines = other.diffIgnoreBlankLines;
}
return *this;
}
void MercurialSettings::writeSettings(QSettings *settings) const
{
VCSBaseClientSettings::writeSettings(settings);
settings->beginGroup(this->settingsGroup());
settings->setValue(diffIgnoreWhiteSpaceKey, diffIgnoreWhiteSpace);
settings->setValue(diffIgnoreBlankLinesKey, diffIgnoreBlankLines);
settings->endGroup();
}
void MercurialSettings::readSettings(const QSettings *settings)
{
VCSBaseClientSettings::readSettings(settings);
const QString keyRoot = this->settingsGroup() + QLatin1Char('/');
diffIgnoreWhiteSpace = settings->value(keyRoot + diffIgnoreWhiteSpaceKey, false).toBool();
diffIgnoreBlankLines = settings->value(keyRoot + diffIgnoreBlankLinesKey, false).toBool();
}
bool MercurialSettings::equals(const VCSBaseClientSettings &rhs) const
{
const MercurialSettings *hgRhs = dynamic_cast<const MercurialSettings *>(&rhs);
if (hgRhs == 0)
return false;
return VCSBaseClientSettings::equals(rhs)
&& diffIgnoreWhiteSpace == hgRhs->diffIgnoreWhiteSpace
&& diffIgnoreBlankLines == hgRhs->diffIgnoreBlankLines;
}
} // namespace Internal
} // namespace Mercurial
......@@ -41,15 +41,10 @@ namespace Internal {
class MercurialSettings : public VCSBase::VCSBaseClientSettings
{
public:
MercurialSettings();
MercurialSettings& operator=(const MercurialSettings& other);
virtual void writeSettings(QSettings *settings) const;
virtual void readSettings(const QSettings *settings);
virtual bool equals(const VCSBaseClientSettings &rhs) const;
static const QLatin1String diffIgnoreWhiteSpaceKey;
static const QLatin1String diffIgnoreBlankLinesKey;
bool diffIgnoreWhiteSpace;
bool diffIgnoreBlankLines;
MercurialSettings();
};
} // namespace Internal
......
......@@ -53,24 +53,24 @@ OptionsPageWidget::OptionsPageWidget(QWidget *parent) :
MercurialSettings OptionsPageWidget::settings() const
{
MercurialSettings rc;
rc.setBinary(m_ui.commandChooser->path());
rc.setUserName(m_ui.defaultUsernameLineEdit->text().trimmed());
rc.setEmail(m_ui.defaultEmailLineEdit->text().trimmed());
rc.setLogCount(m_ui.logEntriesCount->value());
rc.setTimeoutSeconds(m_ui.timeout->value());
rc.setPrompt(m_ui.promptOnSubmitCheckBox->isChecked());
return rc;
MercurialSettings s = MercurialPlugin::instance()->settings();
s.setValue(MercurialSettings::binaryPathKey, m_ui.commandChooser->path());
s.setValue(MercurialSettings::userNameKey, m_ui.defaultUsernameLineEdit->text().trimmed());
s.setValue(MercurialSettings::userEmailKey, m_ui.defaultEmailLineEdit->text().trimmed());
s.setValue(MercurialSettings::logCountKey, m_ui.logEntriesCount->value());
s.setValue(MercurialSettings::timeoutKey, m_ui.timeout->value());
s.setValue(MercurialSettings::promptOnSubmitKey, m_ui.promptOnSubmitCheckBox->isChecked());
return s;
}
void OptionsPageWidget::setSettings(const MercurialSettings &s)
{
m_ui.commandChooser->setPath(s.binary());
m_ui.defaultUsernameLineEdit->setText(s.userName());
m_ui.defaultEmailLineEdit->setText(s.email());
m_ui.logEntriesCount->setValue(s.logCount());
m_ui.timeout->setValue(s.timeoutSeconds());
m_ui.promptOnSubmitCheckBox->setChecked(s.prompt());
m_ui.commandChooser->setPath(s.stringValue(MercurialSettings::binaryPathKey));
m_ui.defaultUsernameLineEdit->setText(s.stringValue(MercurialSettings::userNameKey));
m_ui.defaultEmailLineEdit->setText(s.stringValue(MercurialSettings::userEmailKey));
m_ui.logEntriesCount->setValue(s.intValue(MercurialSettings::logCountKey));
m_ui.timeout->setValue(s.intValue(MercurialSettings::timeoutKey));
m_ui.promptOnSubmitCheckBox->setChecked(s.boolValue(MercurialSettings::promptOnSubmitKey));
}
QString OptionsPageWidget::searchKeywords() const
......
......@@ -35,8 +35,6 @@
#include "vcsbaseclientsettings.h"
#include "vcsbaseeditorparameterwidget.h"
#include <QtDebug>
#include <coreplugin/icore.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/vcsmanager.h>
......@@ -88,6 +86,8 @@ public:
void annotateRevision(QString source, QString change, int lineNumber);
void saveSettings();
void updateJobRunnerSettings();
VCSJobRunner *m_jobManager;
Core::ICore *m_core;
VCSBaseClientSettings *m_clientSettings;
......@@ -132,6 +132,14 @@ void VCSBaseClientPrivate::saveSettings()
m_clientSettings->writeSettings(m_core->settings());
}
void VCSBaseClientPrivate::updateJobRunnerSettings()
{
if (m_jobManager && m_clientSettings) {
m_jobManager->setBinary(m_clientSettings->stringValue(VCSBaseClientSettings::binaryPathKey));
m_jobManager->setTimeoutMs(m_clientSettings->intValue(VCSBaseClientSettings::timeoutKey) * 1000);
}
}
VCSBaseClient::StatusItem::StatusItem()
{
}
......@@ -257,13 +265,12 @@ bool VCSBaseClient::vcsFullySynchronousExec(const QString &workingDir,
vcsProcess.setWorkingDirectory(workingDir);
VCSJobRunner::setProcessEnvironment(&vcsProcess);
const QString binary = settings()->binary();
const QStringList arguments = settings()->standardArguments() + args;
const QString binary = settings()->stringValue(VCSBaseClientSettings::binaryPathKey);
VCSBase::VCSBaseOutputWindow *outputWindow = VCSBase::VCSBaseOutputWindow::instance();
outputWindow->appendCommand(workingDir, binary, args);
vcsProcess.start(binary, arguments);
vcsProcess.start(binary, args);
if (!vcsProcess.waitForStarted()) {
outputWindow->appendError(VCSJobRunner::msgStartFailed(binary, vcsProcess.errorString()));
......@@ -273,10 +280,11 @@ bool VCSBaseClient::vcsFullySynchronousExec(const QString &workingDir,
vcsProcess.closeWriteChannel();
QByteArray stdErr;
if (!Utils::SynchronousProcess::readDataFromProcess(vcsProcess, settings()->timeoutMilliSeconds(),
const int timeoutSec = settings()->intValue(VCSBaseClientSettings::timeoutKey);
if (!Utils::SynchronousProcess::readDataFromProcess(vcsProcess, timeoutSec * 1000,
output, &stdErr, true)) {
Utils::SynchronousProcess::stopProcess(vcsProcess);
outputWindow->appendError(VCSJobRunner::msgTimeout(binary, settings()->timeoutSeconds()));
outputWindow->appendError(VCSJobRunner::msgTimeout(binary, timeoutSec));
return false;
}
if (!stdErr.isEmpty())
......@@ -291,11 +299,10 @@ Utils::SynchronousProcessResponse VCSBaseClient::vcsSynchronousExec(
unsigned flags,
QTextCodec *outputCodec)
{
const QString binary = settings()->binary();
const QStringList arguments = settings()->standardArguments() + args;
return VCSBase::VCSBasePlugin::runVCS(workingDirectory, binary, arguments,
settings()->timeoutMilliSeconds(),
flags, outputCodec);
const QString binary = settings()->stringValue(VCSBaseClientSettings::binaryPathKey);
const int timeoutSec = settings()->intValue(VCSBaseClientSettings::timeoutKey);
return VCSBase::VCSBasePlugin::runVCS(workingDirectory, binary, args,
timeoutSec * 1000, flags, outputCodec);
}
void VCSBaseClient::annotate(const QString &workingDir, const QString &file,
......@@ -509,9 +516,7 @@ VCSBaseClientSettings *VCSBaseClient::settings() const
void VCSBaseClient::handleSettingsChanged()
{
if (d->m_jobManager) {
d->m_jobManager->setSettings(settings()->binary(),
settings()->standardArguments(),
settings()->timeoutMilliSeconds());
d->updateJobRunnerSettings();
d->m_jobManager->restart();
}
}
......@@ -538,7 +543,8 @@ VCSBaseEditorParameterWidget *VCSBaseClient::createLogEditor(const QString &work
QString VCSBaseClient::vcsEditorTitle(const QString &vcsCmd, const QString &sourceId) const
{
return QFileInfo(settings()->binary()).baseName() +
const QString binary = settings()->stringValue(VCSBaseClientSettings::binaryPathKey);
return QFileInfo(binary).baseName() +
QLatin1Char(' ') + vcsCmd + QLatin1Char(' ') +
QFileInfo(sourceId).fileName();
}
......@@ -583,9 +589,7 @@ void VCSBaseClient::enqueueJob(const QSharedPointer<VCSJob> &job)
{
if (!d->m_jobManager) {
d->m_jobManager = new VCSJobRunner();
d->m_jobManager->setSettings(settings()->binary(),
settings()->standardArguments(),
settings()->timeoutMilliSeconds());
d->updateJobRunnerSettings();
d->m_jobManager->start();
}
d->m_jobManager->enqueueJob(job);
......
......@@ -36,6 +36,8 @@
#include "vcsbase_global.h"
#include <QtCore/QString>