aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/bazaar
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2020-01-30 12:31:47 +0100
committerhjk <hjk@qt.io>2020-01-31 12:36:23 +0000
commitb8fe25db258da13a2f7a4e44fcf8845a512af6bf (patch)
treeb5692e17963cc05ca437198b969889d3d78a7b4a /src/plugins/bazaar
parenta35a2d6bf3f9525c6ba3cead820c13046c0e70b5 (diff)
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>
Diffstat (limited to 'src/plugins/bazaar')
-rw-r--r--src/plugins/bazaar/CMakeLists.txt1
-rw-r--r--src/plugins/bazaar/bazaar.pro2
-rw-r--r--src/plugins/bazaar/bazaar.qbs2
-rw-r--r--src/plugins/bazaar/bazaarclient.h3
-rw-r--r--src/plugins/bazaar/bazaarcontrol.cpp169
-rw-r--r--src/plugins/bazaar/bazaarcontrol.h79
-rw-r--r--src/plugins/bazaar/bazaarplugin.cpp160
7 files changed, 155 insertions, 261 deletions
diff --git a/src/plugins/bazaar/CMakeLists.txt b/src/plugins/bazaar/CMakeLists.txt
index 8d16541048..6c40d344c3 100644
--- a/src/plugins/bazaar/CMakeLists.txt
+++ b/src/plugins/bazaar/CMakeLists.txt
@@ -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
diff --git a/src/plugins/bazaar/bazaar.pro b/src/plugins/bazaar/bazaar.pro
index 71cf023dc1..6718ab3323 100644
--- a/src/plugins/bazaar/bazaar.pro
+++ b/src/plugins/bazaar/bazaar.pro
@@ -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 \
diff --git a/src/plugins/bazaar/bazaar.qbs b/src/plugins/bazaar/bazaar.qbs
index c14cce6b4e..2e5f9f0ea5 100644
--- a/src/plugins/bazaar/bazaar.qbs
+++ b/src/plugins/bazaar/bazaar.qbs
@@ -18,8 +18,6 @@ QtcPlugin {
"bazaarcommitpanel.ui",
"bazaarcommitwidget.cpp",
"bazaarcommitwidget.h",
- "bazaarcontrol.cpp",
- "bazaarcontrol.h",
"bazaareditor.cpp",
"bazaareditor.h",
"bazaarplugin.cpp",
diff --git a/src/plugins/bazaar/bazaarclient.h b/src/plugins/bazaar/bazaarclient.h
index e3ed0ed55e..4b3c2acc42 100644
--- a/src/plugins/bazaar/bazaarclient.h
+++ b/src/plugins/bazaar/bazaarclient.h
@@ -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
diff --git a/src/plugins/bazaar/bazaarcontrol.cpp b/src/plugins/bazaar/bazaarcontrol.cpp
deleted file mode 100644
index e420723b62..0000000000
--- a/src/plugins/bazaar/bazaarcontrol.cpp
+++ /dev/null
@@ -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;
- }
-}
diff --git a/src/plugins/bazaar/bazaarcontrol.h b/src/plugins/bazaar/bazaarcontrol.h
deleted file mode 100644
index d0d5b514d6..0000000000
--- a/src/plugins/bazaar/bazaarcontrol.h
+++ /dev/null
@@ -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
diff --git a/src/plugins/bazaar/bazaarplugin.cpp b/src/plugins/bazaar/bazaarplugin.cpp
index 0b99c23bd2..336d74cc90 100644
--- a/src/plugins/bazaar/bazaarplugin.cpp
+++ b/src/plugins/bazaar/bazaarplugin.cpp
@@ -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