Vcs: Merge IVersionControl and VcsBasePlugin hierarchies

They were 1:1 in parallel, with quite a bit of function call
ping-pong inbetween, for code-sharing-by-inheritance. Merge
them by making VcsBasePlugin inherit IVersionControl and
merge the derived classes below.

Size of this patch is hard to avoid as all seven systems have to
move simultaneously. Non-necessary potential follow-up cleanup
have been left out on purpose.

Change-Id: Icb71e4182af3db21069cc637e7ae87ffa3829791
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
hjk
2020-01-30 12:31:47 +01:00
parent a35a2d6bf3
commit b8fe25db25
58 changed files with 1091 additions and 1902 deletions

View File

@@ -5,7 +5,6 @@ add_qtc_plugin(Bazaar
bazaarclient.cpp bazaarclient.h
bazaarcommitpanel.ui
bazaarcommitwidget.cpp bazaarcommitwidget.h
bazaarcontrol.cpp bazaarcontrol.h
bazaareditor.cpp bazaareditor.h
bazaarplugin.cpp bazaarplugin.h
bazaarsettings.cpp bazaarsettings.h

View File

@@ -1,7 +1,6 @@
include(../../qtcreatorplugin.pri)
SOURCES += \
bazaarclient.cpp \
bazaarcontrol.cpp \
bazaarplugin.cpp \
optionspage.cpp \
bazaarsettings.cpp \
@@ -15,7 +14,6 @@ SOURCES += \
HEADERS += \
bazaarclient.h \
constants.h \
bazaarcontrol.h \
bazaarplugin.h \
optionspage.h \
bazaarsettings.h \

View File

@@ -18,8 +18,6 @@ QtcPlugin {
"bazaarcommitpanel.ui",
"bazaarcommitwidget.cpp",
"bazaarcommitwidget.h",
"bazaarcontrol.cpp",
"bazaarcontrol.h",
"bazaareditor.cpp",
"bazaareditor.h",
"bazaarplugin.cpp",

View File

@@ -33,7 +33,6 @@ namespace Bazaar {
namespace Internal {
class BazaarSettings;
class BazaarControl;
class BazaarClient : public VcsBase::VcsBaseClient
{
@@ -57,7 +56,6 @@ public:
void view(const QString &source, const QString &id,
const QStringList &extraOptions = QStringList()) override;
protected:
Core::Id vcsEditorKind(VcsCommandTag cmd) const override;
QString vcsCommandString(VcsCommandTag cmd) const override;
Utils::ExitCodeInterpreter exitCodeInterpreter(VcsCommandTag cmd) const override;
@@ -66,7 +64,6 @@ protected:
private:
friend class CloneWizard;
friend class BazaarControl;
};
} // namespace Internal

View File

@@ -1,169 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 Hugues Delorme
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "bazaarcontrol.h"
#include "bazaarclient.h"
#include "bazaarplugin.h"
#include <vcsbase/vcsbaseclientsettings.h>
#include <vcsbase/vcsbaseconstants.h>
#include <vcsbase/vcscommand.h>
#include <utils/fileutils.h>
#include <QFileInfo>
#include <QVariant>
#include <QStringList>
using namespace Bazaar::Internal;
BazaarControl::BazaarControl(BazaarClient *client) : m_bazaarClient(client)
{ }
QString BazaarControl::displayName() const
{
return tr("Bazaar");
}
Core::Id BazaarControl::id() const
{
return Core::Id(VcsBase::Constants::VCS_ID_BAZAAR);
}
bool BazaarControl::isVcsFileOrDirectory(const Utils::FilePath &fileName) const
{
return m_bazaarClient->isVcsDirectory(fileName);
}
bool BazaarControl::managesDirectory(const QString &directory, QString *topLevel) const
{
QFileInfo dir(directory);
const QString topLevelFound = m_bazaarClient->findTopLevelForFile(dir);
if (topLevel)
*topLevel = topLevelFound;
return !topLevelFound.isEmpty();
}
bool BazaarControl::managesFile(const QString &workingDirectory, const QString &fileName) const
{
return m_bazaarClient->managesFile(workingDirectory, fileName);
}
bool BazaarControl::isConfigured() const
{
const Utils::FilePath binary = m_bazaarClient->vcsBinary();
if (binary.isEmpty())
return false;
QFileInfo fi = binary.toFileInfo();
return fi.exists() && fi.isFile() && fi.isExecutable();
}
bool BazaarControl::supportsOperation(Operation operation) const
{
bool supported = isConfigured();
switch (operation) {
case Core::IVersionControl::AddOperation:
case Core::IVersionControl::DeleteOperation:
case Core::IVersionControl::MoveOperation:
case Core::IVersionControl::CreateRepositoryOperation:
case Core::IVersionControl::AnnotateOperation:
case Core::IVersionControl::InitialCheckoutOperation:
break;
case Core::IVersionControl::SnapshotOperations:
supported = false;
break;
}
return supported;
}
bool BazaarControl::vcsOpen(const QString &filename)
{
Q_UNUSED(filename)
return true;
}
bool BazaarControl::vcsAdd(const QString &filename)
{
const QFileInfo fi(filename);
return m_bazaarClient->synchronousAdd(fi.absolutePath(), fi.fileName());
}
bool BazaarControl::vcsDelete(const QString &filename)
{
const QFileInfo fi(filename);
return m_bazaarClient->synchronousRemove(fi.absolutePath(), fi.fileName());
}
bool BazaarControl::vcsMove(const QString &from, const QString &to)
{
const QFileInfo fromInfo(from);
const QFileInfo toInfo(to);
return m_bazaarClient->synchronousMove(fromInfo.absolutePath(),
fromInfo.absoluteFilePath(),
toInfo.absoluteFilePath());
}
bool BazaarControl::vcsCreateRepository(const QString &directory)
{
return m_bazaarClient->synchronousCreateRepository(directory);
}
bool BazaarControl::vcsAnnotate(const QString &file, int line)
{
const QFileInfo fi(file);
m_bazaarClient->annotate(fi.absolutePath(), fi.fileName(), QString(), line);
return true;
}
Core::ShellCommand *BazaarControl::createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory,
const QString &localName,
const QStringList &extraArgs)
{
QStringList args;
args << m_bazaarClient->vcsCommandString(BazaarClient::CloneCommand)
<< extraArgs << url << localName;
QProcessEnvironment env = m_bazaarClient->processEnvironment();
env.insert(QLatin1String("BZR_PROGRESS_BAR"), QLatin1String("text"));
auto command = new VcsBase::VcsCommand(baseDirectory.toString(), env);
command->addJob({m_bazaarClient->vcsBinary(), args}, -1);
return command;
}
void BazaarControl::changed(const QVariant &v)
{
switch (v.type()) {
case QVariant::String:
emit repositoryChanged(v.toString());
break;
case QVariant::StringList:
emit filesChanged(v.toStringList());
break;
default:
break;
}
}

View File

@@ -1,79 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 Hugues Delorme
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include <coreplugin/iversioncontrol.h>
QT_BEGIN_NAMESPACE
class QVariant;
QT_END_NAMESPACE
namespace Bazaar {
namespace Internal {
class BazaarClient;
//Implements just the basics of the Version Control Interface
//BazaarClient handles all the work
class BazaarControl: public Core::IVersionControl
{
Q_OBJECT
public:
explicit BazaarControl(BazaarClient *bazaarClient);
QString displayName() const final;
Core::Id id() const final;
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final;
bool managesDirectory(const QString &filename, QString *topLevel = nullptr) const final;
bool managesFile(const QString &workingDirectory, const QString &fileName) const final;
bool isConfigured() const final;
bool supportsOperation(Operation operation) const final;
bool vcsOpen(const QString &fileName) final;
bool vcsAdd(const QString &filename) final;
bool vcsDelete(const QString &filename) final;
bool vcsMove(const QString &from, const QString &to) final;
bool vcsCreateRepository(const QString &directory) final;
bool vcsAnnotate(const QString &file, int line) final;
Core::ShellCommand *createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory,
const QString &localName,
const QStringList &extraArgs) final;
// To be connected to the VCSTask's success signal to emit the repository/
// files changed signals according to the variant's type:
// String -> repository, StringList -> files
void changed(const QVariant &);
private:
BazaarClient *const m_bazaarClient;
};
} // namespace Internal
} // namespace Bazaar

View File

@@ -27,7 +27,6 @@
#include "bazaarclient.h"
#include "bazaarcommitwidget.h"
#include "bazaarcontrol.h"
#include "bazaareditor.h"
#include "bazaarsettings.h"
#include "commiteditor.h"
@@ -40,6 +39,7 @@
#include <vcsbase/vcsbaseclient.h>
#include <vcsbase/vcsbaseplugin.h>
#include <vcsbase/vcscommand.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h>
@@ -140,6 +140,31 @@ class BazaarPluginPrivate final : public VcsBasePluginPrivate
public:
BazaarPluginPrivate();
QString displayName() const final;
Core::Id id() const final;
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final;
bool managesDirectory(const QString &filename, QString *topLevel) const final;
bool managesFile(const QString &workingDirectory, const QString &fileName) const final;
bool isConfigured() const final;
bool supportsOperation(Operation operation) const final;
bool vcsOpen(const QString &fileName) final;
bool vcsAdd(const QString &filename) final;
bool vcsDelete(const QString &filename) final;
bool vcsMove(const QString &from, const QString &to) final;
bool vcsCreateRepository(const QString &directory) final;
bool vcsAnnotate(const QString &file, int line) final;
Core::ShellCommand *createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory,
const QString &localName,
const QStringList &extraArgs) final;
// To be connected to the VCSTask's success signal to emit the repository/
// files changed signals according to the variant's type:
// String -> repository, StringList -> files
void changed(const QVariant &);
void updateActions(VcsBase::VcsBasePluginPrivate::ActionState) final;
bool submitEditorAboutToClose() final;
@@ -175,9 +200,8 @@ public:
// Variables
BazaarSettings m_bazaarSettings;
BazaarClient m_client{&m_bazaarSettings};
BazaarControl m_control{&m_client};
OptionsPage m_optionsPage{[this] { m_control.configurationChanged(); }, &m_bazaarSettings};
OptionsPage m_optionsPage{[this] { configurationChanged(); }, &m_bazaarSettings};
VcsSubmitEditorFactory m_submitEditorFactory {
&submitEditorParameters,
@@ -264,11 +288,11 @@ void BazaarPlugin::extensionsInitialized()
}
BazaarPluginPrivate::BazaarPluginPrivate()
: VcsBasePluginPrivate(Context(Constants::BAZAAR_CONTEXT))
{
Context context(Constants::BAZAAR_CONTEXT);
initializeVcs(&m_control, context);
connect(&m_client, &VcsBaseClient::changed, &m_control, &BazaarControl::changed);
connect(&m_client, &VcsBaseClient::changed, this, &BazaarPluginPrivate::changed);
const auto describeFunc = [this](const QString &source, const QString &id) {
m_client.view(source, id);
@@ -796,5 +820,131 @@ void BazaarPluginPrivate::updateActions(VcsBasePluginPrivate::ActionState as)
repoAction->setEnabled(repoEnabled);
}
QString BazaarPluginPrivate::displayName() const
{
return tr("Bazaar");
}
Core::Id BazaarPluginPrivate::id() const
{
return Core::Id(VcsBase::Constants::VCS_ID_BAZAAR);
}
bool BazaarPluginPrivate::isVcsFileOrDirectory(const Utils::FilePath &fileName) const
{
return m_client.isVcsDirectory(fileName);
}
bool BazaarPluginPrivate::managesDirectory(const QString &directory, QString *topLevel) const
{
QFileInfo dir(directory);
const QString topLevelFound = m_client.findTopLevelForFile(dir);
if (topLevel)
*topLevel = topLevelFound;
return !topLevelFound.isEmpty();
}
bool BazaarPluginPrivate::managesFile(const QString &workingDirectory, const QString &fileName) const
{
return m_client.managesFile(workingDirectory, fileName);
}
bool BazaarPluginPrivate::isConfigured() const
{
const Utils::FilePath binary = m_client.vcsBinary();
if (binary.isEmpty())
return false;
QFileInfo fi = binary.toFileInfo();
return fi.exists() && fi.isFile() && fi.isExecutable();
}
bool BazaarPluginPrivate::supportsOperation(Operation operation) const
{
bool supported = isConfigured();
switch (operation) {
case Core::IVersionControl::AddOperation:
case Core::IVersionControl::DeleteOperation:
case Core::IVersionControl::MoveOperation:
case Core::IVersionControl::CreateRepositoryOperation:
case Core::IVersionControl::AnnotateOperation:
case Core::IVersionControl::InitialCheckoutOperation:
break;
case Core::IVersionControl::SnapshotOperations:
supported = false;
break;
}
return supported;
}
bool BazaarPluginPrivate::vcsOpen(const QString &filename)
{
Q_UNUSED(filename)
return true;
}
bool BazaarPluginPrivate::vcsAdd(const QString &filename)
{
const QFileInfo fi(filename);
return m_client.synchronousAdd(fi.absolutePath(), fi.fileName());
}
bool BazaarPluginPrivate::vcsDelete(const QString &filename)
{
const QFileInfo fi(filename);
return m_client.synchronousRemove(fi.absolutePath(), fi.fileName());
}
bool BazaarPluginPrivate::vcsMove(const QString &from, const QString &to)
{
const QFileInfo fromInfo(from);
const QFileInfo toInfo(to);
return m_client.synchronousMove(fromInfo.absolutePath(),
fromInfo.absoluteFilePath(),
toInfo.absoluteFilePath());
}
bool BazaarPluginPrivate::vcsCreateRepository(const QString &directory)
{
return m_client.synchronousCreateRepository(directory);
}
bool BazaarPluginPrivate::vcsAnnotate(const QString &file, int line)
{
const QFileInfo fi(file);
m_client.annotate(fi.absolutePath(), fi.fileName(), QString(), line);
return true;
}
Core::ShellCommand *BazaarPluginPrivate::createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory,
const QString &localName,
const QStringList &extraArgs)
{
QStringList args;
args << m_client.vcsCommandString(BazaarClient::CloneCommand)
<< extraArgs << url << localName;
QProcessEnvironment env = m_client.processEnvironment();
env.insert(QLatin1String("BZR_PROGRESS_BAR"), QLatin1String("text"));
auto command = new VcsBase::VcsCommand(baseDirectory.toString(), env);
command->addJob({m_client.vcsBinary(), args}, -1);
return command;
}
void BazaarPluginPrivate::changed(const QVariant &v)
{
switch (v.type()) {
case QVariant::String:
emit repositoryChanged(v.toString());
break;
case QVariant::StringList:
emit filesChanged(v.toStringList());
break;
default:
break;
}
}
} // namespace Internal
} // namespace Bazaar

View File

