aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/perforce
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/perforce
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/perforce')
-rw-r--r--src/plugins/perforce/CMakeLists.txt1
-rw-r--r--src/plugins/perforce/perforce.pro2
-rw-r--r--src/plugins/perforce/perforce.qbs2
-rw-r--r--src/plugins/perforce/perforceplugin.cpp117
-rw-r--r--src/plugins/perforce/perforceplugin.h28
-rw-r--r--src/plugins/perforce/perforceversioncontrol.cpp171
-rw-r--r--src/plugins/perforce/perforceversioncontrol.h70
7 files changed, 126 insertions, 265 deletions
diff --git a/src/plugins/perforce/CMakeLists.txt b/src/plugins/perforce/CMakeLists.txt
index 9a3dd9e59c..b11ee81b8f 100644
--- a/src/plugins/perforce/CMakeLists.txt
+++ b/src/plugins/perforce/CMakeLists.txt
@@ -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
diff --git a/src/plugins/perforce/perforce.pro b/src/plugins/perforce/perforce.pro
index ff50724b5f..e9bc8e48ea 100644
--- a/src/plugins/perforce/perforce.pro
+++ b/src/plugins/perforce/perforce.pro
@@ -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
diff --git a/src/plugins/perforce/perforce.qbs b/src/plugins/perforce/perforce.qbs
index 41bd8008cc..d867e8e34f 100644
--- a/src/plugins/perforce/perforce.qbs
+++ b/src/plugins/perforce/perforce.qbs
@@ -31,8 +31,6 @@ QtcPlugin {
"perforcesubmiteditor.h",
"perforcesubmiteditorwidget.cpp",
"perforcesubmiteditorwidget.h",
- "perforceversioncontrol.cpp",
- "perforceversioncontrol.h",
"settingspage.cpp",
"settingspage.h",
"settingspage.ui",
diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp
index bea2cc0f83..da4dfdda9a 100644
--- a/src/plugins/perforce/perforceplugin.cpp
+++ b/src/plugins/perforce/perforceplugin.cpp
@@ -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)
diff --git a/src/plugins/perforce/perforceplugin.h b/src/plugins/perforce/perforceplugin.h
index eaf698aeba..6bb7721ab4 100644
--- a/src/plugins/perforce/perforceplugin.h
+++ b/src/plugins/perforce/perforceplugin.h
@@ -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;
diff --git a/src/plugins/perforce/perforceversioncontrol.cpp b/src/plugins/perforce/perforceversioncontrol.cpp
deleted file mode 100644
index f47da2907e..0000000000
--- a/src/plugins/perforce/perforceversioncontrol.cpp
+++ /dev/null
@@ -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
diff --git a/src/plugins/perforce/perforceversioncontrol.h b/src/plugins/perforce/perforceversioncontrol.h
deleted file mode 100644
index a06b2164ae..0000000000
--- a/src/plugins/perforce/perforceversioncontrol.h
+++ /dev/null
@@ -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