forked from qt-creator/qt-creator
VCS: Do not claim to support any operation if unconfigured
Make sure none of the VCS systems claims it does support any VCS operation while unconfigured. This stops the specific VCS from showing up in wizards, etc. till they can actually be used.
This commit is contained in:
@@ -33,6 +33,8 @@
|
||||
#include "bazaarcontrol.h"
|
||||
#include "bazaarclient.h"
|
||||
|
||||
#include <vcsbase/vcsbaseclientsettings.h>
|
||||
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtCore/QStringList>
|
||||
@@ -59,9 +61,19 @@ bool BazaarControl::managesDirectory(const QString &directory, QString *topLevel
|
||||
return !topLevelFound.isEmpty();
|
||||
}
|
||||
|
||||
bool BazaarControl::isConfigured() const
|
||||
{
|
||||
const QString binary = m_bazaarClient->settings().binary();
|
||||
if (binary.isEmpty())
|
||||
return false;
|
||||
QFileInfo fi(binary);
|
||||
return fi.exists() && fi.isFile() && fi.isExecutable();
|
||||
}
|
||||
|
||||
bool BazaarControl::supportsOperation(Operation operation) const
|
||||
{
|
||||
bool supported = true;
|
||||
bool supported = isConfigured();
|
||||
|
||||
switch (operation) {
|
||||
case Core::IVersionControl::AddOperation:
|
||||
case Core::IVersionControl::DeleteOperation:
|
||||
|
@@ -54,6 +54,7 @@ public:
|
||||
|
||||
QString displayName() const;
|
||||
bool managesDirectory(const QString &filename, QString *topLevel = 0) const;
|
||||
bool isConfigured() const;
|
||||
bool supportsOperation(Operation operation) const;
|
||||
bool vcsOpen(const QString &fileName);
|
||||
bool vcsAdd(const QString &filename);
|
||||
|
@@ -75,8 +75,14 @@ public:
|
||||
|
||||
virtual bool managesDirectory(const QString &filename, QString *topLevel = 0) const = 0;
|
||||
|
||||
/*!
|
||||
* Returns true is the VCS is configured to run.
|
||||
*/
|
||||
virtual bool isConfigured() const = 0;
|
||||
/*!
|
||||
* Called to query whether a VCS supports the respective operations.
|
||||
*
|
||||
* Return false if the VCS is not configured yet.
|
||||
*/
|
||||
virtual bool supportsOperation(Operation operation) const = 0;
|
||||
|
||||
|
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "cvscontrol.h"
|
||||
#include "cvsplugin.h"
|
||||
#include "cvssettings.h"
|
||||
|
||||
#include <QtCore/QFileInfo>
|
||||
|
||||
@@ -48,9 +49,18 @@ QString CVSControl::displayName() const
|
||||
return QLatin1String("cvs");
|
||||
}
|
||||
|
||||
bool CVSControl::isConfigured() const
|
||||
{
|
||||
const QString binary = m_plugin->settings().cvsCommand;
|
||||
if (binary.isEmpty())
|
||||
return false;
|
||||
QFileInfo fi(binary);
|
||||
return fi.exists() && fi.isFile() && fi.isExecutable();
|
||||
}
|
||||
|
||||
bool CVSControl::supportsOperation(Operation operation) const
|
||||
{
|
||||
bool rc = true;
|
||||
bool rc = isConfigured();
|
||||
switch (operation) {
|
||||
case AddOperation:
|
||||
case DeleteOperation:
|
||||
|
@@ -50,6 +50,7 @@ public:
|
||||
|
||||
bool managesDirectory(const QString &directory, QString *topLevel = 0) const;
|
||||
|
||||
bool isConfigured() const;
|
||||
bool supportsOperation(Operation operation) const;
|
||||
bool vcsOpen(const QString &fileName);
|
||||
bool vcsAdd(const QString &fileName);
|
||||
|
@@ -277,13 +277,14 @@ bool GitPlugin::initialize(const QStringList &arguments, QString *errorMessage)
|
||||
Q_UNUSED(arguments)
|
||||
Q_UNUSED(errorMessage)
|
||||
|
||||
m_core = Core::ICore::instance();
|
||||
m_gitClient = new GitClient(this);
|
||||
|
||||
typedef VCSBase::VCSEditorFactory<GitEditor> GitEditorFactory;
|
||||
typedef VCSBase::VCSSubmitEditorFactory<GitSubmitEditor> GitSubmitEditorFactory;
|
||||
|
||||
VCSBase::VCSBasePlugin::initialize(new GitVersionControl(m_gitClient));
|
||||
|
||||
m_core = Core::ICore::instance();
|
||||
m_gitClient = new GitClient(this);
|
||||
// Create the globalcontext list to register actions accordingly
|
||||
Core::Context globalcontext(Core::Constants::C_GLOBAL);
|
||||
|
||||
|
@@ -46,13 +46,7 @@ static const char stashRevisionIdC[] = "revision";
|
||||
namespace Git {
|
||||
namespace Internal {
|
||||
|
||||
static inline GitClient *gitClient()
|
||||
{
|
||||
return GitPlugin::instance()->gitClient();
|
||||
}
|
||||
|
||||
GitVersionControl::GitVersionControl(GitClient *client) :
|
||||
m_enabled(true),
|
||||
m_client(client)
|
||||
{
|
||||
}
|
||||
@@ -62,18 +56,22 @@ QString GitVersionControl::displayName() const
|
||||
return QLatin1String("git");
|
||||
}
|
||||
|
||||
// Add: Implement using "git add --intent-to-add" starting from 1.6.1
|
||||
static inline bool addOperationSupported()
|
||||
bool GitVersionControl::isConfigured() const
|
||||
{
|
||||
return gitClient()->gitVersion(true) >= version(1, 6, 1);
|
||||
bool ok = false;
|
||||
m_client->settings().gitBinaryPath(&ok);
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool GitVersionControl::supportsOperation(Operation operation) const
|
||||
{
|
||||
if (!isConfigured())
|
||||
return false;
|
||||
|
||||
bool rc = false;
|
||||
switch (operation) {
|
||||
case AddOperation:
|
||||
rc = addOperationSupported();
|
||||
rc = m_client->gitVersion(true) >= version(1, 6, 1);;
|
||||
break;
|
||||
case DeleteOperation:
|
||||
rc = true;
|
||||
@@ -106,37 +104,37 @@ bool GitVersionControl::vcsOpen(const QString & /*fileName*/)
|
||||
bool GitVersionControl::vcsAdd(const QString & fileName)
|
||||
{
|
||||
// Implement in terms of using "--intent-to-add"
|
||||
QTC_ASSERT(addOperationSupported(), return false);
|
||||
QTC_ASSERT(m_client->gitVersion(true) >= version(1, 6, 1), return false);
|
||||
const QFileInfo fi(fileName);
|
||||
return gitClient()->synchronousAdd(fi.absolutePath(), true, QStringList(fi.fileName()));
|
||||
return m_client->synchronousAdd(fi.absolutePath(), true, QStringList(fi.fileName()));
|
||||
}
|
||||
|
||||
bool GitVersionControl::vcsDelete(const QString & fileName)
|
||||
{
|
||||
const QFileInfo fi(fileName);
|
||||
return gitClient()->synchronousDelete(fi.absolutePath(), true, QStringList(fi.fileName()));
|
||||
return m_client->synchronousDelete(fi.absolutePath(), true, QStringList(fi.fileName()));
|
||||
}
|
||||
|
||||
bool GitVersionControl::vcsMove(const QString &from, const QString &to)
|
||||
{
|
||||
const QFileInfo fromInfo(from);
|
||||
const QFileInfo toInfo(to);
|
||||
return gitClient()->synchronousMove(fromInfo.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath());
|
||||
return m_client->synchronousMove(fromInfo.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath());
|
||||
}
|
||||
|
||||
bool GitVersionControl::vcsCreateRepository(const QString &directory)
|
||||
{
|
||||
return gitClient()->synchronousInit(directory);
|
||||
return m_client->synchronousInit(directory);
|
||||
}
|
||||
|
||||
bool GitVersionControl::vcsCheckout(const QString &directory, const QByteArray &url)
|
||||
{
|
||||
return gitClient()->cloneRepository(directory,url);
|
||||
return m_client->cloneRepository(directory,url);
|
||||
}
|
||||
|
||||
QString GitVersionControl::vcsGetRepositoryURL(const QString &directory)
|
||||
{
|
||||
return gitClient()->vcsGetRepositoryURL(directory);
|
||||
return m_client->vcsGetRepositoryURL(directory);
|
||||
}
|
||||
|
||||
/* Snapshots are implement using stashes, relying on stash messages for
|
||||
@@ -153,7 +151,7 @@ QString GitVersionControl::vcsCreateSnapshot(const QString &topLevel)
|
||||
static int n = 1;
|
||||
QString keyword = QLatin1String(stashMessageKeywordC) + QString::number(n++);
|
||||
const QString stashMessage =
|
||||
gitClient()->synchronousStash(topLevel, keyword,
|
||||
m_client->synchronousStash(topLevel, keyword,
|
||||
GitClient::StashImmediateRestore|GitClient::StashIgnoreUnchanged,
|
||||
&repositoryUnchanged);
|
||||
if (!stashMessage.isEmpty())
|
||||
@@ -162,7 +160,7 @@ QString GitVersionControl::vcsCreateSnapshot(const QString &topLevel)
|
||||
// For unchanged repository state: return identifier + top revision
|
||||
QString topRevision;
|
||||
QString branch;
|
||||
if (!gitClient()->synchronousTopRevision(topLevel, &topRevision, &branch))
|
||||
if (!m_client->synchronousTopRevision(topLevel, &topRevision, &branch))
|
||||
return QString();
|
||||
const QChar colon = QLatin1Char(':');
|
||||
QString id = QLatin1String(stashRevisionIdC);
|
||||
@@ -178,7 +176,7 @@ QString GitVersionControl::vcsCreateSnapshot(const QString &topLevel)
|
||||
QStringList GitVersionControl::vcsSnapshots(const QString &topLevel)
|
||||
{
|
||||
QList<Stash> stashes;
|
||||
if (!gitClient()->synchronousStashList(topLevel, &stashes))
|
||||
if (!m_client->synchronousStashList(topLevel, &stashes))
|
||||
return QStringList();
|
||||
// Return the git stash 'message' as identifier, ignoring empty ones
|
||||
QStringList rc;
|
||||
@@ -200,15 +198,15 @@ bool GitVersionControl::vcsRestoreSnapshot(const QString &topLevel, const QStrin
|
||||
break;
|
||||
const QString branch = tokens.at(1);
|
||||
const QString revision = tokens.at(2);
|
||||
success = gitClient()->synchronousReset(topLevel)
|
||||
&& gitClient()->synchronousCheckoutBranch(topLevel, branch)
|
||||
&& gitClient()->synchronousCheckoutFiles(topLevel, QStringList(), revision);
|
||||
success = m_client->synchronousReset(topLevel)
|
||||
&& m_client->synchronousCheckoutBranch(topLevel, branch)
|
||||
&& m_client->synchronousCheckoutFiles(topLevel, QStringList(), revision);
|
||||
} else {
|
||||
// Restore stash if it can be resolved.
|
||||
QString stashName;
|
||||
success = gitClient()->stashNameFromMessage(topLevel, name, &stashName)
|
||||
&& gitClient()->synchronousReset(topLevel)
|
||||
&& gitClient()->synchronousStashRestore(topLevel, stashName);
|
||||
success = m_client->stashNameFromMessage(topLevel, name, &stashName)
|
||||
&& m_client->synchronousReset(topLevel)
|
||||
&& m_client->synchronousStashRestore(topLevel, stashName);
|
||||
}
|
||||
} while (false);
|
||||
return success;
|
||||
@@ -220,8 +218,8 @@ bool GitVersionControl::vcsRemoveSnapshot(const QString &topLevel, const QString
|
||||
if (name.startsWith(QLatin1String(stashRevisionIdC)))
|
||||
return true;
|
||||
QString stashName;
|
||||
return gitClient()->stashNameFromMessage(topLevel, name, &stashName)
|
||||
&& gitClient()->synchronousStashRemove(topLevel, stashName);
|
||||
return m_client->stashNameFromMessage(topLevel, name, &stashName)
|
||||
&& m_client->synchronousStashRemove(topLevel, stashName);
|
||||
}
|
||||
|
||||
bool GitVersionControl::managesDirectory(const QString &directory, QString *topLevel) const
|
||||
@@ -235,7 +233,7 @@ bool GitVersionControl::managesDirectory(const QString &directory, QString *topL
|
||||
bool GitVersionControl::vcsAnnotate(const QString &file, int line)
|
||||
{
|
||||
const QFileInfo fi(file);
|
||||
gitClient()->blame(fi.absolutePath(), QStringList(), fi.fileName(), QString(), line);
|
||||
m_client->blame(fi.absolutePath(), QStringList(), fi.fileName(), QString(), line);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -51,6 +51,7 @@ public:
|
||||
|
||||
bool managesDirectory(const QString &directory, QString *topLevel) const;
|
||||
|
||||
bool isConfigured() const;
|
||||
bool supportsOperation(Operation operation) const;
|
||||
bool vcsOpen(const QString &fileName);
|
||||
bool vcsAdd(const QString &fileName);
|
||||
@@ -70,7 +71,6 @@ public:
|
||||
void emitRepositoryChanged(const QString &);
|
||||
|
||||
private:
|
||||
bool m_enabled;
|
||||
GitClient *m_client;
|
||||
};
|
||||
|
||||
|
@@ -33,6 +33,8 @@
|
||||
#include "mercurialcontrol.h"
|
||||
#include "mercurialclient.h"
|
||||
|
||||
#include <vcsbase/vcsbaseclientsettings.h>
|
||||
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QVariant>
|
||||
#include <QtCore/QStringList>
|
||||
@@ -59,9 +61,18 @@ bool MercurialControl::managesDirectory(const QString &directory, QString *topLe
|
||||
return !topLevelFound.isEmpty();
|
||||
}
|
||||
|
||||
bool MercurialControl::isConfigured() const
|
||||
{
|
||||
const QString binary = mercurialClient->settings().binary();
|
||||
if (binary.isEmpty())
|
||||
return false;
|
||||
QFileInfo fi(binary);
|
||||
return fi.exists() && fi.isFile() && fi.isExecutable();
|
||||
}
|
||||
|
||||
bool MercurialControl::supportsOperation(Operation operation) const
|
||||
{
|
||||
bool supported = true;
|
||||
bool supported = isConfigured();
|
||||
switch (operation) {
|
||||
case Core::IVersionControl::AddOperation:
|
||||
case Core::IVersionControl::DeleteOperation:
|
||||
|
@@ -54,6 +54,7 @@ public:
|
||||
|
||||
QString displayName() const;
|
||||
bool managesDirectory(const QString &filename, QString *topLevel = 0) const;
|
||||
bool isConfigured() const;
|
||||
bool supportsOperation(Operation operation) const;
|
||||
bool vcsOpen(const QString &fileName);
|
||||
bool vcsAdd(const QString &filename);
|
||||
|
@@ -33,6 +33,7 @@
|
||||
#include "perforceversioncontrol.h"
|
||||
#include "perforceplugin.h"
|
||||
#include "perforceconstants.h"
|
||||
#include "perforcesettings.h"
|
||||
|
||||
#include <QtCore/QFileInfo>
|
||||
#include <QtCore/QDebug>
|
||||
@@ -41,7 +42,6 @@ namespace Perforce {
|
||||
namespace Internal {
|
||||
|
||||
PerforceVersionControl::PerforceVersionControl(PerforcePlugin *plugin) :
|
||||
m_enabled(true),
|
||||
m_plugin(plugin)
|
||||
{
|
||||
}
|
||||
@@ -51,15 +51,25 @@ QString PerforceVersionControl::displayName() const
|
||||
return QLatin1String("perforce");
|
||||
}
|
||||
|
||||
bool PerforceVersionControl::isConfigured() const
|
||||
{
|
||||
const QString binary = m_plugin->settings().p4Command();
|
||||
if (binary.isEmpty())
|
||||
return false;
|
||||
QFileInfo fi(binary);
|
||||
return fi.exists() && fi.isFile() && fi.isExecutable();
|
||||
}
|
||||
|
||||
bool PerforceVersionControl::supportsOperation(Operation operation) const
|
||||
{
|
||||
bool supported = isConfigured();
|
||||
switch (operation) {
|
||||
case AddOperation:
|
||||
case DeleteOperation:
|
||||
case MoveOperation:
|
||||
case OpenOperation:
|
||||
case AnnotateOperation:
|
||||
return true;
|
||||
return supported;
|
||||
case CreateRepositoryOperation:
|
||||
case SnapshotOperations:
|
||||
case CheckoutOperation:
|
||||
|
@@ -50,7 +50,7 @@ public:
|
||||
|
||||
bool managesDirectory(const QString &directory, QString *topLevel = 0) const;
|
||||
|
||||
|
||||
bool isConfigured() const;
|
||||
bool supportsOperation(Operation operation) const;
|
||||
bool vcsOpen(const QString &fileName);
|
||||
SettingsFlags settingsFlags() const;
|
||||
|
@@ -32,6 +32,7 @@
|
||||
|
||||
#include "subversioncontrol.h"
|
||||
#include "subversionplugin.h"
|
||||
#include "subversionsettings.h"
|
||||
|
||||
#include <QtCore/QFileInfo>
|
||||
|
||||
@@ -48,9 +49,18 @@ QString SubversionControl::displayName() const
|
||||
return QLatin1String("subversion");
|
||||
}
|
||||
|
||||
bool SubversionControl::isConfigured() const
|
||||
{
|
||||
const QString binary = m_plugin->settings().svnCommand;
|
||||
if (binary.isEmpty())
|
||||
return false;
|
||||
QFileInfo fi(binary);
|
||||
return fi.exists() && fi.isFile() && fi.isExecutable();
|
||||
}
|
||||
|
||||
bool SubversionControl::supportsOperation(Operation operation) const
|
||||
{
|
||||
bool rc = true;
|
||||
bool rc = isConfigured();
|
||||
switch (operation) {
|
||||
case AddOperation:
|
||||
case DeleteOperation:
|
||||
|
@@ -50,6 +50,7 @@ public:
|
||||
|
||||
bool managesDirectory(const QString &directory, QString *topLevel = 0) const;
|
||||
|
||||
bool isConfigured() const;
|
||||
bool supportsOperation(Operation operation) const;
|
||||
bool vcsOpen(const QString &fileName);
|
||||
bool vcsAdd(const QString &fileName);
|
||||
|
Reference in New Issue
Block a user