Commit 7ffc4349 authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Tobias Hunger

VCS: Allow use of base name for executable

Actual path is found on startup and when setting is changed

Change-Id: If2cb0735953b9fb64df7425230c98efb384d9287
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent 2e989520
......@@ -67,7 +67,7 @@ bool BazaarControl::managesDirectory(const QString &directory, QString *topLevel
bool BazaarControl::isConfigured() const
{
const QString binary = m_bazaarClient->settings()->stringValue(BazaarSettings::binaryPathKey);
const QString binary = m_bazaarClient->settings()->binaryPath();
if (binary.isEmpty())
return false;
QFileInfo fi(binary);
......
......@@ -113,6 +113,6 @@ QSharedPointer<VcsBase::AbstractCheckoutJob> CloneWizard::createJob(const QList<
<< extraOptions << page->repository() << page->directory();
VcsBase::ProcessCheckoutJob *job = new VcsBase::ProcessCheckoutJob;
job->addStep(settings.stringValue(BazaarSettings::binaryPathKey), args, page->path());
job->addStep(settings.binaryPath(), args, page->path());
return QSharedPointer<VcsBase::AbstractCheckoutJob>(job);
}
......@@ -53,7 +53,7 @@ OptionsPageWidget::OptionsPageWidget(QWidget *parent)
BazaarSettings OptionsPageWidget::settings() const
{
BazaarSettings s = BazaarPlugin::instance()->settings();
s.setValue(BazaarSettings::binaryPathKey, m_ui.commandChooser->path());
s.setValue(BazaarSettings::binaryPathKey, m_ui.commandChooser->rawPath());
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());
......
......@@ -84,7 +84,7 @@ QSharedPointer<VcsBase::AbstractCheckoutJob> CheckoutWizard::createJob(const QLi
const CheckoutWizardPage *cwp = qobject_cast<const CheckoutWizardPage *>(parameterPages.front());
QTC_ASSERT(cwp, return QSharedPointer<VcsBase::AbstractCheckoutJob>());
const CvsSettings settings = CvsPlugin::instance()->settings();
const QString binary = settings.cvsCommand;
const QString binary = settings.cvsBinaryPath;
QStringList args;
const QString repository = cwp->repository();
args << QLatin1String("checkout") << repository;
......
......@@ -56,7 +56,7 @@ Core::Id CvsControl::id() const
bool CvsControl::isConfigured() const
{
const QString binary = m_plugin->settings().cvsCommand;
const QString binary = m_plugin->settings().cvsBinaryPath;
if (binary.isEmpty())
return false;
QFileInfo fi(binary);
......
......@@ -1229,7 +1229,7 @@ CvsResponse CvsPlugin::runCvs(const QString &workingDirectory,
unsigned flags,
QTextCodec *outputCodec)
{
const QString executable = m_settings.cvsCommand;
const QString executable = m_settings.cvsBinaryPath;
CvsResponse response;
if (executable.isEmpty()) {
response.result = CvsResponse::OtherError;
......
......@@ -30,6 +30,8 @@
#include "cvssettings.h"
#include <utils/environment.h>
#include <QSettings>
#include <QTextStream>
......@@ -70,6 +72,7 @@ void CvsSettings::fromSettings(QSettings *settings)
{
settings->beginGroup(QLatin1String(groupC));
cvsCommand = settings->value(QLatin1String(commandKeyC), defaultCommand()).toString();
cvsBinaryPath = Utils::Environment::systemEnvironment().searchInPath(cvsCommand);
promptToSubmit = settings->value(QLatin1String(promptToSubmitKeyC), true).toBool();
cvsRoot = settings->value(QLatin1String(rootC), QString()).toString();
cvsDiffOptions = settings->value(QLatin1String(diffOptionsKeyC), QLatin1String(defaultDiffOptions)).toString();
......
......@@ -56,6 +56,7 @@ struct CvsSettings
bool equals(const CvsSettings &s) const;
QString cvsCommand;
QString cvsBinaryPath;
QString cvsRoot;
QString cvsDiffOptions;
int timeOutS;
......
......@@ -55,7 +55,8 @@ SettingsPageWidget::SettingsPageWidget(QWidget *parent) :
CvsSettings SettingsPageWidget::settings() const
{
CvsSettings rc;
rc.cvsCommand = m_ui.commandPathChooser->path();
rc.cvsCommand = m_ui.commandPathChooser->rawPath();
rc.cvsBinaryPath = m_ui.commandPathChooser->path();
rc.cvsRoot = m_ui.rootLineEdit->text();
rc.cvsDiffOptions = m_ui.diffOptionsLineEdit->text();
rc.timeOutS = m_ui.timeOutSpinBox->value();
......
......@@ -82,7 +82,7 @@ QString GitSettings::gitBinaryPath(bool *ok, QString *errorMessage) const
errorMessage->clear();
if (m_binaryPath.isEmpty()) {
const QString binary = stringValue(binaryPathKey);
const QString binary = binaryPath();
QString currentPath = stringValue(pathKey);
QString systemPath = QString::fromLocal8Bit(qgetenv("PATH"));
if (!systemPath.isEmpty()) {
......
......@@ -92,6 +92,6 @@ QSharedPointer<AbstractCheckoutJob> CloneWizard::createJob(const QList<QWizardPa
args << QLatin1String("clone") << page->repository() << directory;
*checkoutPath = path + QLatin1Char('/') + directory;
ProcessCheckoutJob *job = new ProcessCheckoutJob;
job->addStep(settings.stringValue(MercurialSettings::binaryPathKey), args, path);
job->addStep(settings.binaryPath(), args, path);
return QSharedPointer<AbstractCheckoutJob>(job);
}
......@@ -67,7 +67,7 @@ bool MercurialControl::managesDirectory(const QString &directory, QString *topLe
bool MercurialControl::isConfigured() const
{
const QString binary = mercurialClient->settings()->stringValue(MercurialSettings::binaryPathKey);
const QString binary = mercurialClient->settings()->binaryPath();
if (binary.isEmpty())
return false;
QFileInfo fi(binary);
......
......@@ -52,7 +52,7 @@ OptionsPageWidget::OptionsPageWidget(QWidget *parent) :
MercurialSettings OptionsPageWidget::settings() const
{
MercurialSettings s = MercurialPlugin::instance()->settings();
s.setValue(MercurialSettings::binaryPathKey, m_ui.commandChooser->path());
s.setValue(MercurialSettings::binaryPathKey, m_ui.commandChooser->rawPath());
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());
......
......@@ -1013,7 +1013,7 @@ PerforceResponse PerforcePlugin::synchronousProcess(const QString &workingDir,
if (Perforce::Constants::debug)
qDebug() << "PerforcePlugin::run syncp actual args [" << process.workingDirectory() << ']' << args;
process.setTimeOutMessageBoxEnabled(true);
const Utils::SynchronousProcessResponse sp_resp = process.run(m_settings.p4Command(), args);
const Utils::SynchronousProcessResponse sp_resp = process.run(m_settings.p4BinaryPath(), args);
if (Perforce::Constants::debug)
qDebug() << sp_resp;
......@@ -1034,7 +1034,7 @@ PerforceResponse PerforcePlugin::synchronousProcess(const QString &workingDir,
response.message = msgCrash();
break;
case Utils::SynchronousProcessResponse::StartFailed:
response.message = msgNotStarted(m_settings.p4Command());
response.message = msgNotStarted(m_settings.p4BinaryPath());
break;
case Utils::SynchronousProcessResponse::Hang:
response.message = msgCrash();
......@@ -1061,13 +1061,13 @@ PerforceResponse PerforcePlugin::fullySynchronousProcess(const QString &workingD
qDebug() << "PerforcePlugin::run fully syncp actual args [" << process.workingDirectory() << ']' << args;
PerforceResponse response;
process.start(m_settings.p4Command(), args);
process.start(m_settings.p4BinaryPath(), args);
if (stdInput.isEmpty())
process.closeWriteChannel();
if (!process.waitForStarted(3000)) {
response.error = true;
response.message = msgNotStarted(m_settings.p4Command());
response.message = msgNotStarted(m_settings.p4BinaryPath());
return response;
}
if (!stdInput.isEmpty()) {
......@@ -1075,7 +1075,7 @@ PerforceResponse PerforcePlugin::fullySynchronousProcess(const QString &workingD
Utils::SynchronousProcess::stopProcess(process);
response.error = true;
response.message = tr("Unable to write input data to process %1: %2").
arg(QDir::toNativeSeparators(m_settings.p4Command()),
arg(QDir::toNativeSeparators(m_settings.p4BinaryPath()),
process.errorString());
return response;
}
......@@ -1145,7 +1145,7 @@ PerforceResponse PerforcePlugin::runP4Cmd(const QString &workingDir,
actualArgs.append(args);
if (flags & CommandToWindow)
outputWindow->appendCommand(workingDir, m_settings.p4Command(), actualArgs);
outputWindow->appendCommand(workingDir, m_settings.p4BinaryPath(), actualArgs);
if (flags & ShowBusyCursor)
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
......@@ -1520,14 +1520,14 @@ void PerforcePlugin::slotTopLevelFailed(const QString &errorMessage)
void PerforcePlugin::getTopLevel()
{
// Run a new checker
if (m_settings.p4Command().isEmpty())
if (m_settings.p4BinaryPath().isEmpty())
return;
PerforceChecker *checker = new PerforceChecker(this);
connect(checker, SIGNAL(failed(QString)), this, SLOT(slotTopLevelFailed(QString)));
connect(checker, SIGNAL(failed(QString)), checker, SLOT(deleteLater()));
connect(checker, SIGNAL(succeeded(QString)), this, SLOT(slotTopLevelFound(QString)));
connect(checker, SIGNAL(succeeded(QString)),checker, SLOT(deleteLater()));
checker->start(m_settings.p4Command(), m_settings.commonP4Arguments(QString()), 30000);
checker->start(m_settings.p4BinaryPath(), m_settings.commonP4Arguments(QString()), 30000);
}
}
......
......@@ -57,13 +57,12 @@ enum { defaultTimeOutS = 30, defaultLogCount = 1000 };
static QString defaultCommand()
{
Utils::Environment env = Utils::Environment::systemEnvironment();
QString rc;
rc = QLatin1String("p4");
#if defined(Q_OS_WIN32)
rc.append(QLatin1String(".exe"));
#endif
return env.searchInPath(rc);
return rc;
}
namespace Perforce {
......@@ -115,6 +114,7 @@ void PerforceSettings::fromSettings(QSettings *settings)
{
settings->beginGroup(QLatin1String(groupC));
m_settings.p4Command = settings->value(QLatin1String(commandKeyC), defaultCommand()).toString();
m_settings.p4BinaryPath = Utils::Environment::systemEnvironment().searchInPath(m_settings.p4Command);
m_settings.defaultEnv = settings->value(QLatin1String(defaultKeyC), true).toBool();
m_settings.p4Port = settings->value(QLatin1String(portKeyC), QString()).toString();
m_settings.p4Client = settings->value(QLatin1String(clientKeyC), QString()).toString();
......@@ -159,6 +159,11 @@ QString PerforceSettings::p4Command() const
return m_settings.p4Command;
}
QString PerforceSettings::p4BinaryPath() const
{
return m_settings.p4BinaryPath;
}
QString PerforceSettings::p4Port() const
{
return m_settings.p4Port;
......
......@@ -54,6 +54,7 @@ struct Settings {
QString *errorMessage);
QString p4Command;
QString p4BinaryPath;
QString p4Port;
QString p4Client;
QString p4User;
......@@ -92,7 +93,7 @@ public:
inline bool isValid() const
{
return !m_topLevel.isEmpty() && !m_settings.p4Command.isEmpty();
return !m_topLevel.isEmpty() && !m_settings.p4BinaryPath.isEmpty();
}
void fromSettings(QSettings *settings);
......@@ -123,6 +124,7 @@ public:
QString mapToFileSystem(const QString &perforceFilePath) const;
QString p4Command() const;
QString p4BinaryPath() const;
QString p4Port() const;
QString p4Client() const;
QString p4User() const;
......
......@@ -58,7 +58,7 @@ Core::Id PerforceVersionControl::id() const
bool PerforceVersionControl::isConfigured() const
{
const QString binary = m_plugin->settings().p4Command();
const QString binary = m_plugin->settings().p4BinaryPath();
if (binary.isEmpty())
return false;
QFileInfo fi(binary);
......
......@@ -67,7 +67,7 @@ void SettingsPageWidget::slotTest()
setStatusText(tr("Testing..."));
const Settings s = settings();
m_checker->start(s.p4Command, s.commonP4Arguments(), 10000);
m_checker->start(s.p4BinaryPath, s.commonP4Arguments(), 10000);
}
void SettingsPageWidget::testSucceeded(const QString &repo)
......@@ -78,7 +78,8 @@ void SettingsPageWidget::testSucceeded(const QString &repo)
Settings SettingsPageWidget::settings() const
{
Settings settings;
settings.p4Command = m_ui.pathChooser->path();
settings.p4Command = m_ui.pathChooser->rawPath();
settings.p4BinaryPath = m_ui.pathChooser->path();
settings.defaultEnv = !m_ui.environmentGroupBox->isChecked();
settings.p4Port = m_ui.portLineEdit->text();
settings.p4User = m_ui.userLineEdit->text();
......
......@@ -83,7 +83,7 @@ QSharedPointer<VcsBase::AbstractCheckoutJob> CheckoutWizard::createJob(const QLi
const CheckoutWizardPage *cwp = qobject_cast<const CheckoutWizardPage *>(parameterPages.front());
QTC_ASSERT(cwp, return QSharedPointer<VcsBase::AbstractCheckoutJob>());
const SubversionSettings settings = SubversionPlugin::instance()->settings();
const QString binary = settings.svnCommand;
const QString binary = settings.svnBinaryPath;
const QString directory = cwp->directory();
QStringList args;
args << QLatin1String("checkout") << cwp->repository() << directory;
......
......@@ -55,7 +55,8 @@ SettingsPageWidget::SettingsPageWidget(QWidget *parent) :
SubversionSettings SettingsPageWidget::settings() const
{
SubversionSettings rc;
rc.svnCommand = m_ui.pathChooser->path();
rc.svnCommand = m_ui.pathChooser->rawPath();
rc.svnBinaryPath = m_ui.pathChooser->path();
rc.useAuthentication = m_ui.userGroupBox->isChecked();
rc.user = m_ui.usernameLineEdit->text();
rc.password = m_ui.passwordLineEdit->text();
......
......@@ -56,7 +56,7 @@ Core::Id SubversionControl::id() const
bool SubversionControl::isConfigured() const
{
const QString binary = m_plugin->settings().svnCommand;
const QString binary = m_plugin->settings().svnBinaryPath;
if (binary.isEmpty())
return false;
QFileInfo fi(binary);
......
......@@ -1120,7 +1120,7 @@ SubversionResponse SubversionPlugin::runSvn(const QString &workingDir,
const QStringList &arguments, int timeOut,
unsigned flags, QTextCodec *outputCodec)
{
const QString executable = m_settings.svnCommand;
const QString executable = m_settings.svnBinaryPath;
SubversionResponse response;
if (executable.isEmpty()) {
response.error = true;
......
......@@ -30,6 +30,8 @@
#include "subversionsettings.h"
#include <utils/environment.h>
#include <QSettings>
static const char groupC[] = "Subversion";
......@@ -71,6 +73,7 @@ void SubversionSettings::fromSettings(QSettings *settings)
{
settings->beginGroup(QLatin1String(groupC));
svnCommand = settings->value(QLatin1String(commandKeyC), defaultCommand()).toString();
svnBinaryPath = Utils::Environment::systemEnvironment().searchInPath(svnCommand);
useAuthentication = settings->value(QLatin1String(authenticationKeyC), QVariant(false)).toBool();
user = settings->value(QLatin1String(userKeyC), QString()).toString();
password = settings->value(QLatin1String(passwordKeyC), QString()).toString();
......
......@@ -55,6 +55,7 @@ struct SubversionSettings
bool equals(const SubversionSettings &s) const;
QString svnCommand;
QString svnBinaryPath;
bool useAuthentication;
QString user;
QString password;
......
......@@ -282,7 +282,7 @@ bool VcsBaseClient::vcsFullySynchronousExec(const QString &workingDir,
vcsProcess.setWorkingDirectory(workingDir);
vcsProcess.setProcessEnvironment(processEnvironment());
const QString binary = settings()->stringValue(VcsBaseClientSettings::binaryPathKey);
const QString binary = settings()->binaryPath();
::vcsOutputWindow()->appendCommand(workingDir, binary, args);
......@@ -317,7 +317,7 @@ Utils::SynchronousProcessResponse VcsBaseClient::vcsSynchronousExec(
unsigned flags,
QTextCodec *outputCodec)
{
const QString binary = settings()->stringValue(VcsBaseClientSettings::binaryPathKey);
const QString binary = settings()->binaryPath();
const int timeoutSec = settings()->intValue(VcsBaseClientSettings::timeoutKey);
return VcsBase::VcsBasePlugin::runVcs(workingDirectory, binary, args,
timeoutSec * 1000, flags, outputCodec);
......@@ -545,7 +545,7 @@ VcsBaseEditorParameterWidget *VcsBaseClient::createLogEditor(const QString &work
QString VcsBaseClient::vcsEditorTitle(const QString &vcsCmd, const QString &sourceId) const
{
const QString binary = settings()->stringValue(VcsBaseClientSettings::binaryPathKey);
const QString binary = settings()->binaryPath();
return QFileInfo(binary).baseName() +
QLatin1Char(' ') + vcsCmd + QLatin1Char(' ') +
QFileInfo(sourceId).fileName();
......@@ -592,7 +592,7 @@ Command *VcsBaseClient::createCommand(const QString &workingDirectory,
VcsBase::VcsBaseEditorWidget *editor,
JobOutputBindMode mode)
{
Command *cmd = new Command(d->m_clientSettings->stringValue(VcsBaseClientSettings::binaryPathKey),
Command *cmd = new Command(d->m_clientSettings->binaryPath(),
workingDirectory, processEnvironment());
cmd->setDefaultTimeout(d->m_clientSettings->intValue(VcsBaseClientSettings::timeoutKey));
if (editor)
......@@ -620,7 +620,7 @@ Command *VcsBaseClient::createCommand(const QString &workingDirectory,
void VcsBaseClient::enqueueJob(Command *cmd, const QStringList &args)
{
const QString binary = QFileInfo(d->m_clientSettings->stringValue(VcsBaseClientSettings::binaryPathKey)).baseName();
const QString binary = QFileInfo(d->m_clientSettings->binaryPath()).baseName();
::vcsOutputWindow()->appendCommand(cmd->workingDirectory(), binary, args);
cmd->addJob(args);
cmd->execute();
......
......@@ -30,6 +30,8 @@
#include "vcsbaseclientsettings.h"
#include <utils/environment.h>
#include <QSettings>
namespace {
......@@ -165,13 +167,15 @@ public:
QSharedData(other),
m_valueHash(other.m_valueHash),
m_defaultValueHash(other.m_defaultValueHash),
m_settingsGroup(other.m_settingsGroup)
m_settingsGroup(other.m_settingsGroup),
m_binaryFullPath(other.m_binaryFullPath)
{
}
QHash<QString, SettingValue> m_valueHash;
QVariantHash m_defaultValueHash;
QString m_settingsGroup;
QString m_binaryFullPath;
};
} // namespace Internal
......@@ -326,8 +330,11 @@ QVariant VcsBaseClientSettings::value(const QString &key) const
void VcsBaseClientSettings::setValue(const QString &key, const QVariant &v)
{
if (SettingValue::isUsableVariantType(valueType(key)))
if (SettingValue::isUsableVariantType(valueType(key))) {
d->m_valueHash.insert(key, SettingValue(v));
if (key == binaryPathKey)
d->m_binaryFullPath = Utils::Environment::systemEnvironment().searchInPath(v.toString());
}
}
QVariant::Type VcsBaseClientSettings::valueType(const QString &key) const
......@@ -337,6 +344,11 @@ QVariant::Type VcsBaseClientSettings::valueType(const QString &key) const
return QVariant::Invalid;
}
QString VcsBaseClientSettings::binaryPath() const
{
return d->m_binaryFullPath;
}
QString VcsBaseClientSettings::settingsGroup() const
{
return d->m_settingsGroup;
......
......@@ -81,6 +81,8 @@ public:
void setValue(const QString &key, const QVariant &v);
QVariant::Type valueType(const QString &key) const;
QString binaryPath() const;
protected:
QString settingsGroup() const;
void setSettingsGroup(const QString &group);
......
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