@@ -5,7 +5,6 @@ add_qtc_plugin(ClearCase
annotationhighlighter.cpp annotationhighlighter.h
checkoutdialog.cpp checkoutdialog.h checkoutdialog.ui
clearcaseconstants.h
clearcasecontrol.cpp clearcasecontrol.h
clearcaseeditor.cpp clearcaseeditor.h
clearcaseplugin.cpp clearcaseplugin.h
clearcasesettings.cpp clearcasesettings.h

View File

@@ -4,7 +4,6 @@ HEADERS += activityselector.h \
annotationhighlighter.h \
checkoutdialog.h \
clearcaseconstants.h \
clearcasecontrol.h \
clearcaseeditor.h \
clearcaseplugin.h \
clearcasesettings.h \
@@ -17,7 +16,6 @@ HEADERS += activityselector.h \
SOURCES += activityselector.cpp \
annotationhighlighter.cpp \
checkoutdialog.cpp \
clearcasecontrol.cpp \
clearcaseeditor.cpp \
clearcaseplugin.cpp \
clearcasesettings.cpp \

View File

@@ -22,8 +22,6 @@ QtcPlugin {
"checkoutdialog.h",
"checkoutdialog.ui",
"clearcaseconstants.h",
"clearcasecontrol.cpp",
"clearcasecontrol.h",
"clearcaseeditor.cpp",
"clearcaseeditor.h",
"clearcaseplugin.cpp",

View File

@@ -1,193 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 AudioCodes Ltd.
** Author: Orgad Shaneh <orgad.shaneh@audiocodes.com>
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "clearcasecontrol.h"
#include "clearcaseplugin.h"
#include "clearcaseconstants.h"
#include <vcsbase/vcsbaseconstants.h>
#include <utils/synchronousprocess.h>
#include <QFileInfo>
using namespace ClearCase;
using namespace ClearCase::Internal;
ClearCaseControl::ClearCaseControl(ClearCasePluginPrivate *plugin) : m_plugin(plugin)
{ }
QString ClearCaseControl::displayName() const
{
return QLatin1String("ClearCase");
}
Core::Id ClearCaseControl::id() const
{
return Constants::VCS_ID_CLEARCASE;
}
bool ClearCaseControl::isVcsFileOrDirectory(const Utils::FilePath &fileName) const
{
Q_UNUSED(fileName)
return false; // ClearCase has no files/directories littering the sources
}
bool ClearCaseControl::isConfigured() const
{
#ifdef WITH_TESTS
if (m_plugin->isFakeCleartool())
return true;
#endif
const QString binary = m_plugin->settings().ccBinaryPath;
if (binary.isEmpty())
return false;
QFileInfo fi(binary);
return fi.exists() && fi.isFile() && fi.isExecutable();
}
bool ClearCaseControl::supportsOperation(Operation operation) const
{
bool rc = isConfigured();
switch (operation) {
case AddOperation:
case DeleteOperation:
case MoveOperation:
case AnnotateOperation:
break;
case CreateRepositoryOperation:
case SnapshotOperations:
case Core::IVersionControl::InitialCheckoutOperation:
rc = false;
break;
}
return rc;
}
Core::IVersionControl::OpenSupportMode ClearCaseControl::openSupportMode(const QString &fileName) const
{
if (m_plugin->isDynamic()) {
// NB! Has to use managesFile() and not vcsStatus() since the index can only be guaranteed
// to be up to date if the file has been explicitly opened, which is not the case when
// doing a search and replace as a part of a refactoring.
if (m_plugin->managesFile(QFileInfo(fileName).absolutePath(), fileName)) {
// Checkout is the only option for managed files in dynamic views
return IVersionControl::OpenMandatory;
} else {
// Not managed files can be edited without noticing the VCS
return IVersionControl::NoOpen;
}
} else {
return IVersionControl::OpenOptional; // Snapshot views supports Hijack and check out
}
}
bool ClearCaseControl::vcsOpen(const QString &fileName)
{
const QFileInfo fi(fileName);
return m_plugin->vcsOpen(fi.absolutePath(), fi.fileName());
}
Core::IVersionControl::SettingsFlags ClearCaseControl::settingsFlags() const
{
SettingsFlags rc;
if (m_plugin->settings().autoCheckOut)
rc|= AutoOpen;
return rc;
}
bool ClearCaseControl::vcsAdd(const QString &fileName)
{
const QFileInfo fi(fileName);
return m_plugin->vcsAdd(fi.absolutePath(), fi.fileName());
}
bool ClearCaseControl::vcsDelete(const QString &fileName)
{
const QFileInfo fi(fileName);
return m_plugin->vcsDelete(fi.absolutePath(), fi.fileName());
}
bool ClearCaseControl::vcsMove(const QString &from, const QString &to)
{
const QFileInfo ifrom(from);
const QFileInfo ito(to);
return m_plugin->vcsMove(ifrom.absolutePath(), ifrom.fileName(), ito.fileName());
}
bool ClearCaseControl::managesDirectory(const QString &directory, QString *topLevel) const
{
return m_plugin->managesDirectory(directory, topLevel);
}
bool ClearCaseControl::managesFile(const QString &workingDirectory, const QString &fileName) const
{
return m_plugin->managesFile(workingDirectory, fileName);
}
bool ClearCaseControl::vcsAnnotate(const QString &file, int line)
{
const QFileInfo fi(file);
m_plugin->vcsAnnotate(fi.absolutePath(), fi.fileName(), QString(), line);
return true;
}
QString ClearCaseControl::vcsOpenText() const
{
return tr("Check &Out");
}
QString ClearCaseControl::vcsMakeWritableText() const
{
if (m_plugin->isDynamic())
return QString();
return tr("&Hijack");
}
QString ClearCaseControl::vcsTopic(const QString &directory)
{
return m_plugin->ccGetView(directory).name;
}
void ClearCaseControl::emitRepositoryChanged(const QString &s)
{
emit repositoryChanged(s);
}
void ClearCaseControl::emitFilesChanged(const QStringList &l)
{
emit filesChanged(l);
}
void ClearCaseControl::emitConfigurationChanged()
{
emit configurationChanged();
}
bool ClearCaseControl::vcsCreateRepository(const QString &)
{
return false;
}

View File

@@ -1,76 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 AudioCodes Ltd.
** Author: Orgad Shaneh <orgad.shaneh@audiocodes.com>
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include <coreplugin/iversioncontrol.h>
namespace ClearCase {
namespace Internal {
class ClearCasePluginPrivate;
// Just a proxy for ClearCasePlugin
class ClearCaseControl : public Core::IVersionControl
{
Q_OBJECT
public:
explicit ClearCaseControl(ClearCasePluginPrivate *plugin);
QString displayName() const final;
Core::Id id() const final;
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final;
bool managesDirectory(const QString &directory, QString *topLevel = nullptr) const final;
bool managesFile(const QString &workingDirectory, const QString &fileName) const final;
bool isConfigured() const final;
bool supportsOperation(Operation operation) const final;
OpenSupportMode openSupportMode(const QString &fileName) const final;
bool vcsOpen(const QString &fileName) final;
SettingsFlags settingsFlags() const final;
bool vcsAdd(const QString &fileName) final;
bool vcsDelete(const QString &filename) final;
bool vcsMove(const QString &from, const QString &to) final;
bool vcsCreateRepository(const QString &directory) final;
bool vcsAnnotate(const QString &file, int line) final;
QString vcsOpenText() const final;
QString vcsMakeWritableText() const final;
QString vcsTopic(const QString &directory) final;
void emitRepositoryChanged(const QString &);
void emitFilesChanged(const QStringList &);
void emitConfigurationChanged();
private:
ClearCasePluginPrivate *const m_plugin;
};
} // namespace Internal
} // namespace ClearCase

View File

@@ -28,7 +28,6 @@
#include "activityselector.h"
#include "checkoutdialog.h"
#include "clearcaseconstants.h"
#include "clearcasecontrol.h"
#include "clearcaseeditor.h"
#include "clearcasesubmiteditor.h"
#include "clearcasesubmiteditorwidget.h"
@@ -409,9 +408,10 @@ void ClearCasePlugin::extensionsInitialized()
dd->extensionsInitialized();
}
ClearCasePluginPrivate::ClearCasePluginPrivate() :
m_activityMutex(new QMutex),
m_statusMap(new StatusMap)
ClearCasePluginPrivate::ClearCasePluginPrivate()
: VcsBase::VcsBasePluginPrivate(Context(CLEARCASE_CONTEXT)),
m_activityMutex(new QMutex),
m_statusMap(new StatusMap)
{
dd = this;
@@ -427,9 +427,6 @@ ClearCasePluginPrivate::ClearCasePluginPrivate() :
Context context(CLEARCASE_CONTEXT);
auto vcsCtrl = new ClearCaseControl(this);
initializeVcs(vcsCtrl, context);
connect(ICore::instance(), &ICore::coreAboutToClose, this, &ClearCasePluginPrivate::closing);
connect(ProgressManager::instance(), &ProgressManager::allTasksFinished,
this, &ClearCasePluginPrivate::tasksFinished);
@@ -913,7 +910,7 @@ bool ClearCasePluginPrivate::vcsUndoCheckOut(const QString &workingDir, const QS
if (!m_settings.disableIndexer)
setStatus(absPath, FileStatus::CheckedIn);
clearCaseControl()->emitFilesChanged(QStringList(absPath));
emit filesChanged(QStringList(absPath));
}
return !response.error;
}
@@ -976,7 +973,7 @@ void ClearCasePluginPrivate::undoHijackCurrent()
// revert
if (vcsUndoHijack(state.currentFileTopLevel(), fileName, keep))
clearCaseControl()->emitFilesChanged(QStringList(state.currentFile()));
emit filesChanged(QStringList(state.currentFile()));
}
QString ClearCasePluginPrivate::ccGetFileVersion(const QString &workingDir, const QString &file) const
@@ -1338,19 +1335,19 @@ void ClearCasePluginPrivate::ccUpdate(const QString &workingDir, const QStringLi
const ClearCaseResponse response =
runCleartool(workingDir, args, m_settings.longTimeOutS(), VcsCommand::ShowStdOut);
if (!response.error)
clearCaseControl()->emitRepositoryChanged(workingDir);
emit repositoryChanged(workingDir);
}
void ClearCasePluginPrivate::annotateCurrentFile()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return);
vcsAnnotate(state.currentFileTopLevel(), state.relativeCurrentFile());
vcsAnnotateHelper(state.currentFileTopLevel(), state.relativeCurrentFile());
}
void ClearCasePluginPrivate::vcsAnnotate(const QString &workingDir, const QString &file,
const QString &revision /* = QString() */,
int lineNumber /* = -1 */) const
void ClearCasePluginPrivate::vcsAnnotateHelper(const QString &workingDir, const QString &file,
const QString &revision /* = QString() */,
int lineNumber /* = -1 */) const
{
if (Constants::debug)
qDebug() << Q_FUNC_INFO << file;
@@ -1418,8 +1415,7 @@ void ClearCasePluginPrivate::describe(const QString &source, const QString &chan
QStringList args(QLatin1String("describe"));
args.push_back(id);
QTextCodec *codec = VcsBaseEditor::getCodec(source);
const ClearCaseResponse response =
runCleartool(topLevel, args, m_settings.timeOutS, 0, codec);
const ClearCaseResponse response = runCleartool(topLevel, args, m_settings.timeOutS, 0, codec);
description = response.stdOut;
if (m_settings.extDiffAvailable)
description += diffExternal(id);
@@ -1494,7 +1490,8 @@ IEditor *ClearCasePluginPrivate::showOutputInEditor(const QString& title, const
auto e = qobject_cast<ClearCaseEditorWidget*>(editor->widget());
if (!e)
return nullptr;
connect(e, &VcsBaseEditorWidget::annotateRevisionRequested, this, &ClearCasePluginPrivate::vcsAnnotate);
connect(e, &VcsBaseEditorWidget::annotateRevisionRequested,
this, &ClearCasePluginPrivate::vcsAnnotateHelper);
e->setForceReadOnly(true);
s.replace(QLatin1Char(' '), QLatin1Char('_'));
e->textDocument()->setFallbackSaveAsFileName(s);
@@ -1515,7 +1512,7 @@ void ClearCasePluginPrivate::setSettings(const ClearCaseSettings &s)
if (s != m_settings) {
m_settings = s;
m_settings.toSettings(ICore::settings());
clearCaseControl()->emitConfigurationChanged();
emit configurationChanged();
}
}
@@ -1700,7 +1697,7 @@ bool ClearCasePluginPrivate::vcsCheckIn(const QString &messageFile, const QStrin
if (!m_settings.disableIndexer)
setStatus(QDir::fromNativeSeparators(absPath), FileStatus::CheckedIn);
clearCaseControl()->emitFilesChanged(files);
emit filesChanged(files);
anySucceeded = true;
offset = checkedIn.indexIn(response.stdOut, offset + 12);
}
@@ -1820,11 +1817,6 @@ bool ClearCasePluginPrivate::vcsMove(const QString &workingDir, const QString &f
QStringList("move"), from, to);
}
bool ClearCasePluginPrivate::vcsCheckout(const QString & /*directory*/, const QByteArray & /*url*/)
{
return false;
}
///
/// Check if the directory is managed under ClearCase control.
///
@@ -1842,11 +1834,6 @@ bool ClearCasePluginPrivate::managesDirectory(const QString &directory, QString
return !topLevelFound.isEmpty();
}
ClearCaseControl *ClearCasePluginPrivate::clearCaseControl() const
{
return static_cast<ClearCaseControl *>(versionControl());
}
QString ClearCasePluginPrivate::ccGetCurrentActivity() const
{
QStringList args(QLatin1String("lsactivity"));
@@ -2195,6 +2182,134 @@ void ClearCasePluginPrivate::sync(QFutureInterface<void> &future, QStringList fi
ccSync.run(future, files);
}
QString ClearCasePluginPrivate::displayName() const
{
return QLatin1String("ClearCase");
}
Core::Id ClearCasePluginPrivate::id() const
{
return Constants::VCS_ID_CLEARCASE;
}
bool ClearCasePluginPrivate::isVcsFileOrDirectory(const Utils::FilePath &fileName) const
{
Q_UNUSED(fileName)
return false; // ClearCase has no files/directories littering the sources
}
bool ClearCasePluginPrivate::isConfigured() const
{
#ifdef WITH_TESTS
if (m_fakeClearTool)
return true;
#endif
const QString binary = m_settings.ccBinaryPath;
if (binary.isEmpty())
return false;
QFileInfo fi(binary);
return fi.exists() && fi.isFile() && fi.isExecutable();
}
bool ClearCasePluginPrivate::supportsOperation(Operation operation) const
{
bool rc = isConfigured();
switch (operation) {
case AddOperation:
case DeleteOperation:
case MoveOperation:
case AnnotateOperation:
break;
case CreateRepositoryOperation:
case SnapshotOperations:
case Core::IVersionControl::InitialCheckoutOperation:
rc = false;
break;
}
return rc;
}
Core::IVersionControl::OpenSupportMode ClearCasePluginPrivate::openSupportMode(const QString &fileName) const
{
if (isDynamic()) {
// NB! Has to use managesFile() and not vcsStatus() since the index can only be guaranteed
// to be up to date if the file has been explicitly opened, which is not the case when
// doing a search and replace as a part of a refactoring.
if (managesFile(QFileInfo(fileName).absolutePath(), fileName)) {
// Checkout is the only option for managed files in dynamic views
return IVersionControl::OpenMandatory;
} else {
// Not managed files can be edited without noticing the VCS
return IVersionControl::NoOpen;
}
} else {
return IVersionControl::OpenOptional; // Snapshot views supports Hijack and check out
}
}
bool ClearCasePluginPrivate::vcsOpen(const QString &fileName)
{
const QFileInfo fi(fileName);
return vcsOpen(fi.absolutePath(), fi.fileName());
}
Core::IVersionControl::SettingsFlags ClearCasePluginPrivate::settingsFlags() const
{
SettingsFlags rc;
if (m_settings.autoCheckOut)
rc|= AutoOpen;
return rc;
}
bool ClearCasePluginPrivate::vcsAdd(const QString &fileName)
{
const QFileInfo fi(fileName);
return vcsAdd(fi.absolutePath(), fi.fileName());
}
bool ClearCasePluginPrivate::vcsDelete(const QString &fileName)
{
const QFileInfo fi(fileName);
return vcsDelete(fi.absolutePath(), fi.fileName());
}
bool ClearCasePluginPrivate::vcsMove(const QString &from, const QString &to)
{
const QFileInfo ifrom(from);
const QFileInfo ito(to);
return vcsMove(ifrom.absolutePath(), ifrom.fileName(), ito.fileName());
}
bool ClearCasePluginPrivate::vcsAnnotate(const QString &file, int line)
{
const QFileInfo fi(file);
vcsAnnotateHelper(fi.absolutePath(), fi.fileName(), QString(), line);
return true;
}
QString ClearCasePluginPrivate::vcsOpenText() const
{
return tr("Check &Out");
}
QString ClearCasePluginPrivate::vcsMakeWritableText() const
{
if (isDynamic())
return QString();
return tr("&Hijack");
}
QString ClearCasePluginPrivate::vcsTopic(const QString &directory)
{
return ccGetView(directory).name;
}
bool ClearCasePluginPrivate::vcsCreateRepository(const QString &)
{
return false;
}
#ifdef WITH_TESTS
void ClearCasePlugin::testDiffFileResolving_data()

View File

@@ -61,7 +61,6 @@ namespace ClearCase {
namespace Internal {
class ClearCaseSubmitEditor;
class ClearCaseControl;
class ClearCaseResponse
{
@@ -113,6 +112,33 @@ public:
ClearCasePluginPrivate();
~ClearCasePluginPrivate() final;
// IVersionControl
QString displayName() const final;
Core::Id id() const final;
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final;
bool managesDirectory(const QString &directory, QString *topLevel) const final;
bool managesFile(const QString &workingDirectory, const QString &fileName) const final;
bool isConfigured() const final;
bool supportsOperation(Operation operation) const final;
OpenSupportMode openSupportMode(const QString &fileName) const final;
bool vcsOpen(const QString &fileName) final;
SettingsFlags settingsFlags() const final;
bool vcsAdd(const QString &fileName) final;
bool vcsDelete(const QString &filename) final;
bool vcsMove(const QString &from, const QString &to) final;
bool vcsCreateRepository(const QString &directory) final;
bool vcsAnnotate(const QString &file, int line) final;
QString vcsOpenText() const final;
QString vcsMakeWritableText() const final;
QString vcsTopic(const QString &directory) final;
///
ClearCaseSubmitEditor *openClearCaseSubmitEditor(const QString &fileName, bool isUcm);
const ClearCaseSettings &settings() const;
@@ -128,8 +154,6 @@ public:
bool vcsUndoHijack(const QString &workingDir, const QString &fileName, bool keep);
bool vcsMove(const QString &workingDir, const QString &from, const QString &to);
bool vcsSetActivity(const QString &workingDir, const QString &title, const QString &activity);
bool managesDirectory(const QString &directory, QString *topLevel = nullptr) const;
bool vcsCheckout(const QString &directory, const QByteArray &url);
static ClearCasePluginPrivate *instance();
@@ -151,14 +175,12 @@ public:
void setStatus(const QString &file, FileStatus::Status status, bool update = true);
bool ccCheckUcm(const QString &viewname, const QString &workingDir) const;
bool managesFile(const QString &workingDirectory, const QString &fileName) const;
#ifdef WITH_TESTS
inline void setFakeCleartool(const bool b = true) { m_fakeClearTool = b; }
inline bool isFakeCleartool() const { return m_fakeClearTool; }
#endif
void vcsAnnotate(const QString &workingDir, const QString &file,
const QString &revision = QString(), int lineNumber = -1) const;
void vcsAnnotateHelper(const QString &workingDir, const QString &file,
const QString &revision = QString(), int lineNumber = -1) const;
bool newActivity();
void updateStreamAndView();
void describe(const QString &source, const QString &changeNr);
@@ -216,7 +238,6 @@ private:
void ccDiffWithPred(const QString &workingDir, const QStringList &files);
void startCheckIn(const QString &workingDir, const QStringList &files = QStringList());
void cleanCheckInMessageFile();
inline ClearCaseControl *clearCaseControl() const;
QString ccGetFileActivity(const QString &workingDir, const QString &file);
QStringList ccGetActivityVersions(const QString &workingDir, const QString &activity);
void diffGraphical(const QString &file1, const QString &file2 = QString());

View File

@@ -3,7 +3,6 @@ add_qtc_plugin(CVS
SOURCES
annotationhighlighter.cpp annotationhighlighter.h
cvsclient.cpp cvsclient.h
cvscontrol.cpp cvscontrol.h
cvseditor.cpp cvseditor.h
cvsplugin.cpp cvsplugin.h
cvssettings.cpp cvssettings.h

View File

@@ -3,7 +3,6 @@ include(../../qtcreatorplugin.pri)
HEADERS += annotationhighlighter.h \
cvsplugin.h \
cvsclient.h \
cvscontrol.h \
settingspage.h \
cvseditor.h \
cvssubmiteditor.h \
@@ -13,7 +12,6 @@ HEADERS += annotationhighlighter.h \
SOURCES += annotationhighlighter.cpp \
cvsplugin.cpp \
cvsclient.cpp \
cvscontrol.cpp \
settingspage.cpp \
cvseditor.cpp \
cvssubmiteditor.cpp \

View File

@@ -15,8 +15,6 @@ QtcPlugin {
"annotationhighlighter.h",
"cvsclient.cpp",
"cvsclient.h",
"cvscontrol.cpp",
"cvscontrol.h",
"cvseditor.cpp",
"cvseditor.h",
"cvsplugin.cpp",

View File

@@ -28,7 +28,6 @@
#include "cvseditor.h"
#include "cvssubmiteditor.h"
#include "cvsclient.h"
#include "cvscontrol.h"
#include "cvsutils.h"
#include <vcsbase/basevcseditorfactory.h>
@@ -165,15 +164,39 @@ public:
CvsPluginPrivate();
~CvsPluginPrivate() final;
CvsClient *client() const;
// IVersionControl
QString displayName() const final { return QLatin1String("cvs"); }
Core::Id id() const final;
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final;
bool managesDirectory(const QString &directory, QString *topLevel) const final;
bool managesFile(const QString &workingDirectory, const QString &fileName) const final;
bool isConfigured() const final;
bool supportsOperation(Operation operation) const final;
OpenSupportMode openSupportMode(const QString &fileName) const final;
bool vcsOpen(const QString &fileName) final;
bool vcsAdd(const QString &fileName) final;
bool vcsDelete(const QString &filename) final;
bool vcsMove(const QString &, const QString &) final { return false; }
bool vcsCreateRepository(const QString &directory) final;
bool vcsAnnotate(const QString &file, int line) final;
QString vcsOpenText() const final;
Core::ShellCommand *createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory,
const QString &localName,
const QStringList &extraArgs) final;
///
CvsSubmitEditor *openCVSSubmitEditor(const QString &fileName);
// IVersionControl
bool vcsAdd(const QString &workingDir, const QString &fileName);
bool vcsDelete(const QString &workingDir, const QString &fileName);
bool managesDirectory(const QString &directory, QString *topLevel = nullptr) const;
bool managesFile(const QString &workingDirectory, const QString &fileName) const;
// cvs 'edit' is used to implement 'open' (cvsnt).
bool edit(const QString &topLevel, const QStringList &files);
@@ -275,69 +298,29 @@ private:
bool m_submitActionTriggered = false;
};
// Just a proxy for CVSPlugin
class CvsControl : public Core::IVersionControl
{
Q_DECLARE_TR_FUNCTIONS(Cvs::Internal::CvsControl)
public:
explicit CvsControl(CvsPluginPrivate *plugin) : m_plugin(plugin) {}
QString displayName() const final;
Core::Id id() const final;
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final;
bool managesDirectory(const QString &directory, QString *topLevel = nullptr) const final;
bool managesFile(const QString &workingDirectory, const QString &fileName) const final;
bool isConfigured() const final;
bool supportsOperation(Operation operation) const final;
OpenSupportMode openSupportMode(const QString &fileName) const final;
bool vcsOpen(const QString &fileName) final;
bool vcsAdd(const QString &fileName) final;
bool vcsDelete(const QString &filename) final;
bool vcsMove(const QString &from, const QString &to) final;
bool vcsCreateRepository(const QString &directory) final;
bool vcsAnnotate(const QString &file, int line) final;
QString vcsOpenText() const final;
Core::ShellCommand *createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory,
const QString &localName,
const QStringList &extraArgs) final;
private:
CvsPluginPrivate *const m_plugin;
};
QString CvsControl::displayName() const
{
return QLatin1String("cvs");
}
Core::Id CvsControl::id() const
Core::Id CvsPluginPrivate::id() const
{
return Core::Id(VcsBase::Constants::VCS_ID_CVS);
}
bool CvsControl::isVcsFileOrDirectory(const Utils::FilePath &fileName) const
bool CvsPluginPrivate::isVcsFileOrDirectory(const Utils::FilePath &fileName) const
{
return fileName.isDir()
&& !fileName.fileName().compare("CVS", Utils::HostOsInfo::fileNameCaseSensitivity());
}
bool CvsControl::isConfigured() const
bool CvsPluginPrivate::isConfigured() const
{
const Utils::FilePath binary = m_plugin->client()->vcsBinary();
const Utils::FilePath binary = m_client->vcsBinary();
if (binary.isEmpty())
return false;
QFileInfo fi = binary.toFileInfo();
return fi.exists() && fi.isFile() && fi.isExecutable();
}
bool CvsControl::supportsOperation(Operation operation) const
bool CvsPluginPrivate::supportsOperation(Operation operation) const
{
bool rc = isConfigured();
switch (operation) {
@@ -355,62 +338,55 @@ bool CvsControl::supportsOperation(Operation operation) const
return rc;
}
Core::IVersionControl::OpenSupportMode CvsControl::openSupportMode(const QString &fileName) const
Core::IVersionControl::OpenSupportMode CvsPluginPrivate::openSupportMode(const QString &fileName) const
{
Q_UNUSED(fileName)
return OpenOptional;
}
bool CvsControl::vcsOpen(const QString &fileName)
bool CvsPluginPrivate::vcsOpen(const QString &fileName)
{
const QFileInfo fi(fileName);
return m_plugin->edit(fi.absolutePath(), QStringList(fi.fileName()));
return edit(fi.absolutePath(), QStringList(fi.fileName()));
}
bool CvsControl::vcsAdd(const QString &fileName)
bool CvsPluginPrivate::vcsAdd(const QString &fileName)
{
const QFileInfo fi(fileName);
return m_plugin->vcsAdd(fi.absolutePath(), fi.fileName());
return vcsAdd(fi.absolutePath(), fi.fileName());
}
bool CvsControl::vcsDelete(const QString &fileName)
bool CvsPluginPrivate::vcsDelete(const QString &fileName)
{
const QFileInfo fi(fileName);
return m_plugin->vcsDelete(fi.absolutePath(), fi.fileName());
return vcsDelete(fi.absolutePath(), fi.fileName());
}
bool CvsControl::vcsMove(const QString &from, const QString &to)
{
Q_UNUSED(from)
Q_UNUSED(to)
return false;
}
bool CvsControl::vcsCreateRepository(const QString &)
bool CvsPluginPrivate::vcsCreateRepository(const QString &)
{
return false;
}
bool CvsControl::vcsAnnotate(const QString &file, int line)
bool CvsPluginPrivate::vcsAnnotate(const QString &file, int line)
{
const QFileInfo fi(file);
m_plugin->vcsAnnotate(fi.absolutePath(), fi.fileName(), QString(), line);
vcsAnnotate(fi.absolutePath(), fi.fileName(), QString(), line);
return true;
}
QString CvsControl::vcsOpenText() const
QString CvsPluginPrivate::vcsOpenText() const
{
return tr("&Edit");
}
Core::ShellCommand *CvsControl::createInitialCheckoutCommand(const QString &url,
Core::ShellCommand *CvsPluginPrivate::createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory,
const QString &localName,
const QStringList &extraArgs)
{
QTC_ASSERT(localName == url, return nullptr);
const CvsSettings settings = m_plugin->client()->settings();
const CvsSettings settings = m_client->settings();
QStringList args;
args << QLatin1String("checkout") << url << extraArgs;
@@ -418,20 +394,10 @@ Core::ShellCommand *CvsControl::createInitialCheckoutCommand(const QString &url,
auto command = new VcsBase::VcsCommand(baseDirectory.toString(),
QProcessEnvironment::systemEnvironment());
command->setDisplayName(tr("CVS Checkout"));
command->addJob({m_plugin->client()->vcsBinary(), settings.addOptions(args)}, -1);
command->addJob({m_client->vcsBinary(), settings.addOptions(args)}, -1);
return command;
}
bool CvsControl::managesDirectory(const QString &directory, QString *topLevel) const
{
return m_plugin->managesDirectory(directory, topLevel);
}
bool CvsControl::managesFile(const QString &workingDirectory, const QString &fileName) const
{
return m_plugin->managesFile(workingDirectory, fileName);
}
// ------------- CVSPlugin
static CvsPluginPrivate *dd = nullptr;
@@ -442,12 +408,6 @@ CvsPluginPrivate::~CvsPluginPrivate()
cleanCommitMessageFile();
}
CvsClient *CvsPluginPrivate::client() const
{
QTC_CHECK(m_client);
return m_client;
}
void CvsPluginPrivate::cleanCommitMessageFile()
{
if (!m_commitMessageFileName.isEmpty()) {
@@ -488,18 +448,15 @@ void CvsPlugin::extensionsInitialized()
}
CvsPluginPrivate::CvsPluginPrivate()
: VcsBasePluginPrivate(Context(CVS_CONTEXT))
{
using namespace Core::Constants;
dd = this;
Context context(CVS_CONTEXT);
auto vcsCtrl = new CvsControl(this);
initializeVcs(vcsCtrl, context);
m_client = new CvsClient(&m_settings);
new CvsSettingsPage([vcsCtrl] { vcsCtrl->configurationChanged(); }, &m_settings, this);
new CvsSettingsPage([this] { configurationChanged(); }, &m_settings, this);
new VcsSubmitEditorFactory(&submitParameters,
[]() { return new CvsSubmitEditor(&submitParameters); }, this);
@@ -837,7 +794,7 @@ void CvsPluginPrivate::revertAll()
runCvs(state.topLevel(), args, m_client->vcsTimeoutS(),
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
if (revertResponse.result == CvsResponse::Ok)
emit versionControl()->repositoryChanged(state.topLevel());
emit repositoryChanged(state.topLevel());
else
Core::AsynchronousMessageBox::warning(title,
tr("Revert failed: %1").arg(revertResponse.message));
@@ -875,7 +832,7 @@ void CvsPluginPrivate::revertCurrentFile()
runCvs(state.currentFileTopLevel(), args, m_client->vcsTimeoutS(),
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
if (revertResponse.result == CvsResponse::Ok)
emit versionControl()->filesChanged(QStringList(state.currentFile()));
emit filesChanged(QStringList(state.currentFile()));
}
void CvsPluginPrivate::diffProject()
@@ -1066,7 +1023,7 @@ bool CvsPluginPrivate::update(const QString &topLevel, const QString &file)
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
const bool ok = response.result == CvsResponse::Ok;
if (ok)
emit versionControl()->repositoryChanged(topLevel);
emit repositoryChanged(topLevel);
return ok;
}

View File

@@ -30,7 +30,6 @@ add_qtc_plugin(Git
gitsubmiteditorwidget.cpp gitsubmiteditorwidget.h
gitsubmitpanel.ui
gitutils.cpp gitutils.h
gitversioncontrol.cpp gitversioncontrol.h
logchangedialog.cpp logchangedialog.h
mergetool.cpp mergetool.h
remoteadditiondialog.ui

View File

@@ -32,7 +32,6 @@
#include "../gitplugin.h"
#include "../gitclient.h"
#include "../gitversioncontrol.h"
#include "../gitconstants.h"
#include <vcsbase/vcsbaseconstants.h>
#include <vcsbase/vcsbaseeditor.h>
@@ -473,7 +472,7 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
// Try to find a matching repository for a project by asking the VcsManager.
QString GerritPlugin::findLocalRepository(QString project, const QString &branch) const
{
const QStringList gitRepositories = VcsManager::repositories(GitPluginPrivate::instance()->gitVersionControl());
const QStringList gitRepositories = VcsManager::repositories(GitPluginPrivate::instance());
// Determine key (file name) to look for (qt/qtbase->'qtbase').
const int slashPos = project.lastIndexOf('/');
if (slashPos != -1)

View File

@@ -12,7 +12,6 @@ HEADERS += gitplugin.h \
annotationhighlighter.h \
gitsubmiteditorwidget.h \
gitsubmiteditor.h \
gitversioncontrol.h \
gitsettings.h \
branchmodel.h \
stashdialog.h \
@@ -36,7 +35,6 @@ SOURCES += gitplugin.cpp \
annotationhighlighter.cpp \
gitsubmiteditorwidget.cpp \
gitsubmiteditor.cpp \
gitversioncontrol.cpp \
gitsettings.cpp \
branchmodel.cpp \
stashdialog.cpp \

View File

@@ -52,8 +52,6 @@ QtcPlugin {
"gitsubmitpanel.ui",
"gitutils.cpp",
"gitutils.h",
"gitversioncontrol.cpp",
"gitversioncontrol.h",
"logchangedialog.cpp",
"logchangedialog.h",
"mergetool.cpp",

View File

@@ -31,7 +31,6 @@
#include "giteditor.h"
#include "gitplugin.h"
#include "gitsubmiteditor.h"
#include "gitversioncontrol.h"
#include "mergetool.h"
#include "branchadddialog.h"
#include "gerrit/gerritplugin.h"
@@ -2520,7 +2519,7 @@ bool GitClient::launchGitGui(const QString &workingDirectory) {
return success;
}
FilePath GitClient::gitBinDirectory()
FilePath GitClient::gitBinDirectory() const
{
const QString git = vcsBinary().toString();
if (git.isEmpty())
@@ -2945,7 +2944,7 @@ void GitClient::revert(const QStringList &files, bool revertStaging)
QString errorMessage;
switch (revertI(files, &isDirectory, &errorMessage, revertStaging)) {
case RevertOk:
GitPluginPrivate::instance()->gitVersionControl()->emitFilesChanged(files);
emit GitPluginPrivate::instance()->filesChanged(files);
break;
case RevertCanceled:
break;

View File

@@ -326,7 +326,7 @@ public:
void launchGitK(const QString &workingDirectory, const QString &fileName);
void launchGitK(const QString &workingDirectory) { launchGitK(workingDirectory, QString()); }
bool launchGitGui(const QString &workingDirectory);
Utils::FilePath gitBinDirectory();
Utils::FilePath gitBinDirectory() const;
void launchRepositoryBrowser(const QString &workingDirectory);

View File

@@ -32,7 +32,6 @@
#include "gitconstants.h"
#include "giteditor.h"
#include "gitsubmiteditor.h"
#include "gitversioncontrol.h"
#include "remotedialog.h"
#include "stashdialog.h"
#include "settingspage.h"
@@ -71,6 +70,7 @@
#include <vcsbase/submitfilemodel.h>
#include <vcsbase/vcsbaseeditor.h>
#include <vcsbase/vcsbaseconstants.h>
#include <vcsbase/vcscommand.h>
#include <vcsbase/basevcssubmiteditorfactory.h>
#include <vcsbase/vcsoutputwindow.h>
#include <vcsbase/cleandialog.h>
@@ -78,13 +78,11 @@
#include <QDebug>
#include <QDir>
#include <QFileInfo>
#include <QtPlugin>
#include <QAction>
#include <QApplication>
#include <QFileDialog>
#include <QMenu>
#include <QScopedPointer>
#ifdef WITH_TESTS
#include <QTest>
@@ -100,6 +98,29 @@ using namespace VcsBase;
namespace Git {
namespace Internal {
class GitTopicCache : public Core::IVersionControl::TopicCache
{
public:
GitTopicCache(GitClient *client) :
m_client(client)
{ }
protected:
QString trackFile(const QString &repository) override
{
const QString gitDir = m_client->findGitDirForRepository(repository);
return gitDir.isEmpty() ? QString() : (gitDir + "/HEAD");
}
QString refreshTopic(const QString &repository) override
{
return m_client->synchronousTopic(repository);
}
private:
GitClient *m_client;
};
const unsigned minimumRequiredVersion = 0x010900;
const VcsBaseEditorParameters editorParameters[] = {
@@ -138,7 +159,6 @@ GitPluginPrivate::~GitPluginPrivate()
delete m_branchViewFactory;
}
GitPlugin::~GitPlugin()
{
delete dd;
@@ -311,22 +331,22 @@ void GitPlugin::extensionsInitialized()
}
GitPluginPrivate::GitPluginPrivate()
: VcsBase::VcsBasePluginPrivate(Context(Constants::GIT_CONTEXT))
{
dd = this;
m_gitClient = new GitClient(&m_settings);
setTopicCache(new GitTopicCache(m_gitClient));
m_fileActions.reserve(10);
m_projectActions.reserve(10);
m_repositoryActions.reserve(50);
Context context(Constants::GIT_CONTEXT);
m_gitClient = new GitClient(&m_settings);
auto vc = new GitVersionControl(m_gitClient);
initializeVcs(vc, context);
// Create the settings Page
auto onApply = [this, vc] {
vc->configurationChanged();
auto onApply = [this] {
configurationChanged();
updateRepositoryBrowserAction();
bool gitFoundOk;
QString errorMessage;
@@ -691,11 +711,6 @@ GitPluginPrivate::GitPluginPrivate()
m_gerritPlugin->addToLocator(m_commandLocator);
}
GitVersionControl *GitPluginPrivate::gitVersionControl() const
{
return static_cast<GitVersionControl *>(versionControl());
}
void GitPluginPrivate::diffCurrentFile()
{
const VcsBasePluginState state = currentState();
@@ -1480,6 +1495,153 @@ Gerrit::Internal::GerritPlugin *GitPluginPrivate::gerritPlugin() const
return m_gerritPlugin;
}
QString GitPluginPrivate::displayName() const
{
return QLatin1String("Git");
}
Core::Id GitPluginPrivate::id() const
{
return Core::Id(VcsBase::Constants::VCS_ID_GIT);
}
bool GitPluginPrivate::isVcsFileOrDirectory(const Utils::FilePath &fileName) const
{
if (fileName.fileName().compare(".git", Utils::HostOsInfo::fileNameCaseSensitivity()))
return false;
if (fileName.isDir())
return true;
QFile file(fileName.toString());
if (!file.open(QFile::ReadOnly))
return false;
return file.read(8) == "gitdir: ";
}
bool GitPluginPrivate::isConfigured() const
{
return !m_gitClient->vcsBinary().isEmpty();
}
bool GitPluginPrivate::supportsOperation(Operation operation) const
{
if (!isConfigured())
return false;
switch (operation) {
case AddOperation:
case DeleteOperation:
case MoveOperation:
case CreateRepositoryOperation:
case SnapshotOperations:
case AnnotateOperation:
case InitialCheckoutOperation:
return true;
}
return false;
}
bool GitPluginPrivate::vcsOpen(const QString & /*fileName*/)
{
return false;
}
bool GitPluginPrivate::vcsAdd(const QString & fileName)
{
const QFileInfo fi(fileName);
return m_gitClient->synchronousAdd(fi.absolutePath(), {fi.fileName()});
}
bool GitPluginPrivate::vcsDelete(const QString & fileName)
{
const QFileInfo fi(fileName);
return m_gitClient->synchronousDelete(fi.absolutePath(), true, {fi.fileName()});
}
bool GitPluginPrivate::vcsMove(const QString &from, const QString &to)
{
const QFileInfo fromInfo(from);
const QFileInfo toInfo(to);
return m_gitClient->synchronousMove(fromInfo.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath());
}
bool GitPluginPrivate::vcsCreateRepository(const QString &directory)
{
return m_gitClient->synchronousInit(directory);
}
QString GitPluginPrivate::vcsTopic(const QString &directory)
{
QString topic = Core::IVersionControl::vcsTopic(directory);
const QString commandInProgress = m_gitClient->commandInProgressDescription(directory);
if (!commandInProgress.isEmpty())
topic += " (" + commandInProgress + ')';
return topic;
}
Core::ShellCommand *GitPluginPrivate::createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory,
const QString &localName,
const QStringList &extraArgs)
{
QStringList args = {"clone", "--progress"};
args << extraArgs << url << localName;
auto command = new VcsBase::VcsCommand(baseDirectory.toString(), m_gitClient->processEnvironment());
command->addFlags(VcsBase::VcsCommand::SuppressStdErr);
command->addJob({m_gitClient->vcsBinary(), args}, -1);
return command;
}
GitPluginPrivate::RepoUrl GitPluginPrivate::getRepoUrl(const QString &location) const
{
return GitRemote(location);
}
QStringList GitPluginPrivate::additionalToolsPath() const
{
QStringList res = m_gitClient->settings().searchPathList();
const QString binaryPath = m_gitClient->gitBinDirectory().toString();
if (!binaryPath.isEmpty() && !res.contains(binaryPath))
res << binaryPath;
return res;
}
bool GitPluginPrivate::managesDirectory(const QString &directory, QString *topLevel) const
{
const QString topLevelFound = m_gitClient->findRepositoryForDirectory(directory);
if (topLevel)
*topLevel = topLevelFound;
return !topLevelFound.isEmpty();
}
bool GitPluginPrivate::managesFile(const QString &workingDirectory, const QString &fileName) const
{
return m_gitClient->managesFile(workingDirectory, fileName);
}
QStringList GitPluginPrivate::unmanagedFiles(const QString &workingDir,
const QStringList &filePaths) const
{
return m_gitClient->unmanagedFiles(workingDir, filePaths);
}
bool GitPluginPrivate::vcsAnnotate(const QString &file, int line)
{
const QFileInfo fi(file);
m_gitClient->annotate(fi.absolutePath(), fi.fileName(), QString(), line);
return true;
}
void GitPluginPrivate::emitFilesChanged(const QStringList &l)
{
emit filesChanged(l);
}
void GitPluginPrivate::emitRepositoryChanged(const QString &r)
{
emit repositoryChanged(r);
}
#ifdef WITH_TESTS
void GitPlugin::testStatusParsing_data()

View File

@@ -57,7 +57,6 @@ namespace Internal { class GerritPlugin; }
namespace Git {
namespace Internal {
class GitVersionControl;
class GitClient;
class CommitData;
class StashDialog;
@@ -75,11 +74,43 @@ public:
GitPluginPrivate();
~GitPluginPrivate() final;
// IVersionControl
QString displayName() const final;
Core::Id id() const final;
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final;
bool managesDirectory(const QString &directory, QString *topLevel) const final;
bool managesFile(const QString &workingDirectory, const QString &fileName) const final;
QStringList unmanagedFiles(const QString &workingDir, const QStringList &filePaths) const final;
bool isConfigured() const final;
bool supportsOperation(Operation operation) const final;
bool vcsOpen(const QString &fileName) final;
bool vcsAdd(const QString &fileName) final;
bool vcsDelete(const QString &filename) final;
bool vcsMove(const QString &from, const QString &to) final;
bool vcsCreateRepository(const QString &directory) final;
bool vcsAnnotate(const QString &file, int line) final;
QString vcsTopic(const QString &directory) final;
Core::ShellCommand *createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory,
const QString &localName,
const QStringList &extraArgs) final;
RepoUrl getRepoUrl(const QString &location) const override;
QStringList additionalToolsPath() const final;
void emitFilesChanged(const QStringList &);
void emitRepositoryChanged(const QString &);
///
static GitPluginPrivate *instance();
static GitClient *client();
GitVersionControl *gitVersionControl() const;
Gerrit::Internal::GerritPlugin *gerritPlugin() const;
bool isCommitEditorOpen() const;
static QString msgRepositoryLabel(const QString &repository);

View File

@@ -103,7 +103,7 @@ GitSubmitEditor::GitSubmitEditor(const VcsBaseSubmitEditorParameters *parameters
{
connect(this, &VcsBaseSubmitEditor::diffSelectedRows, this, &GitSubmitEditor::slotDiffSelected);
connect(submitEditorWidget(), &GitSubmitEditorWidget::show, this, &GitSubmitEditor::showCommit);
connect(GitPluginPrivate::instance()->versionControl(), &Core::IVersionControl::repositoryChanged,
connect(GitPluginPrivate::instance(), &Core::IVersionControl::repositoryChanged,
this, &GitSubmitEditor::forceUpdateFileModel);
connect(&m_fetchWatcher, &QFutureWatcher<CommitDataFetchResult>::finished,
this, &GitSubmitEditor::commitDataRetrieved);

View File

@@ -1,218 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "gitversioncontrol.h"
#include "gitclient.h"
#include "gitutils.h"
#include <vcsbase/vcsbaseconstants.h>
#include <vcsbase/vcscommand.h>
#include <utils/hostosinfo.h>
#include <QFileInfo>
#include <QProcessEnvironment>
namespace Git {
namespace Internal {
class GitTopicCache : public Core::IVersionControl::TopicCache
{
public:
GitTopicCache(GitClient *client) :
m_client(client)
{ }
protected:
QString trackFile(const QString &repository) override
{
const QString gitDir = m_client->findGitDirForRepository(repository);
return gitDir.isEmpty() ? QString() : (gitDir + "/HEAD");
}
QString refreshTopic(const QString &repository) override
{
return m_client->synchronousTopic(repository);
}
private:
GitClient *m_client;
};
GitVersionControl::GitVersionControl(GitClient *client) :
m_client(client)
{
setTopicCache(new GitTopicCache(client));
}
QString GitVersionControl::displayName() const
{
return QLatin1String("Git");
}
Core::Id GitVersionControl::id() const
{
return Core::Id(VcsBase::Constants::VCS_ID_GIT);
}
bool GitVersionControl::isVcsFileOrDirectory(const Utils::FilePath &fileName) const
{
if (fileName.fileName().compare(".git", Utils::HostOsInfo::fileNameCaseSensitivity()))
return false;
if (fileName.isDir())
return true;
QFile file(fileName.toString());
if (!file.open(QFile::ReadOnly))
return false;
return file.read(8) == "gitdir: ";
}
bool GitVersionControl::isConfigured() const
{
return !m_client->vcsBinary().isEmpty();
}
bool GitVersionControl::supportsOperation(Operation operation) const
{
if (!isConfigured())
return false;
switch (operation) {
case AddOperation:
case DeleteOperation:
case MoveOperation:
case CreateRepositoryOperation:
case SnapshotOperations:
case AnnotateOperation:
case InitialCheckoutOperation:
return true;
}
return false;
}
bool GitVersionControl::vcsOpen(const QString & /*fileName*/)
{
return false;
}
bool GitVersionControl::vcsAdd(const QString & fileName)
{
const QFileInfo fi(fileName);
return m_client->synchronousAdd(fi.absolutePath(), {fi.fileName()});
}
bool GitVersionControl::vcsDelete(const QString & fileName)
{
const QFileInfo fi(fileName);
return m_client->synchronousDelete(fi.absolutePath(), true, {fi.fileName()});
}
bool GitVersionControl::vcsMove(const QString &from, const QString &to)
{
const QFileInfo fromInfo(from);
const QFileInfo toInfo(to);
return m_client->synchronousMove(fromInfo.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath());
}
bool GitVersionControl::vcsCreateRepository(const QString &directory)
{
return m_client->synchronousInit(directory);
}
QString GitVersionControl::vcsTopic(const QString &directory)
{
QString topic = Core::IVersionControl::vcsTopic(directory);
const QString commandInProgress = m_client->commandInProgressDescription(directory);
if (!commandInProgress.isEmpty())
topic += " (" + commandInProgress + ')';
return topic;
}
Core::ShellCommand *GitVersionControl::createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory,
const QString &localName,
const QStringList &extraArgs)
{
QStringList args = {"clone", "--progress"};
args << extraArgs << url << localName;
auto command = new VcsBase::VcsCommand(baseDirectory.toString(), m_client->processEnvironment());
command->addFlags(VcsBase::VcsCommand::SuppressStdErr);
command->addJob({m_client->vcsBinary(), args}, -1);
return command;
}
GitVersionControl::RepoUrl GitVersionControl::getRepoUrl(const QString &location) const
{
return GitRemote(location);
}
QStringList GitVersionControl::additionalToolsPath() const
{
QStringList res = m_client->settings().searchPathList();
const QString binaryPath = m_client->gitBinDirectory().toString();
if (!binaryPath.isEmpty() && !res.contains(binaryPath))
res << binaryPath;
return res;
}
bool GitVersionControl::managesDirectory(const QString &directory, QString *topLevel) const
{
const QString topLevelFound = m_client->findRepositoryForDirectory(directory);
if (topLevel)
*topLevel = topLevelFound;
return !topLevelFound.isEmpty();
}
bool GitVersionControl::managesFile(const QString &workingDirectory, const QString &fileName) const
{
return m_client->managesFile(workingDirectory, fileName);
}
QStringList GitVersionControl::unmanagedFiles(const QString &workingDir,
const QStringList &filePaths) const
{
return m_client->unmanagedFiles(workingDir, filePaths);
}
bool GitVersionControl::vcsAnnotate(const QString &file, int line)
{
const QFileInfo fi(file);
m_client->annotate(fi.absolutePath(), fi.fileName(), QString(), line);
return true;
}
void GitVersionControl::emitFilesChanged(const QStringList &l)
{
emit filesChanged(l);
}
void GitVersionControl::emitRepositoryChanged(const QString &r)
{
emit repositoryChanged(r);
}
} // Internal
} // Git

View File

@@ -1,79 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include <coreplugin/iversioncontrol.h>
namespace Git {
namespace Internal {
class GitClient;
// Just a proxy for GitPlugin
class GitVersionControl : public Core::IVersionControl
{
Q_OBJECT
public:
explicit GitVersionControl(GitClient *client);
QString displayName() const final;
Core::Id id() const final;
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final;
bool managesDirectory(const QString &directory, QString *topLevel) const final;
bool managesFile(const QString &workingDirectory, const QString &fileName) const final;
QStringList unmanagedFiles(const QString &workingDir, const QStringList &filePaths) const final;
bool isConfigured() const final;
bool supportsOperation(Operation operation) const final;
bool vcsOpen(const QString &fileName) final;
bool vcsAdd(const QString &fileName) final;
bool vcsDelete(const QString &filename) final;
bool vcsMove(const QString &from, const QString &to) final;
bool vcsCreateRepository(const QString &directory) final;
bool vcsAnnotate(const QString &file, int line) final;
QString vcsTopic(const QString &directory) final;
Core::ShellCommand *createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory,
const QString &localName,
const QStringList &extraArgs) final;
RepoUrl getRepoUrl(const QString &location) const override;
QStringList additionalToolsPath() const final;
void emitFilesChanged(const QStringList &);
void emitRepositoryChanged(const QString &);
private:
GitClient *m_client;
};
} // Internal
} // Git

View File

@@ -26,7 +26,6 @@
#include "mergetool.h"
#include "gitclient.h"
#include "gitplugin.h"
#include "gitversioncontrol.h"
#include <coreplugin/documentmanager.h>
#include <coreplugin/icore.h>
@@ -265,7 +264,7 @@ void MergeTool::done()
.arg(exitCode));
}
GitPluginPrivate::client()->continueCommandIfNeeded(workingDirectory, exitCode == 0);
GitPluginPrivate::instance()->gitVersionControl()->emitRepositoryChanged(workingDirectory);
GitPluginPrivate::instance()->emitRepositoryChanged(workingDirectory);
deleteLater();
}

View File

@@ -8,7 +8,6 @@ add_qtc_plugin(Mercurial
mercurialclient.cpp mercurialclient.h
mercurialcommitpanel.ui
mercurialcommitwidget.cpp mercurialcommitwidget.h
mercurialcontrol.cpp mercurialcontrol.h
mercurialeditor.cpp mercurialeditor.h
mercurialplugin.cpp mercurialplugin.h
mercurialsettings.cpp mercurialsettings.h

View File

@@ -1,7 +1,6 @@
include(../../qtcreatorplugin.pri)
SOURCES += mercurialplugin.cpp \
optionspage.cpp \
mercurialcontrol.cpp \
mercurialclient.cpp \
annotationhighlighter.cpp \
mercurialeditor.cpp \
@@ -14,7 +13,6 @@ SOURCES += mercurialplugin.cpp \
HEADERS += mercurialplugin.h \
constants.h \
optionspage.h \
mercurialcontrol.h \
mercurialclient.h \
annotationhighlighter.h \
mercurialeditor.h \

View File

@@ -25,8 +25,6 @@ QtcPlugin {
"mercurialcommitpanel.ui",
"mercurialcommitwidget.cpp",
"mercurialcommitwidget.h",
"mercurialcontrol.cpp",
"mercurialcontrol.h",
"mercurialeditor.cpp",
"mercurialeditor.h",
"mercurialplugin.cpp",

View File

@@ -1,206 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 Brian McGillion
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "mercurialcontrol.h"
#include "mercurialclient.h"
#include <vcsbase/vcsbaseclientsettings.h>
#include <vcsbase/vcsbaseconstants.h>
#include <vcsbase/vcscommand.h>
#include <coreplugin/vcsmanager.h>
#include <utils/fileutils.h>
#include <QFileInfo>
#include <QProcessEnvironment>
#include <QVariant>
#include <QStringList>
#include <QDir>
namespace Mercurial {
namespace Internal {
class MercurialTopicCache : public Core::IVersionControl::TopicCache
{
public:
MercurialTopicCache(MercurialClient *client) : m_client(client) {}
protected:
QString trackFile(const QString &repository) override
{
return repository + QLatin1String("/.hg/branch");
}
QString refreshTopic(const QString &repository) override
{
return m_client->branchQuerySync(repository);
}
private:
MercurialClient *m_client;
};
MercurialControl::MercurialControl(MercurialClient *client) :
mercurialClient(client)
{
setTopicCache(new MercurialTopicCache(client));
}
QString MercurialControl::displayName() const
{
return tr("Mercurial");
}
Core::Id MercurialControl::id() const
{
return {VcsBase::Constants::VCS_ID_MERCURIAL};
}
bool MercurialControl::isVcsFileOrDirectory(const Utils::FilePath &fileName) const
{
return mercurialClient->isVcsDirectory(fileName);
}
bool MercurialControl::managesDirectory(const QString &directory, QString *topLevel) const
{
QFileInfo dir(directory);
const QString topLevelFound = mercurialClient->findTopLevelForFile(dir);
if (topLevel)
*topLevel = topLevelFound;
return !topLevelFound.isEmpty();
}
bool MercurialControl::managesFile(const QString &workingDirectory, const QString &fileName) const
{
return mercurialClient->managesFile(workingDirectory, fileName);
}
bool MercurialControl::isConfigured() const
{
const Utils::FilePath binary = mercurialClient->vcsBinary();
if (binary.isEmpty())
return false;
QFileInfo fi = binary.toFileInfo();
return fi.exists() && fi.isFile() && fi.isExecutable();
}
bool MercurialControl::supportsOperation(Operation operation) const
{
bool supported = isConfigured();
switch (operation) {
case Core::IVersionControl::AddOperation:
case Core::IVersionControl::DeleteOperation:
case Core::IVersionControl::MoveOperation:
case Core::IVersionControl::CreateRepositoryOperation:
case Core::IVersionControl::AnnotateOperation:
case Core::IVersionControl::InitialCheckoutOperation:
break;
case Core::IVersionControl::SnapshotOperations:
supported = false;
break;
}
return supported;
}
bool MercurialControl::vcsOpen(const QString &filename)
{
Q_UNUSED(filename)
return true;
}
bool MercurialControl::vcsAdd(const QString &filename)
{
const QFileInfo fi(filename);
return mercurialClient->synchronousAdd(fi.absolutePath(), fi.fileName());
}
bool MercurialControl::vcsDelete(const QString &filename)
{
const QFileInfo fi(filename);
return mercurialClient->synchronousRemove(fi.absolutePath(), fi.fileName());
}
bool MercurialControl::vcsMove(const QString &from, const QString &to)
{
const QFileInfo fromInfo(from);
const QFileInfo toInfo(to);
return mercurialClient->synchronousMove(fromInfo.absolutePath(),
fromInfo.absoluteFilePath(),
toInfo.absoluteFilePath());
}
bool MercurialControl::vcsCreateRepository(const QString &directory)
{
return mercurialClient->synchronousCreateRepository(directory);
}
bool MercurialControl::vcsAnnotate(const QString &file, int line)
{
const QFileInfo fi(file);
mercurialClient->annotate(fi.absolutePath(), fi.fileName(), QString(), line);
return true;
}
Core::ShellCommand *MercurialControl::createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory,
const QString &localName,
const QStringList &extraArgs)
{
QStringList args;
args << QLatin1String("clone") << extraArgs << url << localName;
auto command = new VcsBase::VcsCommand(baseDirectory.toString(),
mercurialClient->processEnvironment());
command->addJob({mercurialClient->vcsBinary(), args}, -1);
return command;
}
bool MercurialControl::sccManaged(const QString &filename)
{
const QFileInfo fi(filename);
QString topLevel;
const bool managed = managesDirectory(fi.absolutePath(), &topLevel);
if (!managed || topLevel.isEmpty())
return false;
const QDir topLevelDir(topLevel);
return mercurialClient->manifestSync(topLevel, topLevelDir.relativeFilePath(filename));
}
void MercurialControl::changed(const QVariant &v)
{
switch (v.type()) {
case QVariant::String:
emit repositoryChanged(v.toString());
break;
case QVariant::StringList:
emit filesChanged(v.toStringList());
break;
default:
break;
}
}
} // namespace Internal
} // namespace Mercurial

View File

@@ -1,80 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 Brian McGillion
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include <coreplugin/iversioncontrol.h>
QT_BEGIN_NAMESPACE
class QVariant;
QT_END_NAMESPACE
namespace Mercurial {
namespace Internal {
class MercurialClient;
// Implements just the basics of the Version Control Interface
// MercurialClient handles all the work.
class MercurialControl : public Core::IVersionControl
{
Q_OBJECT
public:
explicit MercurialControl(MercurialClient *mercurialClient);
QString displayName() const final;
Core::Id id() const final;
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final;
bool managesDirectory(const QString &filename, QString *topLevel = nullptr) const final;
bool managesFile(const QString &workingDirectory, const QString &fileName) const final;
bool isConfigured() const final;
bool supportsOperation(Operation operation) const final;
bool vcsOpen(const QString &fileName) final;
bool vcsAdd(const QString &filename) final;
bool vcsDelete(const QString &filename) final;
bool vcsMove(const QString &from, const QString &to) final;
bool vcsCreateRepository(const QString &directory) final;
bool vcsAnnotate(const QString &file, int line) final;
Core::ShellCommand *createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory,
const QString &localName,
const QStringList &extraArgs) final;
bool sccManaged(const QString &filename);
// To be connected to the HgTask's success signal to emit the repository/
// files changed signals according to the variant's type:
// String -> repository, StringList -> files
void changed(const QVariant&);
private:
MercurialClient *const mercurialClient;
};
} // namespace Internal
} // namespace Mercurial

View File

@@ -27,7 +27,6 @@
#include "optionspage.h"
#include "constants.h"
#include "mercurialclient.h"
#include "mercurialcontrol.h"
#include "mercurialeditor.h"
#include "revertdialog.h"
#include "srcdestdialog.h"
@@ -55,6 +54,7 @@
#include <vcsbase/vcsbaseeditor.h>
#include <vcsbase/vcsbaseconstants.h>
#include <vcsbase/vcsoutputwindow.h>
#include <vcsbase/vcscommand.h>
#include <QtPlugin>
#include <QAction>
@@ -75,6 +75,26 @@ using namespace Utils;
namespace Mercurial {
namespace Internal {
class MercurialTopicCache : public Core::IVersionControl::TopicCache
{
public:
MercurialTopicCache(MercurialClient *client) : m_client(client) {}
protected:
QString trackFile(const QString &repository) override
{
return repository + QLatin1String("/.hg/branch");
}
QString refreshTopic(const QString &repository) override
{
return m_client->branchQuerySync(repository);
}
private:
MercurialClient *m_client;
};
static const VcsBaseEditorParameters editorParameters[] = {
{
LogOutput,
@@ -107,6 +127,34 @@ class MercurialPluginPrivate final : public VcsBase::VcsBasePluginPrivate
public:
MercurialPluginPrivate();
// IVersionControl
QString displayName() const final;
Core::Id id() const final;
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final;
bool managesDirectory(const QString &filename, QString *topLevel = nullptr) const final;
bool managesFile(const QString &workingDirectory, const QString &fileName) const final;
bool isConfigured() const final;
bool supportsOperation(Operation operation) const final;
bool vcsOpen(const QString &fileName) final;
bool vcsAdd(const QString &filename) final;
bool vcsDelete(const QString &filename) final;
bool vcsMove(const QString &from, const QString &to) final;
bool vcsCreateRepository(const QString &directory) final;
bool vcsAnnotate(const QString &file, int line) final;
Core::ShellCommand *createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory,
const QString &localName,
const QStringList &extraArgs) final;
bool sccManaged(const QString &filename);
// To be connected to the HgTask's success signal to emit the repository/
// files changed signals according to the variant's type:
// String -> repository, StringList -> files
void changed(const QVariant&);
private:
void updateActions(VcsBase::VcsBasePluginPrivate::ActionState) final;
bool submitEditorAboutToClose() final;
@@ -145,9 +193,8 @@ private:
// Variables
MercurialSettings m_settings;
MercurialClient m_client{&m_settings};
MercurialControl m_control{&m_client};
OptionsPage m_optionsPage{[this] { m_control.configurationChanged(); }, &m_settings};
OptionsPage m_optionsPage{[this] { configurationChanged(); }, &m_settings};
Core::CommandLocator *m_commandLocator = nullptr;
Core::ActionContainer *m_mercurialContainer = nullptr;
@@ -191,13 +238,15 @@ void MercurialPlugin::extensionsInitialized()
}
MercurialPluginPrivate::MercurialPluginPrivate()
: VcsBase::VcsBasePluginPrivate(Core::Context(Constants::MERCURIAL_CONTEXT))
{
dd = this;
setTopicCache(new MercurialTopicCache(&m_client));
Core::Context context(Constants::MERCURIAL_CONTEXT);
initializeVcs(&m_control, context);
connect(&m_client, &VcsBaseClient::changed, &m_control, &MercurialControl::changed);
connect(&m_client, &VcsBaseClient::changed, this, &MercurialPluginPrivate::changed);
connect(&m_client, &MercurialClient::needUpdate, this, &MercurialPluginPrivate::update);
const auto describeFunc = [this](const QString &source, const QString &id) {
@@ -593,7 +642,7 @@ void MercurialPluginPrivate::showCommitWidget(const QList<VcsBaseClient::StatusI
arg(QDir::toNativeSeparators(m_submitRepository));
commitEditor->document()->setPreferredDisplayName(msg);
QString branch = m_control.vcsTopic(m_submitRepository);
const QString branch = vcsTopic(m_submitRepository);
commitEditor->setFields(m_submitRepository, branch,
m_settings.stringValue(MercurialSettings::userNameKey),
m_settings.stringValue(MercurialSettings::userEmailKey), status);
@@ -669,6 +718,139 @@ void MercurialPluginPrivate::updateActions(VcsBasePluginPrivate::ActionState as)
repoAction->setEnabled(repoEnabled);
}
QString MercurialPluginPrivate::displayName() const
{
return tr("Mercurial");
}
Core::Id MercurialPluginPrivate::id() const
{
return {VcsBase::Constants::VCS_ID_MERCURIAL};
}
bool MercurialPluginPrivate::isVcsFileOrDirectory(const Utils::FilePath &fileName) const
{
return m_client.isVcsDirectory(fileName);
}
bool MercurialPluginPrivate::managesDirectory(const QString &directory, QString *topLevel) const
{
QFileInfo dir(directory);
const QString topLevelFound = m_client.findTopLevelForFile(dir);
if (topLevel)
*topLevel = topLevelFound;
return !topLevelFound.isEmpty();
}
bool MercurialPluginPrivate::managesFile(const QString &workingDirectory, const QString &fileName) const
{
return m_client.managesFile(workingDirectory, fileName);
}
bool MercurialPluginPrivate::isConfigured() const
{
const Utils::FilePath binary = m_client.vcsBinary();
if (binary.isEmpty())
return false;
QFileInfo fi = binary.toFileInfo();
return fi.exists() && fi.isFile() && fi.isExecutable();
}
bool MercurialPluginPrivate::supportsOperation(Operation operation) const
{
bool supported = isConfigured();
switch (operation) {
case Core::IVersionControl::AddOperation:
case Core::IVersionControl::DeleteOperation:
case Core::IVersionControl::MoveOperation:
case Core::IVersionControl::CreateRepositoryOperation:
case Core::IVersionControl::AnnotateOperation:
case Core::IVersionControl::InitialCheckoutOperation:
break;
case Core::IVersionControl::SnapshotOperations:
supported = false;
break;
}
return supported;
}
bool MercurialPluginPrivate::vcsOpen(const QString &filename)
{
Q_UNUSED(filename)
return true;
}
bool MercurialPluginPrivate::vcsAdd(const QString &filename)
{
const QFileInfo fi(filename);
return m_client.synchronousAdd(fi.absolutePath(), fi.fileName());
}
bool MercurialPluginPrivate::vcsDelete(const QString &filename)
{
const QFileInfo fi(filename);
return m_client.synchronousRemove(fi.absolutePath(), fi.fileName());
}
bool MercurialPluginPrivate::vcsMove(const QString &from, const QString &to)
{
const QFileInfo fromInfo(from);
const QFileInfo toInfo(to);
return m_client.synchronousMove(fromInfo.absolutePath(),
fromInfo.absoluteFilePath(),
toInfo.absoluteFilePath());
}
bool MercurialPluginPrivate::vcsCreateRepository(const QString &directory)
{
return m_client.synchronousCreateRepository(directory);
}
bool MercurialPluginPrivate::vcsAnnotate(const QString &file, int line)
{
const QFileInfo fi(file);
m_client.annotate(fi.absolutePath(), fi.fileName(), QString(), line);
return true;
}
Core::ShellCommand *MercurialPluginPrivate::createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory,
const QString &localName,
const QStringList &extraArgs)
{
QStringList args;
args << QLatin1String("clone") << extraArgs << url << localName;
auto command = new VcsBase::VcsCommand(baseDirectory.toString(),
m_client.processEnvironment());
command->addJob({m_client.vcsBinary(), args}, -1);
return command;
}
bool MercurialPluginPrivate::sccManaged(const QString &filename)
{
const QFileInfo fi(filename);
QString topLevel;
const bool managed = managesDirectory(fi.absolutePath(), &topLevel);
if (!managed || topLevel.isEmpty())
return false;
const QDir topLevelDir(topLevel);
return m_client.manifestSync(topLevel, topLevelDir.relativeFilePath(filename));
}
void MercurialPluginPrivate::changed(const QVariant &v)
{
switch (v.type()) {
case QVariant::String:
emit repositoryChanged(v.toString());
break;
case QVariant::StringList:
emit filesChanged(v.toStringList());
break;
default:
break;
}
}
#ifdef WITH_TESTS
void MercurialPlugin::testDiffFileResolving_data()

View File

@@ -10,7 +10,6 @@ add_qtc_plugin(Perforce
perforcesettings.cpp perforcesettings.h
perforcesubmiteditor.cpp perforcesubmiteditor.h
perforcesubmiteditorwidget.cpp perforcesubmiteditorwidget.h
perforceversioncontrol.cpp perforceversioncontrol.h
promptdialog.ui
settingspage.cpp settingspage.h settingspage.ui
submitpanel.ui

View File

@@ -8,7 +8,6 @@ HEADERS += \
changenumberdialog.h \
perforcesubmiteditor.h \
pendingchangesdialog.h \
perforceversioncontrol.h \
perforcesettings.h \
annotationhighlighter.h \
perforcesubmiteditorwidget.h
@@ -20,7 +19,6 @@ SOURCES += perforceplugin.cpp \
changenumberdialog.cpp \
perforcesubmiteditor.cpp \
pendingchangesdialog.cpp \
perforceversioncontrol.cpp \
perforcesettings.cpp \
annotationhighlighter.cpp \
perforcesubmiteditorwidget.cpp

View File

@@ -31,8 +31,6 @@ QtcPlugin {
"perforcesubmiteditor.h",
"perforcesubmiteditorwidget.cpp",
"perforcesubmiteditorwidget.h",
"perforceversioncontrol.cpp",
"perforceversioncontrol.h",
"settingspage.cpp",
"settingspage.h",
"settingspage.ui",

View File

@@ -29,9 +29,9 @@
#include "pendingchangesdialog.h"
#include "perforceeditor.h"
#include "perforcesubmiteditor.h"
#include "perforceversioncontrol.h"
#include "perforcechecker.h"
#include "settingspage.h"
#include "perforcesettings.h"
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/actioncontainer.h>
@@ -49,6 +49,7 @@
#include <utils/qtcassert.h>
#include <utils/synchronousprocess.h>
#include <utils/temporarydirectory.h>
#include <vcsbase/basevcseditorfactory.h>
#include <vcsbase/basevcssubmiteditorfactory.h>
#include <vcsbase/vcsbaseeditor.h>
@@ -191,12 +192,10 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString *er
}
PerforcePluginPrivate::PerforcePluginPrivate()
: VcsBase::VcsBasePluginPrivate(Context(PERFORCE_CONTEXT))
{
Context context(PERFORCE_CONTEXT);
auto vcsCtrl = new PerforceVersionControl(this);
initializeVcs(vcsCtrl, context);
dd = this;
m_settings.fromSettings(ICore::settings());
@@ -442,7 +441,7 @@ void PerforcePluginPrivate::revertCurrentFile()
PerforceResponse result2 = runP4Cmd(state.currentFileTopLevel(), args,
CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
if (!result2.error)
perforceVersionControl()->emitFilesChanged(QStringList(state.currentFile()));
emit filesChanged(QStringList(state.currentFile()));
}
void PerforcePluginPrivate::diffCurrentFile()
@@ -514,11 +513,11 @@ void PerforcePluginPrivate::updateCheckout(const QString &workingDir, const QStr
CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
if (dirs.empty()) {
if (!workingDir.isEmpty())
perforceVersionControl()->emitRepositoryChanged(workingDir);
emit repositoryChanged(workingDir);
} else {
const QChar slash = QLatin1Char('/');
foreach (const QString &dir, dirs)
perforceVersionControl()->emitRepositoryChanged(workingDir + slash + dir);
emit repositoryChanged(workingDir + slash + dir);
}
}
@@ -794,9 +793,9 @@ void PerforcePluginPrivate::updateActions(VcsBasePluginPrivate::ActionState as)
m_revertUnchangedAction->setParameter(projectName);
}
bool PerforcePluginPrivate::managesDirectory(const QString &directory, QString *topLevel /* = 0 */)
bool PerforcePluginPrivate::managesDirectory(const QString &directory, QString *topLevel /* = 0 */) const
{
const bool rc = managesDirectoryFstat(directory);
const bool rc = const_cast<PerforcePluginPrivate *>(this)->managesDirectoryFstat(directory);
if (topLevel) {
if (rc)
*topLevel = m_settings.topLevelSymLinkTarget();
@@ -942,6 +941,99 @@ PerforcePluginPrivate::createTemporaryArgumentFile(const QStringList &extraArgs,
return rc;
}
bool PerforcePluginPrivate::isVcsFileOrDirectory(const Utils::FilePath &fileName) const
{
Q_UNUSED(fileName)
return false; // Perforce does not seem to litter its files into the source tree.
}
bool PerforcePluginPrivate::isConfigured() const
{
const QString binary = settings().p4BinaryPath();
if (binary.isEmpty())
return false;
QFileInfo fi(binary);
return fi.exists() && fi.isFile() && fi.isExecutable();
}
bool PerforcePluginPrivate::supportsOperation(Operation operation) const
{
bool supported = isConfigured();
switch (operation) {
case AddOperation:
case DeleteOperation:
case MoveOperation:
case AnnotateOperation:
return supported;
case CreateRepositoryOperation:
case SnapshotOperations:
case InitialCheckoutOperation:
break;
}
return false;
}
Core::IVersionControl::OpenSupportMode PerforcePluginPrivate::openSupportMode(const QString &fileName) const
{
Q_UNUSED(fileName)
return OpenOptional;
}
bool PerforcePluginPrivate::vcsOpen(const QString &fileName)
{
const QFileInfo fi(fileName);
return vcsOpen(fi.absolutePath(), fi.fileName(), true);
}
Core::IVersionControl::SettingsFlags PerforcePluginPrivate::settingsFlags() const
{
SettingsFlags rc;
if (m_settings.autoOpen())
rc|= AutoOpen;
return rc;
}
bool PerforcePluginPrivate::vcsAdd(const QString &fileName)
{
const QFileInfo fi(fileName);
return vcsAdd(fi.absolutePath(), fi.fileName());
}
bool PerforcePluginPrivate::vcsDelete(const QString &fileName)
{
const QFileInfo fi(fileName);
return vcsDelete(fi.absolutePath(), fi.fileName());
}
bool PerforcePluginPrivate::vcsMove(const QString &from, const QString &to)
{
const QFileInfo fromInfo(from);
const QFileInfo toInfo(to);
return vcsMove(fromInfo.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath());
}
bool PerforcePluginPrivate::vcsCreateRepository(const QString &)
{
return false;
}
bool PerforcePluginPrivate::vcsAnnotate(const QString &file, int line)
{
const QFileInfo fi(file);
vcsAnnotate(fi.absolutePath(), fi.fileName(), QString(), line);
return true;
}
QString PerforcePluginPrivate::vcsOpenText() const
{
return tr("&Edit");
}
QString PerforcePluginPrivate::vcsMakeWritableText() const
{
return tr("&Hijack");
}
// Run messages
static inline QString msgNotStarted(const QString &cmd)
@@ -1415,7 +1507,7 @@ void PerforcePluginPrivate::setSettings(const Settings &newSettings)
dd->m_managedDirectoryCache.clear();
dd->m_settings.toSettings(ICore::settings());
getTopLevel();
perforceVersionControl()->emitConfigurationChanged();
emit dd->configurationChanged();
}
}
@@ -1462,11 +1554,6 @@ QString PerforcePluginPrivate::fileNameFromPerforceName(const QString& perforceN
return dd->m_settings.mapToFileSystem(p4fileSpec);
}
PerforceVersionControl *PerforcePluginPrivate::perforceVersionControl()
{
return static_cast<PerforceVersionControl *>(dd->versionControl());
}
void PerforcePluginPrivate::setTopLevel(const QString &topLevel)
{
if (m_settings.topLevel() == topLevel)

View File

@@ -29,6 +29,8 @@
#include <coreplugin/editormanager/ieditorfactory.h>
#include <coreplugin/iversioncontrol.h>
#include <vcsbase/vcsbaseconstants.h>
#include <vcsbase/vcsbaseplugin.h>
#include <QObject>
@@ -76,8 +78,28 @@ class PerforcePluginPrivate final : public VcsBase::VcsBasePluginPrivate
public:
PerforcePluginPrivate();
bool managesDirectory(const QString &directory, QString *topLevel = nullptr);
bool managesFile(const QString &workingDirectory, const QString &fileName) const;
// IVersionControl
QString displayName() const final { return {"perforce"}; }
Core::Id id() const final { return Core::Id(VcsBase::Constants::VCS_ID_PERFORCE); }
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final;
bool managesDirectory(const QString &directory, QString *topLevel = nullptr) const final;
bool managesFile(const QString &workingDirectory, const QString &fileName) const final;
bool isConfigured() const final;
bool supportsOperation(Operation operation) const final;
OpenSupportMode openSupportMode(const QString &fileName) const final;
bool vcsOpen(const QString &fileName) final;
SettingsFlags settingsFlags() const final;
bool vcsAdd(const QString &fileName) final;
bool vcsDelete(const QString &filename) final;
bool vcsMove(const QString &from, const QString &to) final;
bool vcsCreateRepository(const QString &directory) final;
bool vcsAnnotate(const QString &file, int line) final;
QString vcsOpenText() const final;
QString vcsMakeWritableText() const final;
///
bool vcsOpen(const QString &workingDir, const QString &fileName, bool silently = false);
bool vcsAdd(const QString &workingDir, const QString &fileName);
bool vcsDelete(const QString &workingDir, const QString &filename);
@@ -203,8 +225,6 @@ private:
bool revertProject(const QString &workingDir, const QStringList &args, bool unchangedOnly);
bool managesDirectoryFstat(const QString &directory);
static PerforceVersionControl *perforceVersionControl();
Core::CommandLocator *m_commandLocator = nullptr;
Utils::ParameterAction *m_editAction = nullptr;
Utils::ParameterAction *m_addAction = nullptr;

View File

@@ -1,171 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "perforceversioncontrol.h"
#include "perforceplugin.h"
#include "perforcesettings.h"
#include <vcsbase/vcsbaseconstants.h>
#include <QFileInfo>
#include <QDebug>
namespace Perforce {
namespace Internal {
PerforceVersionControl::PerforceVersionControl(PerforcePluginPrivate *plugin) :
m_plugin(plugin)
{ }
QString PerforceVersionControl::displayName() const
{
return QLatin1String("perforce");
}
Core::Id PerforceVersionControl::id() const
{
return Core::Id(VcsBase::Constants::VCS_ID_PERFORCE);
}
bool PerforceVersionControl::isVcsFileOrDirectory(const Utils::FilePath &fileName) const
{
Q_UNUSED(fileName)
return false; // Perforce does not seem to litter its files into the source tree.
}
bool PerforceVersionControl::isConfigured() const
{
const QString binary = m_plugin->settings().p4BinaryPath();
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 AnnotateOperation:
return supported;
case CreateRepositoryOperation:
case SnapshotOperations:
case InitialCheckoutOperation:
break;
}
return false;
}
Core::IVersionControl::OpenSupportMode PerforceVersionControl::openSupportMode(const QString &fileName) const
{
Q_UNUSED(fileName)
return OpenOptional;
}
bool PerforceVersionControl::vcsOpen(const QString &fileName)
{
const QFileInfo fi(fileName);
return m_plugin->vcsOpen(fi.absolutePath(), fi.fileName(), true);
}
Core::IVersionControl::SettingsFlags PerforceVersionControl::settingsFlags() const
{
SettingsFlags rc;
if (m_plugin->settings().autoOpen())
rc|= AutoOpen;
return rc;
}
bool PerforceVersionControl::vcsAdd(const QString &fileName)
{
const QFileInfo fi(fileName);
return m_plugin->vcsAdd(fi.absolutePath(), fi.fileName());
}
bool PerforceVersionControl::vcsDelete(const QString &fileName)
{
const QFileInfo fi(fileName);
return m_plugin->vcsDelete(fi.absolutePath(), fi.fileName());
}
bool PerforceVersionControl::vcsMove(const QString &from, const QString &to)
{
const QFileInfo fromInfo(from);
const QFileInfo toInfo(to);
return m_plugin->vcsMove(fromInfo.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath());
}
bool PerforceVersionControl::vcsCreateRepository(const QString &)
{
return false;
}
bool PerforceVersionControl::vcsAnnotate(const QString &file, int line)
{
const QFileInfo fi(file);
m_plugin->vcsAnnotate(fi.absolutePath(), fi.fileName(), QString(), line);
return true;
}
QString PerforceVersionControl::vcsOpenText() const
{
return tr("&Edit");
}
QString PerforceVersionControl::vcsMakeWritableText() const
{
return tr("&Hijack");
}
bool PerforceVersionControl::managesDirectory(const QString &directory, QString *topLevel) const
{
return m_plugin->managesDirectory(directory, topLevel);
}
bool PerforceVersionControl::managesFile(const QString &workingDirectory, const QString &fileName) const
{
return m_plugin->managesFile(workingDirectory, fileName);
}
void PerforceVersionControl::emitRepositoryChanged(const QString &s)
{
emit repositoryChanged(s);
}
void PerforceVersionControl::emitFilesChanged(const QStringList &l)
{
emit filesChanged(l);
}
void PerforceVersionControl::emitConfigurationChanged()
{
emit configurationChanged();
}
} // Internal
} // Perforce

View File

@@ -1,70 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include <coreplugin/iversioncontrol.h>
namespace Perforce {
namespace Internal {
class PerforcePluginPrivate;
// Just a proxy for PerforcePlugin
class PerforceVersionControl : public Core::IVersionControl
{
Q_OBJECT
public:
explicit PerforceVersionControl(PerforcePluginPrivate *plugin);
QString displayName() const final;
Core::Id id() const final;
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final;
bool managesDirectory(const QString &directory, QString *topLevel = nullptr) const final;
bool managesFile(const QString &workingDirectory, const QString &fileName) const final;
bool isConfigured() const final;
bool supportsOperation(Operation operation) const final;
OpenSupportMode openSupportMode(const QString &fileName) const final;
bool vcsOpen(const QString &fileName) final;
SettingsFlags settingsFlags() const final;
bool vcsAdd(const QString &fileName) final;
bool vcsDelete(const QString &filename) final;
bool vcsMove(const QString &from, const QString &to) final;
bool vcsCreateRepository(const QString &directory) final;
bool vcsAnnotate(const QString &file, int line) final;
QString vcsOpenText() const final;
QString vcsMakeWritableText() const final;
void emitRepositoryChanged(const QString &s);
void emitFilesChanged(const QStringList &l);
void emitConfigurationChanged();
private:
PerforcePluginPrivate *m_plugin;
};
} // namespace Internal
} // namespace Perforce

View File

@@ -5,7 +5,6 @@ add_qtc_plugin(Subversion
settingspage.cpp settingspage.h settingspage.ui
subversionclient.cpp subversionclient.h
subversionconstants.h
subversioncontrol.cpp subversioncontrol.h
subversioneditor.cpp subversioneditor.h
subversionplugin.cpp subversionplugin.h
subversionsettings.cpp subversionsettings.h

View File

@@ -3,7 +3,6 @@ include(../../qtcreatorplugin.pri)
HEADERS += annotationhighlighter.h \
subversionplugin.h \
subversionclient.h \
subversioncontrol.h \
settingspage.h \
subversioneditor.h \
subversionsubmiteditor.h \
@@ -13,7 +12,6 @@ HEADERS += annotationhighlighter.h \
SOURCES += annotationhighlighter.cpp \
subversionplugin.cpp \
subversionclient.cpp \
subversioncontrol.cpp \
settingspage.cpp \
subversioneditor.cpp \
subversionsubmiteditor.cpp \

View File

@@ -20,8 +20,6 @@ QtcPlugin {
"subversionclient.cpp",
"subversionclient.h",
"subversionconstants.h",
"subversioncontrol.cpp",
"subversioncontrol.h",
"subversioneditor.cpp",
"subversioneditor.h",
"subversionplugin.cpp",

View File

@@ -138,7 +138,7 @@ QStringList SubversionClient::addAuthenticationOptions(const VcsBaseClientSettin
return rc;
}
QString SubversionClient::synchronousTopic(const QString &repository)
QString SubversionClient::synchronousTopic(const QString &repository) const
{
QStringList args;

View File

@@ -69,7 +69,7 @@ public:
// Add authorization options to the command line arguments.
static QStringList addAuthenticationOptions(const VcsBase::VcsBaseClientSettings &settings);
QString synchronousTopic(const QString &repository);
QString synchronousTopic(const QString &repository) const;
static QString escapeFile(const QString &file);
static QStringList escapeFiles(const QStringList &files);

View File

@@ -1,190 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "subversioncontrol.h"
#include "subversionclient.h"
#include "subversionconstants.h"
#include "subversionplugin.h"
#include "subversionsettings.h"
#include <vcsbase/vcsbaseconstants.h>
#include <vcsbase/vcsbaseclientsettings.h>
#include <vcsbase/vcscommand.h>
#include <utils/fileutils.h>
#include <QFileInfo>
namespace Subversion {
namespace Internal {
class SubversionTopicCache : public Core::IVersionControl::TopicCache
{
public:
SubversionTopicCache(SubversionPluginPrivate *plugin) :
m_plugin(plugin)
{ }
protected:
QString trackFile(const QString &repository) override
{
return m_plugin->monitorFile(repository);
}
QString refreshTopic(const QString &repository) override
{
return m_plugin->synchronousTopic(repository);
}
private:
SubversionPluginPrivate *m_plugin;
};
SubversionControl::SubversionControl(SubversionPluginPrivate *plugin) :
m_plugin(plugin)
{
setTopicCache(new SubversionTopicCache(plugin));
}
QString SubversionControl::displayName() const
{
return QLatin1String("subversion");
}
Core::Id SubversionControl::id() const
{
return Core::Id(VcsBase::Constants::VCS_ID_SUBVERSION);
}
bool SubversionControl::isVcsFileOrDirectory(const Utils::FilePath &fileName) const
{
return m_plugin->isVcsDirectory(fileName);
}
bool SubversionControl::isConfigured() const
{
const Utils::FilePath binary = m_plugin->client()->vcsBinary();
if (binary.isEmpty())
return false;
QFileInfo fi = binary.toFileInfo();
return fi.exists() && fi.isFile() && fi.isExecutable();
}
bool SubversionControl::supportsOperation(Operation operation) const
{
bool rc = isConfigured();
switch (operation) {
case AddOperation:
case DeleteOperation:
case MoveOperation:
case AnnotateOperation:
case InitialCheckoutOperation:
break;
case CreateRepositoryOperation:
case SnapshotOperations:
rc = false;
break;
}
return rc;
}
bool SubversionControl::vcsOpen(const QString & /* fileName */)
{
// Open for edit: N/A
return true;
}
bool SubversionControl::vcsAdd(const QString &fileName)
{
const QFileInfo fi(fileName);
return m_plugin->vcsAdd(fi.absolutePath(), fi.fileName());
}
bool SubversionControl::vcsDelete(const QString &fileName)
{
const QFileInfo fi(fileName);
return m_plugin->vcsDelete(fi.absolutePath(), fi.fileName());
}
bool SubversionControl::vcsMove(const QString &from, const QString &to)
{
const QFileInfo fromInfo(from);
const QFileInfo toInfo(to);
return m_plugin->vcsMove(fromInfo.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath());
}
bool SubversionControl::vcsCreateRepository(const QString &)
{
return false;
}
bool SubversionControl::managesDirectory(const QString &directory, QString *topLevel) const
{
return m_plugin->managesDirectory(directory, topLevel);
}
bool SubversionControl::managesFile(const QString &workingDirectory, const QString &fileName) const
{
return m_plugin->managesFile(workingDirectory, fileName);
}
bool SubversionControl::vcsAnnotate(const QString &file, int line)
{
const QFileInfo fi(file);
m_plugin->vcsAnnotate(fi.absolutePath(), fi.fileName(), QString(), line);
return true;
}
Core::ShellCommand *SubversionControl::createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory,
const QString &localName,
const QStringList &extraArgs)
{
SubversionClient *client = m_plugin->client();
QStringList args;
args << QLatin1String("checkout");
args << SubversionClient::addAuthenticationOptions(client->settings());
args << QLatin1String(Subversion::Constants::NON_INTERACTIVE_OPTION);
args << extraArgs << url << localName;
auto command = new VcsBase::VcsCommand(baseDirectory.toString(), client->processEnvironment());
command->addJob({client->vcsBinary(), args}, -1);
return command;
}
void SubversionControl::emitRepositoryChanged(const QString &s)
{
emit repositoryChanged(s);
}
void SubversionControl::emitFilesChanged(const QStringList &l)
{
emit filesChanged(l);
}
} // namespace Internal
} // namespace Subversion

View File

@@ -1,71 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include <coreplugin/iversioncontrol.h>
namespace Subversion {
namespace Internal {
class SubversionPluginPrivate;
// Just a proxy for SubversionPlugin
class SubversionControl : public Core::IVersionControl
{
Q_OBJECT
public:
explicit SubversionControl(SubversionPluginPrivate *plugin);
QString displayName() const final;
Core::Id id() const final;
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final;
bool managesDirectory(const QString &directory, QString *topLevel = nullptr) const final;
bool managesFile(const QString &workingDirectory, const QString &fileName) const final;
bool isConfigured() const final;
bool supportsOperation(Operation operation) const final;
bool vcsOpen(const QString &fileName) final;
bool vcsAdd(const QString &fileName) final;
bool vcsDelete(const QString &filename) final;
bool vcsMove(const QString &from, const QString &to) final;
bool vcsCreateRepository(const QString &directory) final;
bool vcsAnnotate(const QString &file, int line) final;
Core::ShellCommand *createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory,
const QString &localName,
const QStringList &extraArgs) final;
void emitRepositoryChanged(const QString &);
void emitFilesChanged(const QStringList &);
private:
SubversionPluginPrivate *m_plugin;
};
} // namespace Internal
} // namespace Subversion

View File

@@ -31,7 +31,6 @@
#include "subversionsubmiteditor.h"
#include "subversionclient.h"
#include "subversionconstants.h"
#include "subversioncontrol.h"
#include <vcsbase/basevcseditorfactory.h>
#include <vcsbase/vcscommand.h>
@@ -168,6 +167,28 @@ static inline QStringList svnDirectories()
return rc;
}
class SubversionTopicCache : public Core::IVersionControl::TopicCache
{
public:
SubversionTopicCache(SubversionPluginPrivate *plugin) :
m_plugin(plugin)
{ }
protected:
QString trackFile(const QString &repository) override
{
return m_plugin->monitorFile(repository);
}
QString refreshTopic(const QString &repository) override
{
return m_plugin->synchronousTopic(repository);
}
private:
SubversionPluginPrivate *m_plugin;
};
// ------------- SubversionPlugin
static SubversionPluginPrivate *dd = nullptr;
@@ -180,8 +201,8 @@ SubversionPlugin::~SubversionPlugin()
SubversionPluginPrivate::~SubversionPluginPrivate()
{
delete m_client;
cleanCommitMessageFile();
delete m_client;
}
void SubversionPluginPrivate::cleanCommitMessageFile()
@@ -217,21 +238,21 @@ void SubversionPlugin::extensionsInitialized()
dd->extensionsInitialized();
}
SubversionPluginPrivate::SubversionPluginPrivate() :
m_svnDirectories(svnDirectories())
SubversionPluginPrivate::SubversionPluginPrivate()
: VcsBasePluginPrivate(Context(Constants::SUBVERSION_CONTEXT)),
m_svnDirectories(svnDirectories())
{
dd = this;
m_client = new SubversionClient(&m_settings);
setTopicCache(new SubversionTopicCache(this));
using namespace Constants;
using namespace Core::Constants;
Context context(SUBVERSION_CONTEXT);
auto vcsCtrl = new SubversionControl(this);
initializeVcs(vcsCtrl, context);
m_client = new SubversionClient(&m_settings);
new SubversionSettingsPage(versionControl(), &m_settings, this);
new SubversionSettingsPage(this, &m_settings, this);
new VcsSubmitEditorFactory(&submitParameters,
[]() { return new SubversionSubmitEditor(&submitParameters); }, this);
@@ -402,7 +423,7 @@ SubversionPluginPrivate::SubversionPluginPrivate() :
m_commandLocator->appendCommand(command);
}
bool SubversionPluginPrivate::isVcsDirectory(const FilePath &fileName)
bool SubversionPluginPrivate::isVcsDirectory(const FilePath &fileName) const
{
const QString baseName = fileName.fileName();
return fileName.isDir() && contains(m_svnDirectories, [baseName](const QString &s) {
@@ -410,9 +431,8 @@ bool SubversionPluginPrivate::isVcsDirectory(const FilePath &fileName)
});
}
SubversionClient *SubversionPluginPrivate::client() const
SubversionClient *SubversionPluginPrivate::client()
{
QTC_CHECK(m_client);
return m_client;
}
@@ -541,7 +561,7 @@ void SubversionPluginPrivate::revertAll()
QMessageBox::warning(ICore::dialogParent(), title,
tr("Revert failed: %1").arg(revertResponse.message), QMessageBox::Ok);
else
subVersionControl()->emitRepositoryChanged(state.topLevel());
emit repositoryChanged(state.topLevel());
}
void SubversionPluginPrivate::revertCurrentFile()
@@ -579,7 +599,7 @@ void SubversionPluginPrivate::revertCurrentFile()
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
if (!revertResponse.error)
subVersionControl()->emitFilesChanged(QStringList(state.currentFile()));
emit filesChanged(QStringList(state.currentFile()));
}
void SubversionPluginPrivate::diffProject()
@@ -751,19 +771,19 @@ void SubversionPluginPrivate::svnUpdate(const QString &workingDir, const QString
= runSvn(workingDir, args, 10 * m_client->vcsTimeoutS(),
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
if (!response.error)
subVersionControl()->emitRepositoryChanged(workingDir);
emit repositoryChanged(workingDir);
}
void SubversionPluginPrivate::annotateCurrentFile()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return);
vcsAnnotate(state.currentFileTopLevel(), state.relativeCurrentFile());
vcsAnnotateHelper(state.currentFileTopLevel(), state.relativeCurrentFile());
}
void SubversionPluginPrivate::vcsAnnotate(const QString &workingDir, const QString &file,
const QString &revision /* = QString() */,
int lineNumber /* = -1 */)
void SubversionPluginPrivate::vcsAnnotateHelper(const QString &workingDir, const QString &file,
const QString &revision /* = QString() */,
int lineNumber /* = -1 */)
{
const QString source = VcsBaseEditor::getSource(workingDir, file);
QTextCodec *codec = VcsBaseEditor::getCodec(source);
@@ -896,7 +916,8 @@ IEditor *SubversionPluginPrivate::showOutputInEditor(const QString &title, const
auto e = qobject_cast<SubversionEditorWidget*>(editor->widget());
if (!e)
return nullptr;
connect(e, &VcsBaseEditorWidget::annotateRevisionRequested, this, &SubversionPluginPrivate::vcsAnnotate);
connect(e, &VcsBaseEditorWidget::annotateRevisionRequested,
this, &SubversionPluginPrivate::vcsAnnotateHelper);
e->setForceReadOnly(true);
s.replace(QLatin1Char(' '), QLatin1Char('_'));
e->textDocument()->setFallbackSaveAsFileName(s);
@@ -1050,9 +1071,99 @@ bool SubversionPluginPrivate::checkSVNSubDir(const QDir &directory) const
return false;
}
SubversionControl *SubversionPluginPrivate::subVersionControl() const
QString SubversionPluginPrivate::displayName() const
{
return static_cast<SubversionControl *>(versionControl());
return QLatin1String("subversion");
}
Core::Id SubversionPluginPrivate::id() const
{
return Core::Id(VcsBase::Constants::VCS_ID_SUBVERSION);
}
bool SubversionPluginPrivate::isVcsFileOrDirectory(const Utils::FilePath &fileName) const
{
return isVcsDirectory(fileName);
}
bool SubversionPluginPrivate::isConfigured() const
{
const Utils::FilePath binary = m_client->vcsBinary();
if (binary.isEmpty())
return false;
QFileInfo fi = binary.toFileInfo();
return fi.exists() && fi.isFile() && fi.isExecutable();
}
bool SubversionPluginPrivate::supportsOperation(Operation operation) const
{
bool rc = isConfigured();
switch (operation) {
case AddOperation:
case DeleteOperation:
case MoveOperation:
case AnnotateOperation:
case InitialCheckoutOperation:
break;
case CreateRepositoryOperation:
case SnapshotOperations:
rc = false;
break;
}
return rc;
}
bool SubversionPluginPrivate::vcsOpen(const QString & /* fileName */)
{
// Open for edit: N/A
return true;
}
bool SubversionPluginPrivate::vcsAdd(const QString &fileName)
{
const QFileInfo fi(fileName);
return vcsAdd(fi.absolutePath(), fi.fileName());
}
bool SubversionPluginPrivate::vcsDelete(const QString &fileName)
{
const QFileInfo fi(fileName);
return vcsDelete(fi.absolutePath(), fi.fileName());
}
bool SubversionPluginPrivate::vcsMove(const QString &from, const QString &to)
{
const QFileInfo fromInfo(from);
const QFileInfo toInfo(to);
return vcsMove(fromInfo.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath());
}
bool SubversionPluginPrivate::vcsCreateRepository(const QString &)
{
return false;
}
bool SubversionPluginPrivate::vcsAnnotate(const QString &file, int line)
{
const QFileInfo fi(file);
vcsAnnotateHelper(fi.absolutePath(), fi.fileName(), QString(), line);
return true;
}
Core::ShellCommand *SubversionPluginPrivate::createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory,
const QString &localName,
const QStringList &extraArgs)
{
QStringList args;
args << QLatin1String("checkout");
args << SubversionClient::addAuthenticationOptions(m_settings);
args << QLatin1String(Subversion::Constants::NON_INTERACTIVE_OPTION);
args << extraArgs << url << localName;
auto command = new VcsBase::VcsCommand(baseDirectory.toString(), m_client->processEnvironment());
command->addJob({m_client->vcsBinary(), args}, -1);
return command;
}
#ifdef WITH_TESTS
@@ -1080,4 +1191,3 @@ void SubversionPlugin::testLogResolving()
} // Internal
} // Subversion

View File

@@ -46,7 +46,6 @@ namespace Subversion {
namespace Internal {
class SubversionSubmitEditor;
class SubversionControl;
class SubversionClient;
struct SubversionResponse
@@ -70,9 +69,33 @@ public:
SubversionPluginPrivate();
~SubversionPluginPrivate() final;
bool isVcsDirectory(const Utils::FilePath &fileName);
// IVersionControl
QString displayName() const final;
Core::Id id() const final;
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final;
SubversionClient *client() const;
bool managesDirectory(const QString &directory, QString *topLevel) const final;
bool managesFile(const QString &workingDirectory, const QString &fileName) const final;
bool isConfigured() const final;
bool supportsOperation(Operation operation) const final;
bool vcsOpen(const QString &fileName) final;
bool vcsAdd(const QString &fileName) final;
bool vcsDelete(const QString &filename) final;
bool vcsMove(const QString &from, const QString &to) final;
bool vcsCreateRepository(const QString &directory) final;
bool vcsAnnotate(const QString &file, int line) final;
Core::ShellCommand *createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory,
const QString &localName,
const QStringList &extraArgs) final;
bool isVcsDirectory(const Utils::FilePath &fileName) const;
///
SubversionClient *client();
SubversionSubmitEditor *openSubversionSubmitEditor(const QString &fileName);
@@ -80,8 +103,6 @@ public:
bool vcsAdd(const QString &workingDir, const QString &fileName);
bool vcsDelete(const QString &workingDir, const QString &fileName);
bool vcsMove(const QString &workingDir, const QString &from, const QString &to);
bool managesDirectory(const QString &directory, QString *topLevel = nullptr) const;
bool managesFile(const QString &workingDirectory, const QString &fileName) const;
bool vcsCheckout(const QString &directory, const QByteArray &url);
static SubversionPluginPrivate *instance();
@@ -92,7 +113,7 @@ public:
const QStringList &arguments, int timeOutS,
unsigned flags, QTextCodec *outputCodec = nullptr) const;
void describe(const QString &source, const QString &changeNr);
void vcsAnnotate(const QString &workingDir, const QString &file,
void vcsAnnotateHelper(const QString &workingDir, const QString &file,
const QString &revision = QString(), int lineNumber = -1);
protected:
@@ -134,7 +155,6 @@ private:
void svnUpdate(const QString &workingDir, const QString &relativePath = QString());
bool checkSVNSubDir(const QDir &directory) const;
void startCommit(const QString &workingDir, const QStringList &files = QStringList());
inline SubversionControl *subVersionControl() const;
const QStringList m_svnDirectories;

View File

@@ -202,7 +202,7 @@ signals:
// Passes on changed signals from VcsJob to Control
void changed(const QVariant &v);
protected:
public:
enum VcsCommandTag
{
CreateRepositoryCommand,
@@ -221,6 +221,7 @@ protected:
LogCommand,
StatusCommand
};
protected:
virtual QString vcsCommandString(VcsCommandTag cmd) const;
virtual Core::Id vcsEditorKind(VcsCommandTag cmd) const = 0;
virtual Utils::ExitCodeInterpreter exitCodeInterpreter(VcsCommandTag cmd) const;

View File

@@ -518,26 +518,14 @@ VCSBASE_EXPORT QDebug operator<<(QDebug in, const VcsBasePluginState &state)
bool VcsBasePluginPrivate::supportsRepositoryCreation() const
{
return m_versionControl && m_versionControl->supportsOperation(IVersionControl::CreateRepositoryOperation);
return supportsOperation(IVersionControl::CreateRepositoryOperation);
}
static Internal::StateListener *m_listener = nullptr;
VcsBasePluginPrivate::VcsBasePluginPrivate()
{ }
VcsBasePluginPrivate::~VcsBasePluginPrivate()
VcsBasePluginPrivate::VcsBasePluginPrivate(const Context &context)
: m_context(context)
{
delete m_versionControl;
}
void VcsBasePluginPrivate::initializeVcs(IVersionControl *vc, const Context &context)
{
QTC_ASSERT(vc, return);
m_versionControl = vc;
m_context = context;
Internal::VcsPlugin *plugin = Internal::VcsPlugin::instance();
connect(plugin, &Internal::VcsPlugin::submitEditorAboutToClose,
this, &VcsBasePluginPrivate::slotSubmitEditorAboutToClose);
@@ -547,9 +535,9 @@ void VcsBasePluginPrivate::initializeVcs(IVersionControl *vc, const Context &con
connect(m_listener, &Internal::StateListener::stateChanged,
this, &VcsBasePluginPrivate::slotStateChanged);
// VCSes might have become (un-)available, so clear the VCS directory cache
connect(vc, &IVersionControl::configurationChanged,
connect(this, &IVersionControl::configurationChanged,
VcsManager::instance(), &VcsManager::clearVersionControlCache);
connect(vc, &IVersionControl::configurationChanged,
connect(this, &IVersionControl::configurationChanged,
m_listener, &Internal::StateListener::slotStateChanged);
}
@@ -569,14 +557,9 @@ void VcsBasePluginPrivate::slotSubmitEditorAboutToClose(VcsBaseSubmitEditor *sub
*result = submitEditorAboutToClose();
}
IVersionControl *VcsBasePluginPrivate::versionControl() const
void VcsBasePluginPrivate::slotStateChanged(const Internal::State &newInternalState, Core::IVersionControl *vc)
{
return m_versionControl;
}
void VcsBasePluginPrivate::slotStateChanged(const VcsBase::Internal::State &newInternalState, IVersionControl *vc)
{
if (vc == m_versionControl) {
if (vc == this) {
// We are directly affected: Change state
if (!m_state.equals(newInternalState)) {
m_state.setState(newInternalState);
@@ -637,7 +620,7 @@ void VcsBasePluginPrivate::promptToDeleteCurrentFile()
{
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return);
const bool rc = VcsManager::promptToDelete(versionControl(), state.currentFile());
const bool rc = VcsManager::promptToDelete(this, state.currentFile());
if (!rc)
QMessageBox::warning(ICore::dialogParent(), tr("Version Control"),
tr("The file \"%1\" could not be deleted.").
@@ -654,7 +637,7 @@ static inline bool ask(QWidget *parent, const QString &title, const QString &que
void VcsBasePluginPrivate::createRepository()
{
QTC_ASSERT(m_versionControl->supportsOperation(IVersionControl::CreateRepositoryOperation), return);
QTC_ASSERT(supportsOperation(IVersionControl::CreateRepositoryOperation), return);
// Find current starting directory
QString directory;
if (const Project *currentProject = ProjectTree::currentProject())
@@ -675,7 +658,7 @@ void VcsBasePluginPrivate::createRepository()
return;
} while (true);
// Create
const bool rc = m_versionControl->vcsCreateRepository(directory);
const bool rc = vcsCreateRepository(directory);
const QString nativeDir = QDir::toNativeSeparators(directory);
if (rc) {
QMessageBox::information(mw, tr("Repository Created"),

View File

@@ -154,20 +154,17 @@ VCSBASE_EXPORT Utils::SynchronousProcessResponse runVcs(const QString &workingDi
QTextCodec *outputCodec = nullptr,
const QProcessEnvironment &env = {});
class VCSBASE_EXPORT VcsBasePluginPrivate : public QObject
class VCSBASE_EXPORT VcsBasePluginPrivate : public Core::IVersionControl
{
Q_OBJECT
protected:
explicit VcsBasePluginPrivate();
explicit VcsBasePluginPrivate(const Core::Context &context);
public:
~VcsBasePluginPrivate() override;
void extensionsInitialized();
const VcsBasePluginState &currentState() const;
Core::IVersionControl *versionControl() const;
// Display name of the commit action
virtual QString commitDisplayName() const;
@@ -209,16 +206,13 @@ protected:
// Returns whether actions should be set up further.
bool enableMenuAction(ActionState as, QAction *in) const;
void initializeVcs(Core::IVersionControl *vc, const Core::Context &context);
private:
void slotSubmitEditorAboutToClose(VcsBaseSubmitEditor *submitEditor, bool *result);
void slotStateChanged(const VcsBase::Internal::State &s, Core::IVersionControl *vc);
void slotStateChanged(const Internal::State &s, Core::IVersionControl *vc);
bool supportsRepositoryCreation() const;
QPointer<VcsBaseSubmitEditor> m_submitEditor;
QPointer<Core::IVersionControl> m_versionControl;
Core::Context m_context;
VcsBasePluginState m_state;
int m_actionState = -1;

View File

@@ -535,8 +535,7 @@ VcsBaseSubmitEditor::PromptSubmitResult
return SubmitConfirmed;
CheckableMessageBox mb(Core::ICore::dialogParent());
const QString commitName = plugin->commitDisplayName();
mb.setWindowTitle(tr("Close %1 %2 Editor")
.arg(plugin->versionControl()->displayName(), commitName));
mb.setWindowTitle(tr("Close %1 %2 Editor").arg(plugin->displayName(), commitName));
mb.setIcon(QMessageBox::Question);
QString message;
if (canCommit) {