forked from qt-creator/qt-creator
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:
@@ -5,7 +5,6 @@ add_qtc_plugin(Bazaar
|
|||||||
bazaarclient.cpp bazaarclient.h
|
bazaarclient.cpp bazaarclient.h
|
||||||
bazaarcommitpanel.ui
|
bazaarcommitpanel.ui
|
||||||
bazaarcommitwidget.cpp bazaarcommitwidget.h
|
bazaarcommitwidget.cpp bazaarcommitwidget.h
|
||||||
bazaarcontrol.cpp bazaarcontrol.h
|
|
||||||
bazaareditor.cpp bazaareditor.h
|
bazaareditor.cpp bazaareditor.h
|
||||||
bazaarplugin.cpp bazaarplugin.h
|
bazaarplugin.cpp bazaarplugin.h
|
||||||
bazaarsettings.cpp bazaarsettings.h
|
bazaarsettings.cpp bazaarsettings.h
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
include(../../qtcreatorplugin.pri)
|
include(../../qtcreatorplugin.pri)
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
bazaarclient.cpp \
|
bazaarclient.cpp \
|
||||||
bazaarcontrol.cpp \
|
|
||||||
bazaarplugin.cpp \
|
bazaarplugin.cpp \
|
||||||
optionspage.cpp \
|
optionspage.cpp \
|
||||||
bazaarsettings.cpp \
|
bazaarsettings.cpp \
|
||||||
@@ -15,7 +14,6 @@ SOURCES += \
|
|||||||
HEADERS += \
|
HEADERS += \
|
||||||
bazaarclient.h \
|
bazaarclient.h \
|
||||||
constants.h \
|
constants.h \
|
||||||
bazaarcontrol.h \
|
|
||||||
bazaarplugin.h \
|
bazaarplugin.h \
|
||||||
optionspage.h \
|
optionspage.h \
|
||||||
bazaarsettings.h \
|
bazaarsettings.h \
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ QtcPlugin {
|
|||||||
"bazaarcommitpanel.ui",
|
"bazaarcommitpanel.ui",
|
||||||
"bazaarcommitwidget.cpp",
|
"bazaarcommitwidget.cpp",
|
||||||
"bazaarcommitwidget.h",
|
"bazaarcommitwidget.h",
|
||||||
"bazaarcontrol.cpp",
|
|
||||||
"bazaarcontrol.h",
|
|
||||||
"bazaareditor.cpp",
|
"bazaareditor.cpp",
|
||||||
"bazaareditor.h",
|
"bazaareditor.h",
|
||||||
"bazaarplugin.cpp",
|
"bazaarplugin.cpp",
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ namespace Bazaar {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class BazaarSettings;
|
class BazaarSettings;
|
||||||
class BazaarControl;
|
|
||||||
|
|
||||||
class BazaarClient : public VcsBase::VcsBaseClient
|
class BazaarClient : public VcsBase::VcsBaseClient
|
||||||
{
|
{
|
||||||
@@ -57,7 +56,6 @@ public:
|
|||||||
void view(const QString &source, const QString &id,
|
void view(const QString &source, const QString &id,
|
||||||
const QStringList &extraOptions = QStringList()) override;
|
const QStringList &extraOptions = QStringList()) override;
|
||||||
|
|
||||||
protected:
|
|
||||||
Core::Id vcsEditorKind(VcsCommandTag cmd) const override;
|
Core::Id vcsEditorKind(VcsCommandTag cmd) const override;
|
||||||
QString vcsCommandString(VcsCommandTag cmd) const override;
|
QString vcsCommandString(VcsCommandTag cmd) const override;
|
||||||
Utils::ExitCodeInterpreter exitCodeInterpreter(VcsCommandTag cmd) const override;
|
Utils::ExitCodeInterpreter exitCodeInterpreter(VcsCommandTag cmd) const override;
|
||||||
@@ -66,7 +64,6 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend class CloneWizard;
|
friend class CloneWizard;
|
||||||
friend class BazaarControl;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -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
|
|
||||||
@@ -27,7 +27,6 @@
|
|||||||
|
|
||||||
#include "bazaarclient.h"
|
#include "bazaarclient.h"
|
||||||
#include "bazaarcommitwidget.h"
|
#include "bazaarcommitwidget.h"
|
||||||
#include "bazaarcontrol.h"
|
|
||||||
#include "bazaareditor.h"
|
#include "bazaareditor.h"
|
||||||
#include "bazaarsettings.h"
|
#include "bazaarsettings.h"
|
||||||
#include "commiteditor.h"
|
#include "commiteditor.h"
|
||||||
@@ -40,6 +39,7 @@
|
|||||||
|
|
||||||
#include <vcsbase/vcsbaseclient.h>
|
#include <vcsbase/vcsbaseclient.h>
|
||||||
#include <vcsbase/vcsbaseplugin.h>
|
#include <vcsbase/vcsbaseplugin.h>
|
||||||
|
#include <vcsbase/vcscommand.h>
|
||||||
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||||
@@ -140,6 +140,31 @@ class BazaarPluginPrivate final : public VcsBasePluginPrivate
|
|||||||
public:
|
public:
|
||||||
BazaarPluginPrivate();
|
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;
|
void updateActions(VcsBase::VcsBasePluginPrivate::ActionState) final;
|
||||||
bool submitEditorAboutToClose() final;
|
bool submitEditorAboutToClose() final;
|
||||||
|
|
||||||
@@ -175,9 +200,8 @@ public:
|
|||||||
// Variables
|
// Variables
|
||||||
BazaarSettings m_bazaarSettings;
|
BazaarSettings m_bazaarSettings;
|
||||||
BazaarClient m_client{&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 {
|
VcsSubmitEditorFactory m_submitEditorFactory {
|
||||||
&submitEditorParameters,
|
&submitEditorParameters,
|
||||||
@@ -264,11 +288,11 @@ void BazaarPlugin::extensionsInitialized()
|
|||||||
}
|
}
|
||||||
|
|
||||||
BazaarPluginPrivate::BazaarPluginPrivate()
|
BazaarPluginPrivate::BazaarPluginPrivate()
|
||||||
|
: VcsBasePluginPrivate(Context(Constants::BAZAAR_CONTEXT))
|
||||||
{
|
{
|
||||||
Context 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) {
|
const auto describeFunc = [this](const QString &source, const QString &id) {
|
||||||
m_client.view(source, id);
|
m_client.view(source, id);
|
||||||
@@ -796,5 +820,131 @@ void BazaarPluginPrivate::updateActions(VcsBasePluginPrivate::ActionState as)
|
|||||||
repoAction->setEnabled(repoEnabled);
|
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 Internal
|
||||||
} // namespace Bazaar
|
} // namespace Bazaar
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ add_qtc_plugin(ClearCase
|
|||||||
annotationhighlighter.cpp annotationhighlighter.h
|
annotationhighlighter.cpp annotationhighlighter.h
|
||||||
checkoutdialog.cpp checkoutdialog.h checkoutdialog.ui
|
checkoutdialog.cpp checkoutdialog.h checkoutdialog.ui
|
||||||
clearcaseconstants.h
|
clearcaseconstants.h
|
||||||
clearcasecontrol.cpp clearcasecontrol.h
|
|
||||||
clearcaseeditor.cpp clearcaseeditor.h
|
clearcaseeditor.cpp clearcaseeditor.h
|
||||||
clearcaseplugin.cpp clearcaseplugin.h
|
clearcaseplugin.cpp clearcaseplugin.h
|
||||||
clearcasesettings.cpp clearcasesettings.h
|
clearcasesettings.cpp clearcasesettings.h
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ HEADERS += activityselector.h \
|
|||||||
annotationhighlighter.h \
|
annotationhighlighter.h \
|
||||||
checkoutdialog.h \
|
checkoutdialog.h \
|
||||||
clearcaseconstants.h \
|
clearcaseconstants.h \
|
||||||
clearcasecontrol.h \
|
|
||||||
clearcaseeditor.h \
|
clearcaseeditor.h \
|
||||||
clearcaseplugin.h \
|
clearcaseplugin.h \
|
||||||
clearcasesettings.h \
|
clearcasesettings.h \
|
||||||
@@ -17,7 +16,6 @@ HEADERS += activityselector.h \
|
|||||||
SOURCES += activityselector.cpp \
|
SOURCES += activityselector.cpp \
|
||||||
annotationhighlighter.cpp \
|
annotationhighlighter.cpp \
|
||||||
checkoutdialog.cpp \
|
checkoutdialog.cpp \
|
||||||
clearcasecontrol.cpp \
|
|
||||||
clearcaseeditor.cpp \
|
clearcaseeditor.cpp \
|
||||||
clearcaseplugin.cpp \
|
clearcaseplugin.cpp \
|
||||||
clearcasesettings.cpp \
|
clearcasesettings.cpp \
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ QtcPlugin {
|
|||||||
"checkoutdialog.h",
|
"checkoutdialog.h",
|
||||||
"checkoutdialog.ui",
|
"checkoutdialog.ui",
|
||||||
"clearcaseconstants.h",
|
"clearcaseconstants.h",
|
||||||
"clearcasecontrol.cpp",
|
|
||||||
"clearcasecontrol.h",
|
|
||||||
"clearcaseeditor.cpp",
|
"clearcaseeditor.cpp",
|
||||||
"clearcaseeditor.h",
|
"clearcaseeditor.h",
|
||||||
"clearcaseplugin.cpp",
|
"clearcaseplugin.cpp",
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
@@ -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
|
|
||||||
@@ -28,7 +28,6 @@
|
|||||||
#include "activityselector.h"
|
#include "activityselector.h"
|
||||||
#include "checkoutdialog.h"
|
#include "checkoutdialog.h"
|
||||||
#include "clearcaseconstants.h"
|
#include "clearcaseconstants.h"
|
||||||
#include "clearcasecontrol.h"
|
|
||||||
#include "clearcaseeditor.h"
|
#include "clearcaseeditor.h"
|
||||||
#include "clearcasesubmiteditor.h"
|
#include "clearcasesubmiteditor.h"
|
||||||
#include "clearcasesubmiteditorwidget.h"
|
#include "clearcasesubmiteditorwidget.h"
|
||||||
@@ -409,7 +408,8 @@ void ClearCasePlugin::extensionsInitialized()
|
|||||||
dd->extensionsInitialized();
|
dd->extensionsInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearCasePluginPrivate::ClearCasePluginPrivate() :
|
ClearCasePluginPrivate::ClearCasePluginPrivate()
|
||||||
|
: VcsBase::VcsBasePluginPrivate(Context(CLEARCASE_CONTEXT)),
|
||||||
m_activityMutex(new QMutex),
|
m_activityMutex(new QMutex),
|
||||||
m_statusMap(new StatusMap)
|
m_statusMap(new StatusMap)
|
||||||
{
|
{
|
||||||
@@ -427,9 +427,6 @@ ClearCasePluginPrivate::ClearCasePluginPrivate() :
|
|||||||
|
|
||||||
Context context(CLEARCASE_CONTEXT);
|
Context context(CLEARCASE_CONTEXT);
|
||||||
|
|
||||||
auto vcsCtrl = new ClearCaseControl(this);
|
|
||||||
initializeVcs(vcsCtrl, context);
|
|
||||||
|
|
||||||
connect(ICore::instance(), &ICore::coreAboutToClose, this, &ClearCasePluginPrivate::closing);
|
connect(ICore::instance(), &ICore::coreAboutToClose, this, &ClearCasePluginPrivate::closing);
|
||||||
connect(ProgressManager::instance(), &ProgressManager::allTasksFinished,
|
connect(ProgressManager::instance(), &ProgressManager::allTasksFinished,
|
||||||
this, &ClearCasePluginPrivate::tasksFinished);
|
this, &ClearCasePluginPrivate::tasksFinished);
|
||||||
@@ -913,7 +910,7 @@ bool ClearCasePluginPrivate::vcsUndoCheckOut(const QString &workingDir, const QS
|
|||||||
|
|
||||||
if (!m_settings.disableIndexer)
|
if (!m_settings.disableIndexer)
|
||||||
setStatus(absPath, FileStatus::CheckedIn);
|
setStatus(absPath, FileStatus::CheckedIn);
|
||||||
clearCaseControl()->emitFilesChanged(QStringList(absPath));
|
emit filesChanged(QStringList(absPath));
|
||||||
}
|
}
|
||||||
return !response.error;
|
return !response.error;
|
||||||
}
|
}
|
||||||
@@ -976,7 +973,7 @@ void ClearCasePluginPrivate::undoHijackCurrent()
|
|||||||
|
|
||||||
// revert
|
// revert
|
||||||
if (vcsUndoHijack(state.currentFileTopLevel(), fileName, keep))
|
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
|
QString ClearCasePluginPrivate::ccGetFileVersion(const QString &workingDir, const QString &file) const
|
||||||
@@ -1338,17 +1335,17 @@ void ClearCasePluginPrivate::ccUpdate(const QString &workingDir, const QStringLi
|
|||||||
const ClearCaseResponse response =
|
const ClearCaseResponse response =
|
||||||
runCleartool(workingDir, args, m_settings.longTimeOutS(), VcsCommand::ShowStdOut);
|
runCleartool(workingDir, args, m_settings.longTimeOutS(), VcsCommand::ShowStdOut);
|
||||||
if (!response.error)
|
if (!response.error)
|
||||||
clearCaseControl()->emitRepositoryChanged(workingDir);
|
emit repositoryChanged(workingDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearCasePluginPrivate::annotateCurrentFile()
|
void ClearCasePluginPrivate::annotateCurrentFile()
|
||||||
{
|
{
|
||||||
const VcsBasePluginState state = currentState();
|
const VcsBasePluginState state = currentState();
|
||||||
QTC_ASSERT(state.hasFile(), return);
|
QTC_ASSERT(state.hasFile(), return);
|
||||||
vcsAnnotate(state.currentFileTopLevel(), state.relativeCurrentFile());
|
vcsAnnotateHelper(state.currentFileTopLevel(), state.relativeCurrentFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClearCasePluginPrivate::vcsAnnotate(const QString &workingDir, const QString &file,
|
void ClearCasePluginPrivate::vcsAnnotateHelper(const QString &workingDir, const QString &file,
|
||||||
const QString &revision /* = QString() */,
|
const QString &revision /* = QString() */,
|
||||||
int lineNumber /* = -1 */) const
|
int lineNumber /* = -1 */) const
|
||||||
{
|
{
|
||||||
@@ -1418,8 +1415,7 @@ void ClearCasePluginPrivate::describe(const QString &source, const QString &chan
|
|||||||
QStringList args(QLatin1String("describe"));
|
QStringList args(QLatin1String("describe"));
|
||||||
args.push_back(id);
|
args.push_back(id);
|
||||||
QTextCodec *codec = VcsBaseEditor::getCodec(source);
|
QTextCodec *codec = VcsBaseEditor::getCodec(source);
|
||||||
const ClearCaseResponse response =
|
const ClearCaseResponse response = runCleartool(topLevel, args, m_settings.timeOutS, 0, codec);
|
||||||
runCleartool(topLevel, args, m_settings.timeOutS, 0, codec);
|
|
||||||
description = response.stdOut;
|
description = response.stdOut;
|
||||||
if (m_settings.extDiffAvailable)
|
if (m_settings.extDiffAvailable)
|
||||||
description += diffExternal(id);
|
description += diffExternal(id);
|
||||||
@@ -1494,7 +1490,8 @@ IEditor *ClearCasePluginPrivate::showOutputInEditor(const QString& title, const
|
|||||||
auto e = qobject_cast<ClearCaseEditorWidget*>(editor->widget());
|
auto e = qobject_cast<ClearCaseEditorWidget*>(editor->widget());
|
||||||
if (!e)
|
if (!e)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
connect(e, &VcsBaseEditorWidget::annotateRevisionRequested, this, &ClearCasePluginPrivate::vcsAnnotate);
|
connect(e, &VcsBaseEditorWidget::annotateRevisionRequested,
|
||||||
|
this, &ClearCasePluginPrivate::vcsAnnotateHelper);
|
||||||
e->setForceReadOnly(true);
|
e->setForceReadOnly(true);
|
||||||
s.replace(QLatin1Char(' '), QLatin1Char('_'));
|
s.replace(QLatin1Char(' '), QLatin1Char('_'));
|
||||||
e->textDocument()->setFallbackSaveAsFileName(s);
|
e->textDocument()->setFallbackSaveAsFileName(s);
|
||||||
@@ -1515,7 +1512,7 @@ void ClearCasePluginPrivate::setSettings(const ClearCaseSettings &s)
|
|||||||
if (s != m_settings) {
|
if (s != m_settings) {
|
||||||
m_settings = s;
|
m_settings = s;
|
||||||
m_settings.toSettings(ICore::settings());
|
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)
|
if (!m_settings.disableIndexer)
|
||||||
setStatus(QDir::fromNativeSeparators(absPath), FileStatus::CheckedIn);
|
setStatus(QDir::fromNativeSeparators(absPath), FileStatus::CheckedIn);
|
||||||
clearCaseControl()->emitFilesChanged(files);
|
emit filesChanged(files);
|
||||||
anySucceeded = true;
|
anySucceeded = true;
|
||||||
offset = checkedIn.indexIn(response.stdOut, offset + 12);
|
offset = checkedIn.indexIn(response.stdOut, offset + 12);
|
||||||
}
|
}
|
||||||
@@ -1820,11 +1817,6 @@ bool ClearCasePluginPrivate::vcsMove(const QString &workingDir, const QString &f
|
|||||||
QStringList("move"), from, to);
|
QStringList("move"), from, to);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ClearCasePluginPrivate::vcsCheckout(const QString & /*directory*/, const QByteArray & /*url*/)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Check if the directory is managed under ClearCase control.
|
/// Check if the directory is managed under ClearCase control.
|
||||||
///
|
///
|
||||||
@@ -1842,11 +1834,6 @@ bool ClearCasePluginPrivate::managesDirectory(const QString &directory, QString
|
|||||||
return !topLevelFound.isEmpty();
|
return !topLevelFound.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearCaseControl *ClearCasePluginPrivate::clearCaseControl() const
|
|
||||||
{
|
|
||||||
return static_cast<ClearCaseControl *>(versionControl());
|
|
||||||
}
|
|
||||||
|
|
||||||
QString ClearCasePluginPrivate::ccGetCurrentActivity() const
|
QString ClearCasePluginPrivate::ccGetCurrentActivity() const
|
||||||
{
|
{
|
||||||
QStringList args(QLatin1String("lsactivity"));
|
QStringList args(QLatin1String("lsactivity"));
|
||||||
@@ -2195,6 +2182,134 @@ void ClearCasePluginPrivate::sync(QFutureInterface<void> &future, QStringList fi
|
|||||||
ccSync.run(future, files);
|
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
|
#ifdef WITH_TESTS
|
||||||
|
|
||||||
void ClearCasePlugin::testDiffFileResolving_data()
|
void ClearCasePlugin::testDiffFileResolving_data()
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ namespace ClearCase {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class ClearCaseSubmitEditor;
|
class ClearCaseSubmitEditor;
|
||||||
class ClearCaseControl;
|
|
||||||
|
|
||||||
class ClearCaseResponse
|
class ClearCaseResponse
|
||||||
{
|
{
|
||||||
@@ -113,6 +112,33 @@ public:
|
|||||||
ClearCasePluginPrivate();
|
ClearCasePluginPrivate();
|
||||||
~ClearCasePluginPrivate() final;
|
~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);
|
ClearCaseSubmitEditor *openClearCaseSubmitEditor(const QString &fileName, bool isUcm);
|
||||||
|
|
||||||
const ClearCaseSettings &settings() const;
|
const ClearCaseSettings &settings() const;
|
||||||
@@ -128,8 +154,6 @@ public:
|
|||||||
bool vcsUndoHijack(const QString &workingDir, const QString &fileName, bool keep);
|
bool vcsUndoHijack(const QString &workingDir, const QString &fileName, bool keep);
|
||||||
bool vcsMove(const QString &workingDir, const QString &from, const QString &to);
|
bool vcsMove(const QString &workingDir, const QString &from, const QString &to);
|
||||||
bool vcsSetActivity(const QString &workingDir, const QString &title, const QString &activity);
|
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();
|
static ClearCasePluginPrivate *instance();
|
||||||
|
|
||||||
@@ -151,13 +175,11 @@ public:
|
|||||||
void setStatus(const QString &file, FileStatus::Status status, bool update = true);
|
void setStatus(const QString &file, FileStatus::Status status, bool update = true);
|
||||||
|
|
||||||
bool ccCheckUcm(const QString &viewname, const QString &workingDir) const;
|
bool ccCheckUcm(const QString &viewname, const QString &workingDir) const;
|
||||||
bool managesFile(const QString &workingDirectory, const QString &fileName) const;
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
inline void setFakeCleartool(const bool b = true) { m_fakeClearTool = b; }
|
inline void setFakeCleartool(const bool b = true) { m_fakeClearTool = b; }
|
||||||
inline bool isFakeCleartool() const { return m_fakeClearTool; }
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void vcsAnnotate(const QString &workingDir, const QString &file,
|
void vcsAnnotateHelper(const QString &workingDir, const QString &file,
|
||||||
const QString &revision = QString(), int lineNumber = -1) const;
|
const QString &revision = QString(), int lineNumber = -1) const;
|
||||||
bool newActivity();
|
bool newActivity();
|
||||||
void updateStreamAndView();
|
void updateStreamAndView();
|
||||||
@@ -216,7 +238,6 @@ private:
|
|||||||
void ccDiffWithPred(const QString &workingDir, const QStringList &files);
|
void ccDiffWithPred(const QString &workingDir, const QStringList &files);
|
||||||
void startCheckIn(const QString &workingDir, const QStringList &files = QStringList());
|
void startCheckIn(const QString &workingDir, const QStringList &files = QStringList());
|
||||||
void cleanCheckInMessageFile();
|
void cleanCheckInMessageFile();
|
||||||
inline ClearCaseControl *clearCaseControl() const;
|
|
||||||
QString ccGetFileActivity(const QString &workingDir, const QString &file);
|
QString ccGetFileActivity(const QString &workingDir, const QString &file);
|
||||||
QStringList ccGetActivityVersions(const QString &workingDir, const QString &activity);
|
QStringList ccGetActivityVersions(const QString &workingDir, const QString &activity);
|
||||||
void diffGraphical(const QString &file1, const QString &file2 = QString());
|
void diffGraphical(const QString &file1, const QString &file2 = QString());
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ add_qtc_plugin(CVS
|
|||||||
SOURCES
|
SOURCES
|
||||||
annotationhighlighter.cpp annotationhighlighter.h
|
annotationhighlighter.cpp annotationhighlighter.h
|
||||||
cvsclient.cpp cvsclient.h
|
cvsclient.cpp cvsclient.h
|
||||||
cvscontrol.cpp cvscontrol.h
|
|
||||||
cvseditor.cpp cvseditor.h
|
cvseditor.cpp cvseditor.h
|
||||||
cvsplugin.cpp cvsplugin.h
|
cvsplugin.cpp cvsplugin.h
|
||||||
cvssettings.cpp cvssettings.h
|
cvssettings.cpp cvssettings.h
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ include(../../qtcreatorplugin.pri)
|
|||||||
HEADERS += annotationhighlighter.h \
|
HEADERS += annotationhighlighter.h \
|
||||||
cvsplugin.h \
|
cvsplugin.h \
|
||||||
cvsclient.h \
|
cvsclient.h \
|
||||||
cvscontrol.h \
|
|
||||||
settingspage.h \
|
settingspage.h \
|
||||||
cvseditor.h \
|
cvseditor.h \
|
||||||
cvssubmiteditor.h \
|
cvssubmiteditor.h \
|
||||||
@@ -13,7 +12,6 @@ HEADERS += annotationhighlighter.h \
|
|||||||
SOURCES += annotationhighlighter.cpp \
|
SOURCES += annotationhighlighter.cpp \
|
||||||
cvsplugin.cpp \
|
cvsplugin.cpp \
|
||||||
cvsclient.cpp \
|
cvsclient.cpp \
|
||||||
cvscontrol.cpp \
|
|
||||||
settingspage.cpp \
|
settingspage.cpp \
|
||||||
cvseditor.cpp \
|
cvseditor.cpp \
|
||||||
cvssubmiteditor.cpp \
|
cvssubmiteditor.cpp \
|
||||||
|
|||||||
@@ -15,8 +15,6 @@ QtcPlugin {
|
|||||||
"annotationhighlighter.h",
|
"annotationhighlighter.h",
|
||||||
"cvsclient.cpp",
|
"cvsclient.cpp",
|
||||||
"cvsclient.h",
|
"cvsclient.h",
|
||||||
"cvscontrol.cpp",
|
|
||||||
"cvscontrol.h",
|
|
||||||
"cvseditor.cpp",
|
"cvseditor.cpp",
|
||||||
"cvseditor.h",
|
"cvseditor.h",
|
||||||
"cvsplugin.cpp",
|
"cvsplugin.cpp",
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
#include "cvseditor.h"
|
#include "cvseditor.h"
|
||||||
#include "cvssubmiteditor.h"
|
#include "cvssubmiteditor.h"
|
||||||
#include "cvsclient.h"
|
#include "cvsclient.h"
|
||||||
#include "cvscontrol.h"
|
|
||||||
#include "cvsutils.h"
|
#include "cvsutils.h"
|
||||||
|
|
||||||
#include <vcsbase/basevcseditorfactory.h>
|
#include <vcsbase/basevcseditorfactory.h>
|
||||||
@@ -165,15 +164,39 @@ public:
|
|||||||
CvsPluginPrivate();
|
CvsPluginPrivate();
|
||||||
~CvsPluginPrivate() final;
|
~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);
|
CvsSubmitEditor *openCVSSubmitEditor(const QString &fileName);
|
||||||
|
|
||||||
// IVersionControl
|
// IVersionControl
|
||||||
bool vcsAdd(const QString &workingDir, const QString &fileName);
|
bool vcsAdd(const QString &workingDir, const QString &fileName);
|
||||||
bool vcsDelete(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).
|
// cvs 'edit' is used to implement 'open' (cvsnt).
|
||||||
bool edit(const QString &topLevel, const QStringList &files);
|
bool edit(const QString &topLevel, const QStringList &files);
|
||||||
|
|
||||||
@@ -275,69 +298,29 @@ private:
|
|||||||
bool m_submitActionTriggered = false;
|
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 CvsPluginPrivate::id() const
|
||||||
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
|
|
||||||
{
|
{
|
||||||
return Core::Id(VcsBase::Constants::VCS_ID_CVS);
|
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()
|
return fileName.isDir()
|
||||||
&& !fileName.fileName().compare("CVS", Utils::HostOsInfo::fileNameCaseSensitivity());
|
&& !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())
|
if (binary.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
QFileInfo fi = binary.toFileInfo();
|
QFileInfo fi = binary.toFileInfo();
|
||||||
return fi.exists() && fi.isFile() && fi.isExecutable();
|
return fi.exists() && fi.isFile() && fi.isExecutable();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CvsControl::supportsOperation(Operation operation) const
|
bool CvsPluginPrivate::supportsOperation(Operation operation) const
|
||||||
{
|
{
|
||||||
bool rc = isConfigured();
|
bool rc = isConfigured();
|
||||||
switch (operation) {
|
switch (operation) {
|
||||||
@@ -355,62 +338,55 @@ bool CvsControl::supportsOperation(Operation operation) const
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::IVersionControl::OpenSupportMode CvsControl::openSupportMode(const QString &fileName) const
|
Core::IVersionControl::OpenSupportMode CvsPluginPrivate::openSupportMode(const QString &fileName) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(fileName)
|
Q_UNUSED(fileName)
|
||||||
return OpenOptional;
|
return OpenOptional;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CvsControl::vcsOpen(const QString &fileName)
|
bool CvsPluginPrivate::vcsOpen(const QString &fileName)
|
||||||
{
|
{
|
||||||
const QFileInfo fi(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);
|
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);
|
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)
|
bool CvsPluginPrivate::vcsCreateRepository(const QString &)
|
||||||
{
|
|
||||||
Q_UNUSED(from)
|
|
||||||
Q_UNUSED(to)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CvsControl::vcsCreateRepository(const QString &)
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CvsControl::vcsAnnotate(const QString &file, int line)
|
bool CvsPluginPrivate::vcsAnnotate(const QString &file, int line)
|
||||||
{
|
{
|
||||||
const QFileInfo fi(file);
|
const QFileInfo fi(file);
|
||||||
m_plugin->vcsAnnotate(fi.absolutePath(), fi.fileName(), QString(), line);
|
vcsAnnotate(fi.absolutePath(), fi.fileName(), QString(), line);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CvsControl::vcsOpenText() const
|
QString CvsPluginPrivate::vcsOpenText() const
|
||||||
{
|
{
|
||||||
return tr("&Edit");
|
return tr("&Edit");
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::ShellCommand *CvsControl::createInitialCheckoutCommand(const QString &url,
|
Core::ShellCommand *CvsPluginPrivate::createInitialCheckoutCommand(const QString &url,
|
||||||
const Utils::FilePath &baseDirectory,
|
const Utils::FilePath &baseDirectory,
|
||||||
const QString &localName,
|
const QString &localName,
|
||||||
const QStringList &extraArgs)
|
const QStringList &extraArgs)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(localName == url, return nullptr);
|
QTC_ASSERT(localName == url, return nullptr);
|
||||||
|
|
||||||
const CvsSettings settings = m_plugin->client()->settings();
|
const CvsSettings settings = m_client->settings();
|
||||||
|
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args << QLatin1String("checkout") << url << extraArgs;
|
args << QLatin1String("checkout") << url << extraArgs;
|
||||||
@@ -418,20 +394,10 @@ Core::ShellCommand *CvsControl::createInitialCheckoutCommand(const QString &url,
|
|||||||
auto command = new VcsBase::VcsCommand(baseDirectory.toString(),
|
auto command = new VcsBase::VcsCommand(baseDirectory.toString(),
|
||||||
QProcessEnvironment::systemEnvironment());
|
QProcessEnvironment::systemEnvironment());
|
||||||
command->setDisplayName(tr("CVS Checkout"));
|
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;
|
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
|
// ------------- CVSPlugin
|
||||||
|
|
||||||
static CvsPluginPrivate *dd = nullptr;
|
static CvsPluginPrivate *dd = nullptr;
|
||||||
@@ -442,12 +408,6 @@ CvsPluginPrivate::~CvsPluginPrivate()
|
|||||||
cleanCommitMessageFile();
|
cleanCommitMessageFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
CvsClient *CvsPluginPrivate::client() const
|
|
||||||
{
|
|
||||||
QTC_CHECK(m_client);
|
|
||||||
return m_client;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CvsPluginPrivate::cleanCommitMessageFile()
|
void CvsPluginPrivate::cleanCommitMessageFile()
|
||||||
{
|
{
|
||||||
if (!m_commitMessageFileName.isEmpty()) {
|
if (!m_commitMessageFileName.isEmpty()) {
|
||||||
@@ -488,18 +448,15 @@ void CvsPlugin::extensionsInitialized()
|
|||||||
}
|
}
|
||||||
|
|
||||||
CvsPluginPrivate::CvsPluginPrivate()
|
CvsPluginPrivate::CvsPluginPrivate()
|
||||||
|
: VcsBasePluginPrivate(Context(CVS_CONTEXT))
|
||||||
{
|
{
|
||||||
using namespace Core::Constants;
|
using namespace Core::Constants;
|
||||||
dd = this;
|
dd = this;
|
||||||
|
|
||||||
Context context(CVS_CONTEXT);
|
Context context(CVS_CONTEXT);
|
||||||
|
|
||||||
auto vcsCtrl = new CvsControl(this);
|
|
||||||
initializeVcs(vcsCtrl, context);
|
|
||||||
|
|
||||||
m_client = new CvsClient(&m_settings);
|
m_client = new CvsClient(&m_settings);
|
||||||
|
|
||||||
new CvsSettingsPage([vcsCtrl] { vcsCtrl->configurationChanged(); }, &m_settings, this);
|
new CvsSettingsPage([this] { configurationChanged(); }, &m_settings, this);
|
||||||
|
|
||||||
new VcsSubmitEditorFactory(&submitParameters,
|
new VcsSubmitEditorFactory(&submitParameters,
|
||||||
[]() { return new CvsSubmitEditor(&submitParameters); }, this);
|
[]() { return new CvsSubmitEditor(&submitParameters); }, this);
|
||||||
@@ -837,7 +794,7 @@ void CvsPluginPrivate::revertAll()
|
|||||||
runCvs(state.topLevel(), args, m_client->vcsTimeoutS(),
|
runCvs(state.topLevel(), args, m_client->vcsTimeoutS(),
|
||||||
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
|
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
|
||||||
if (revertResponse.result == CvsResponse::Ok)
|
if (revertResponse.result == CvsResponse::Ok)
|
||||||
emit versionControl()->repositoryChanged(state.topLevel());
|
emit repositoryChanged(state.topLevel());
|
||||||
else
|
else
|
||||||
Core::AsynchronousMessageBox::warning(title,
|
Core::AsynchronousMessageBox::warning(title,
|
||||||
tr("Revert failed: %1").arg(revertResponse.message));
|
tr("Revert failed: %1").arg(revertResponse.message));
|
||||||
@@ -875,7 +832,7 @@ void CvsPluginPrivate::revertCurrentFile()
|
|||||||
runCvs(state.currentFileTopLevel(), args, m_client->vcsTimeoutS(),
|
runCvs(state.currentFileTopLevel(), args, m_client->vcsTimeoutS(),
|
||||||
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
|
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
|
||||||
if (revertResponse.result == CvsResponse::Ok)
|
if (revertResponse.result == CvsResponse::Ok)
|
||||||
emit versionControl()->filesChanged(QStringList(state.currentFile()));
|
emit filesChanged(QStringList(state.currentFile()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CvsPluginPrivate::diffProject()
|
void CvsPluginPrivate::diffProject()
|
||||||
@@ -1066,7 +1023,7 @@ bool CvsPluginPrivate::update(const QString &topLevel, const QString &file)
|
|||||||
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
|
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
|
||||||
const bool ok = response.result == CvsResponse::Ok;
|
const bool ok = response.result == CvsResponse::Ok;
|
||||||
if (ok)
|
if (ok)
|
||||||
emit versionControl()->repositoryChanged(topLevel);
|
emit repositoryChanged(topLevel);
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ add_qtc_plugin(Git
|
|||||||
gitsubmiteditorwidget.cpp gitsubmiteditorwidget.h
|
gitsubmiteditorwidget.cpp gitsubmiteditorwidget.h
|
||||||
gitsubmitpanel.ui
|
gitsubmitpanel.ui
|
||||||
gitutils.cpp gitutils.h
|
gitutils.cpp gitutils.h
|
||||||
gitversioncontrol.cpp gitversioncontrol.h
|
|
||||||
logchangedialog.cpp logchangedialog.h
|
logchangedialog.cpp logchangedialog.h
|
||||||
mergetool.cpp mergetool.h
|
mergetool.cpp mergetool.h
|
||||||
remoteadditiondialog.ui
|
remoteadditiondialog.ui
|
||||||
|
|||||||
@@ -32,7 +32,6 @@
|
|||||||
|
|
||||||
#include "../gitplugin.h"
|
#include "../gitplugin.h"
|
||||||
#include "../gitclient.h"
|
#include "../gitclient.h"
|
||||||
#include "../gitversioncontrol.h"
|
|
||||||
#include "../gitconstants.h"
|
#include "../gitconstants.h"
|
||||||
#include <vcsbase/vcsbaseconstants.h>
|
#include <vcsbase/vcsbaseconstants.h>
|
||||||
#include <vcsbase/vcsbaseeditor.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.
|
// Try to find a matching repository for a project by asking the VcsManager.
|
||||||
QString GerritPlugin::findLocalRepository(QString project, const QString &branch) const
|
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').
|
// Determine key (file name) to look for (qt/qtbase->'qtbase').
|
||||||
const int slashPos = project.lastIndexOf('/');
|
const int slashPos = project.lastIndexOf('/');
|
||||||
if (slashPos != -1)
|
if (slashPos != -1)
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ HEADERS += gitplugin.h \
|
|||||||
annotationhighlighter.h \
|
annotationhighlighter.h \
|
||||||
gitsubmiteditorwidget.h \
|
gitsubmiteditorwidget.h \
|
||||||
gitsubmiteditor.h \
|
gitsubmiteditor.h \
|
||||||
gitversioncontrol.h \
|
|
||||||
gitsettings.h \
|
gitsettings.h \
|
||||||
branchmodel.h \
|
branchmodel.h \
|
||||||
stashdialog.h \
|
stashdialog.h \
|
||||||
@@ -36,7 +35,6 @@ SOURCES += gitplugin.cpp \
|
|||||||
annotationhighlighter.cpp \
|
annotationhighlighter.cpp \
|
||||||
gitsubmiteditorwidget.cpp \
|
gitsubmiteditorwidget.cpp \
|
||||||
gitsubmiteditor.cpp \
|
gitsubmiteditor.cpp \
|
||||||
gitversioncontrol.cpp \
|
|
||||||
gitsettings.cpp \
|
gitsettings.cpp \
|
||||||
branchmodel.cpp \
|
branchmodel.cpp \
|
||||||
stashdialog.cpp \
|
stashdialog.cpp \
|
||||||
|
|||||||
@@ -52,8 +52,6 @@ QtcPlugin {
|
|||||||
"gitsubmitpanel.ui",
|
"gitsubmitpanel.ui",
|
||||||
"gitutils.cpp",
|
"gitutils.cpp",
|
||||||
"gitutils.h",
|
"gitutils.h",
|
||||||
"gitversioncontrol.cpp",
|
|
||||||
"gitversioncontrol.h",
|
|
||||||
"logchangedialog.cpp",
|
"logchangedialog.cpp",
|
||||||
"logchangedialog.h",
|
"logchangedialog.h",
|
||||||
"mergetool.cpp",
|
"mergetool.cpp",
|
||||||
|
|||||||
@@ -31,7 +31,6 @@
|
|||||||
#include "giteditor.h"
|
#include "giteditor.h"
|
||||||
#include "gitplugin.h"
|
#include "gitplugin.h"
|
||||||
#include "gitsubmiteditor.h"
|
#include "gitsubmiteditor.h"
|
||||||
#include "gitversioncontrol.h"
|
|
||||||
#include "mergetool.h"
|
#include "mergetool.h"
|
||||||
#include "branchadddialog.h"
|
#include "branchadddialog.h"
|
||||||
#include "gerrit/gerritplugin.h"
|
#include "gerrit/gerritplugin.h"
|
||||||
@@ -2520,7 +2519,7 @@ bool GitClient::launchGitGui(const QString &workingDirectory) {
|
|||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath GitClient::gitBinDirectory()
|
FilePath GitClient::gitBinDirectory() const
|
||||||
{
|
{
|
||||||
const QString git = vcsBinary().toString();
|
const QString git = vcsBinary().toString();
|
||||||
if (git.isEmpty())
|
if (git.isEmpty())
|
||||||
@@ -2945,7 +2944,7 @@ void GitClient::revert(const QStringList &files, bool revertStaging)
|
|||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
switch (revertI(files, &isDirectory, &errorMessage, revertStaging)) {
|
switch (revertI(files, &isDirectory, &errorMessage, revertStaging)) {
|
||||||
case RevertOk:
|
case RevertOk:
|
||||||
GitPluginPrivate::instance()->gitVersionControl()->emitFilesChanged(files);
|
emit GitPluginPrivate::instance()->filesChanged(files);
|
||||||
break;
|
break;
|
||||||
case RevertCanceled:
|
case RevertCanceled:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ public:
|
|||||||
void launchGitK(const QString &workingDirectory, const QString &fileName);
|
void launchGitK(const QString &workingDirectory, const QString &fileName);
|
||||||
void launchGitK(const QString &workingDirectory) { launchGitK(workingDirectory, QString()); }
|
void launchGitK(const QString &workingDirectory) { launchGitK(workingDirectory, QString()); }
|
||||||
bool launchGitGui(const QString &workingDirectory);
|
bool launchGitGui(const QString &workingDirectory);
|
||||||
Utils::FilePath gitBinDirectory();
|
Utils::FilePath gitBinDirectory() const;
|
||||||
|
|
||||||
void launchRepositoryBrowser(const QString &workingDirectory);
|
void launchRepositoryBrowser(const QString &workingDirectory);
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,6 @@
|
|||||||
#include "gitconstants.h"
|
#include "gitconstants.h"
|
||||||
#include "giteditor.h"
|
#include "giteditor.h"
|
||||||
#include "gitsubmiteditor.h"
|
#include "gitsubmiteditor.h"
|
||||||
#include "gitversioncontrol.h"
|
|
||||||
#include "remotedialog.h"
|
#include "remotedialog.h"
|
||||||
#include "stashdialog.h"
|
#include "stashdialog.h"
|
||||||
#include "settingspage.h"
|
#include "settingspage.h"
|
||||||
@@ -71,6 +70,7 @@
|
|||||||
#include <vcsbase/submitfilemodel.h>
|
#include <vcsbase/submitfilemodel.h>
|
||||||
#include <vcsbase/vcsbaseeditor.h>
|
#include <vcsbase/vcsbaseeditor.h>
|
||||||
#include <vcsbase/vcsbaseconstants.h>
|
#include <vcsbase/vcsbaseconstants.h>
|
||||||
|
#include <vcsbase/vcscommand.h>
|
||||||
#include <vcsbase/basevcssubmiteditorfactory.h>
|
#include <vcsbase/basevcssubmiteditorfactory.h>
|
||||||
#include <vcsbase/vcsoutputwindow.h>
|
#include <vcsbase/vcsoutputwindow.h>
|
||||||
#include <vcsbase/cleandialog.h>
|
#include <vcsbase/cleandialog.h>
|
||||||
@@ -78,13 +78,11 @@
|
|||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QtPlugin>
|
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QScopedPointer>
|
|
||||||
|
|
||||||
#ifdef WITH_TESTS
|
#ifdef WITH_TESTS
|
||||||
#include <QTest>
|
#include <QTest>
|
||||||
@@ -100,6 +98,29 @@ using namespace VcsBase;
|
|||||||
namespace Git {
|
namespace Git {
|
||||||
namespace Internal {
|
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 unsigned minimumRequiredVersion = 0x010900;
|
||||||
|
|
||||||
const VcsBaseEditorParameters editorParameters[] = {
|
const VcsBaseEditorParameters editorParameters[] = {
|
||||||
@@ -138,7 +159,6 @@ GitPluginPrivate::~GitPluginPrivate()
|
|||||||
delete m_branchViewFactory;
|
delete m_branchViewFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GitPlugin::~GitPlugin()
|
GitPlugin::~GitPlugin()
|
||||||
{
|
{
|
||||||
delete dd;
|
delete dd;
|
||||||
@@ -311,22 +331,22 @@ void GitPlugin::extensionsInitialized()
|
|||||||
}
|
}
|
||||||
|
|
||||||
GitPluginPrivate::GitPluginPrivate()
|
GitPluginPrivate::GitPluginPrivate()
|
||||||
|
: VcsBase::VcsBasePluginPrivate(Context(Constants::GIT_CONTEXT))
|
||||||
{
|
{
|
||||||
dd = this;
|
dd = this;
|
||||||
|
|
||||||
|
m_gitClient = new GitClient(&m_settings);
|
||||||
|
setTopicCache(new GitTopicCache(m_gitClient));
|
||||||
|
|
||||||
m_fileActions.reserve(10);
|
m_fileActions.reserve(10);
|
||||||
m_projectActions.reserve(10);
|
m_projectActions.reserve(10);
|
||||||
m_repositoryActions.reserve(50);
|
m_repositoryActions.reserve(50);
|
||||||
|
|
||||||
Context context(Constants::GIT_CONTEXT);
|
Context context(Constants::GIT_CONTEXT);
|
||||||
|
|
||||||
m_gitClient = new GitClient(&m_settings);
|
|
||||||
|
|
||||||
auto vc = new GitVersionControl(m_gitClient);
|
|
||||||
initializeVcs(vc, context);
|
|
||||||
|
|
||||||
// Create the settings Page
|
// Create the settings Page
|
||||||
auto onApply = [this, vc] {
|
auto onApply = [this] {
|
||||||
vc->configurationChanged();
|
configurationChanged();
|
||||||
updateRepositoryBrowserAction();
|
updateRepositoryBrowserAction();
|
||||||
bool gitFoundOk;
|
bool gitFoundOk;
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
@@ -691,11 +711,6 @@ GitPluginPrivate::GitPluginPrivate()
|
|||||||
m_gerritPlugin->addToLocator(m_commandLocator);
|
m_gerritPlugin->addToLocator(m_commandLocator);
|
||||||
}
|
}
|
||||||
|
|
||||||
GitVersionControl *GitPluginPrivate::gitVersionControl() const
|
|
||||||
{
|
|
||||||
return static_cast<GitVersionControl *>(versionControl());
|
|
||||||
}
|
|
||||||
|
|
||||||
void GitPluginPrivate::diffCurrentFile()
|
void GitPluginPrivate::diffCurrentFile()
|
||||||
{
|
{
|
||||||
const VcsBasePluginState state = currentState();
|
const VcsBasePluginState state = currentState();
|
||||||
@@ -1480,6 +1495,153 @@ Gerrit::Internal::GerritPlugin *GitPluginPrivate::gerritPlugin() const
|
|||||||
return m_gerritPlugin;
|
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
|
#ifdef WITH_TESTS
|
||||||
|
|
||||||
void GitPlugin::testStatusParsing_data()
|
void GitPlugin::testStatusParsing_data()
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ namespace Internal { class GerritPlugin; }
|
|||||||
namespace Git {
|
namespace Git {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class GitVersionControl;
|
|
||||||
class GitClient;
|
class GitClient;
|
||||||
class CommitData;
|
class CommitData;
|
||||||
class StashDialog;
|
class StashDialog;
|
||||||
@@ -75,11 +74,43 @@ public:
|
|||||||
GitPluginPrivate();
|
GitPluginPrivate();
|
||||||
~GitPluginPrivate() final;
|
~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 GitPluginPrivate *instance();
|
||||||
static GitClient *client();
|
static GitClient *client();
|
||||||
|
|
||||||
GitVersionControl *gitVersionControl() const;
|
|
||||||
|
|
||||||
Gerrit::Internal::GerritPlugin *gerritPlugin() const;
|
Gerrit::Internal::GerritPlugin *gerritPlugin() const;
|
||||||
bool isCommitEditorOpen() const;
|
bool isCommitEditorOpen() const;
|
||||||
static QString msgRepositoryLabel(const QString &repository);
|
static QString msgRepositoryLabel(const QString &repository);
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ GitSubmitEditor::GitSubmitEditor(const VcsBaseSubmitEditorParameters *parameters
|
|||||||
{
|
{
|
||||||
connect(this, &VcsBaseSubmitEditor::diffSelectedRows, this, &GitSubmitEditor::slotDiffSelected);
|
connect(this, &VcsBaseSubmitEditor::diffSelectedRows, this, &GitSubmitEditor::slotDiffSelected);
|
||||||
connect(submitEditorWidget(), &GitSubmitEditorWidget::show, this, &GitSubmitEditor::showCommit);
|
connect(submitEditorWidget(), &GitSubmitEditorWidget::show, this, &GitSubmitEditor::showCommit);
|
||||||
connect(GitPluginPrivate::instance()->versionControl(), &Core::IVersionControl::repositoryChanged,
|
connect(GitPluginPrivate::instance(), &Core::IVersionControl::repositoryChanged,
|
||||||
this, &GitSubmitEditor::forceUpdateFileModel);
|
this, &GitSubmitEditor::forceUpdateFileModel);
|
||||||
connect(&m_fetchWatcher, &QFutureWatcher<CommitDataFetchResult>::finished,
|
connect(&m_fetchWatcher, &QFutureWatcher<CommitDataFetchResult>::finished,
|
||||||
this, &GitSubmitEditor::commitDataRetrieved);
|
this, &GitSubmitEditor::commitDataRetrieved);
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -26,7 +26,6 @@
|
|||||||
#include "mergetool.h"
|
#include "mergetool.h"
|
||||||
#include "gitclient.h"
|
#include "gitclient.h"
|
||||||
#include "gitplugin.h"
|
#include "gitplugin.h"
|
||||||
#include "gitversioncontrol.h"
|
|
||||||
|
|
||||||
#include <coreplugin/documentmanager.h>
|
#include <coreplugin/documentmanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
@@ -265,7 +264,7 @@ void MergeTool::done()
|
|||||||
.arg(exitCode));
|
.arg(exitCode));
|
||||||
}
|
}
|
||||||
GitPluginPrivate::client()->continueCommandIfNeeded(workingDirectory, exitCode == 0);
|
GitPluginPrivate::client()->continueCommandIfNeeded(workingDirectory, exitCode == 0);
|
||||||
GitPluginPrivate::instance()->gitVersionControl()->emitRepositoryChanged(workingDirectory);
|
GitPluginPrivate::instance()->emitRepositoryChanged(workingDirectory);
|
||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ add_qtc_plugin(Mercurial
|
|||||||
mercurialclient.cpp mercurialclient.h
|
mercurialclient.cpp mercurialclient.h
|
||||||
mercurialcommitpanel.ui
|
mercurialcommitpanel.ui
|
||||||
mercurialcommitwidget.cpp mercurialcommitwidget.h
|
mercurialcommitwidget.cpp mercurialcommitwidget.h
|
||||||
mercurialcontrol.cpp mercurialcontrol.h
|
|
||||||
mercurialeditor.cpp mercurialeditor.h
|
mercurialeditor.cpp mercurialeditor.h
|
||||||
mercurialplugin.cpp mercurialplugin.h
|
mercurialplugin.cpp mercurialplugin.h
|
||||||
mercurialsettings.cpp mercurialsettings.h
|
mercurialsettings.cpp mercurialsettings.h
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
include(../../qtcreatorplugin.pri)
|
include(../../qtcreatorplugin.pri)
|
||||||
SOURCES += mercurialplugin.cpp \
|
SOURCES += mercurialplugin.cpp \
|
||||||
optionspage.cpp \
|
optionspage.cpp \
|
||||||
mercurialcontrol.cpp \
|
|
||||||
mercurialclient.cpp \
|
mercurialclient.cpp \
|
||||||
annotationhighlighter.cpp \
|
annotationhighlighter.cpp \
|
||||||
mercurialeditor.cpp \
|
mercurialeditor.cpp \
|
||||||
@@ -14,7 +13,6 @@ SOURCES += mercurialplugin.cpp \
|
|||||||
HEADERS += mercurialplugin.h \
|
HEADERS += mercurialplugin.h \
|
||||||
constants.h \
|
constants.h \
|
||||||
optionspage.h \
|
optionspage.h \
|
||||||
mercurialcontrol.h \
|
|
||||||
mercurialclient.h \
|
mercurialclient.h \
|
||||||
annotationhighlighter.h \
|
annotationhighlighter.h \
|
||||||
mercurialeditor.h \
|
mercurialeditor.h \
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ QtcPlugin {
|
|||||||
"mercurialcommitpanel.ui",
|
"mercurialcommitpanel.ui",
|
||||||
"mercurialcommitwidget.cpp",
|
"mercurialcommitwidget.cpp",
|
||||||
"mercurialcommitwidget.h",
|
"mercurialcommitwidget.h",
|
||||||
"mercurialcontrol.cpp",
|
|
||||||
"mercurialcontrol.h",
|
|
||||||
"mercurialeditor.cpp",
|
"mercurialeditor.cpp",
|
||||||
"mercurialeditor.h",
|
"mercurialeditor.h",
|
||||||
"mercurialplugin.cpp",
|
"mercurialplugin.cpp",
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -27,7 +27,6 @@
|
|||||||
#include "optionspage.h"
|
#include "optionspage.h"
|
||||||
#include "constants.h"
|
#include "constants.h"
|
||||||
#include "mercurialclient.h"
|
#include "mercurialclient.h"
|
||||||
#include "mercurialcontrol.h"
|
|
||||||
#include "mercurialeditor.h"
|
#include "mercurialeditor.h"
|
||||||
#include "revertdialog.h"
|
#include "revertdialog.h"
|
||||||
#include "srcdestdialog.h"
|
#include "srcdestdialog.h"
|
||||||
@@ -55,6 +54,7 @@
|
|||||||
#include <vcsbase/vcsbaseeditor.h>
|
#include <vcsbase/vcsbaseeditor.h>
|
||||||
#include <vcsbase/vcsbaseconstants.h>
|
#include <vcsbase/vcsbaseconstants.h>
|
||||||
#include <vcsbase/vcsoutputwindow.h>
|
#include <vcsbase/vcsoutputwindow.h>
|
||||||
|
#include <vcsbase/vcscommand.h>
|
||||||
|
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
@@ -75,6 +75,26 @@ using namespace Utils;
|
|||||||
namespace Mercurial {
|
namespace Mercurial {
|
||||||
namespace Internal {
|
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[] = {
|
static const VcsBaseEditorParameters editorParameters[] = {
|
||||||
{
|
{
|
||||||
LogOutput,
|
LogOutput,
|
||||||
@@ -107,6 +127,34 @@ class MercurialPluginPrivate final : public VcsBase::VcsBasePluginPrivate
|
|||||||
public:
|
public:
|
||||||
MercurialPluginPrivate();
|
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:
|
private:
|
||||||
void updateActions(VcsBase::VcsBasePluginPrivate::ActionState) final;
|
void updateActions(VcsBase::VcsBasePluginPrivate::ActionState) final;
|
||||||
bool submitEditorAboutToClose() final;
|
bool submitEditorAboutToClose() final;
|
||||||
@@ -145,9 +193,8 @@ private:
|
|||||||
// Variables
|
// Variables
|
||||||
MercurialSettings m_settings;
|
MercurialSettings m_settings;
|
||||||
MercurialClient m_client{&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::CommandLocator *m_commandLocator = nullptr;
|
||||||
Core::ActionContainer *m_mercurialContainer = nullptr;
|
Core::ActionContainer *m_mercurialContainer = nullptr;
|
||||||
@@ -191,13 +238,15 @@ void MercurialPlugin::extensionsInitialized()
|
|||||||
}
|
}
|
||||||
|
|
||||||
MercurialPluginPrivate::MercurialPluginPrivate()
|
MercurialPluginPrivate::MercurialPluginPrivate()
|
||||||
|
: VcsBase::VcsBasePluginPrivate(Core::Context(Constants::MERCURIAL_CONTEXT))
|
||||||
{
|
{
|
||||||
dd = this;
|
dd = this;
|
||||||
|
|
||||||
|
setTopicCache(new MercurialTopicCache(&m_client));
|
||||||
|
|
||||||
Core::Context context(Constants::MERCURIAL_CONTEXT);
|
Core::Context context(Constants::MERCURIAL_CONTEXT);
|
||||||
|
|
||||||
initializeVcs(&m_control, context);
|
connect(&m_client, &VcsBaseClient::changed, this, &MercurialPluginPrivate::changed);
|
||||||
|
|
||||||
connect(&m_client, &VcsBaseClient::changed, &m_control, &MercurialControl::changed);
|
|
||||||
connect(&m_client, &MercurialClient::needUpdate, this, &MercurialPluginPrivate::update);
|
connect(&m_client, &MercurialClient::needUpdate, this, &MercurialPluginPrivate::update);
|
||||||
|
|
||||||
const auto describeFunc = [this](const QString &source, const QString &id) {
|
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));
|
arg(QDir::toNativeSeparators(m_submitRepository));
|
||||||
commitEditor->document()->setPreferredDisplayName(msg);
|
commitEditor->document()->setPreferredDisplayName(msg);
|
||||||
|
|
||||||
QString branch = m_control.vcsTopic(m_submitRepository);
|
const QString branch = vcsTopic(m_submitRepository);
|
||||||
commitEditor->setFields(m_submitRepository, branch,
|
commitEditor->setFields(m_submitRepository, branch,
|
||||||
m_settings.stringValue(MercurialSettings::userNameKey),
|
m_settings.stringValue(MercurialSettings::userNameKey),
|
||||||
m_settings.stringValue(MercurialSettings::userEmailKey), status);
|
m_settings.stringValue(MercurialSettings::userEmailKey), status);
|
||||||
@@ -669,6 +718,139 @@ void MercurialPluginPrivate::updateActions(VcsBasePluginPrivate::ActionState as)
|
|||||||
repoAction->setEnabled(repoEnabled);
|
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
|
#ifdef WITH_TESTS
|
||||||
|
|
||||||
void MercurialPlugin::testDiffFileResolving_data()
|
void MercurialPlugin::testDiffFileResolving_data()
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ add_qtc_plugin(Perforce
|
|||||||
perforcesettings.cpp perforcesettings.h
|
perforcesettings.cpp perforcesettings.h
|
||||||
perforcesubmiteditor.cpp perforcesubmiteditor.h
|
perforcesubmiteditor.cpp perforcesubmiteditor.h
|
||||||
perforcesubmiteditorwidget.cpp perforcesubmiteditorwidget.h
|
perforcesubmiteditorwidget.cpp perforcesubmiteditorwidget.h
|
||||||
perforceversioncontrol.cpp perforceversioncontrol.h
|
|
||||||
promptdialog.ui
|
promptdialog.ui
|
||||||
settingspage.cpp settingspage.h settingspage.ui
|
settingspage.cpp settingspage.h settingspage.ui
|
||||||
submitpanel.ui
|
submitpanel.ui
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ HEADERS += \
|
|||||||
changenumberdialog.h \
|
changenumberdialog.h \
|
||||||
perforcesubmiteditor.h \
|
perforcesubmiteditor.h \
|
||||||
pendingchangesdialog.h \
|
pendingchangesdialog.h \
|
||||||
perforceversioncontrol.h \
|
|
||||||
perforcesettings.h \
|
perforcesettings.h \
|
||||||
annotationhighlighter.h \
|
annotationhighlighter.h \
|
||||||
perforcesubmiteditorwidget.h
|
perforcesubmiteditorwidget.h
|
||||||
@@ -20,7 +19,6 @@ SOURCES += perforceplugin.cpp \
|
|||||||
changenumberdialog.cpp \
|
changenumberdialog.cpp \
|
||||||
perforcesubmiteditor.cpp \
|
perforcesubmiteditor.cpp \
|
||||||
pendingchangesdialog.cpp \
|
pendingchangesdialog.cpp \
|
||||||
perforceversioncontrol.cpp \
|
|
||||||
perforcesettings.cpp \
|
perforcesettings.cpp \
|
||||||
annotationhighlighter.cpp \
|
annotationhighlighter.cpp \
|
||||||
perforcesubmiteditorwidget.cpp
|
perforcesubmiteditorwidget.cpp
|
||||||
|
|||||||
@@ -31,8 +31,6 @@ QtcPlugin {
|
|||||||
"perforcesubmiteditor.h",
|
"perforcesubmiteditor.h",
|
||||||
"perforcesubmiteditorwidget.cpp",
|
"perforcesubmiteditorwidget.cpp",
|
||||||
"perforcesubmiteditorwidget.h",
|
"perforcesubmiteditorwidget.h",
|
||||||
"perforceversioncontrol.cpp",
|
|
||||||
"perforceversioncontrol.h",
|
|
||||||
"settingspage.cpp",
|
"settingspage.cpp",
|
||||||
"settingspage.h",
|
"settingspage.h",
|
||||||
"settingspage.ui",
|
"settingspage.ui",
|
||||||
|
|||||||
@@ -29,9 +29,9 @@
|
|||||||
#include "pendingchangesdialog.h"
|
#include "pendingchangesdialog.h"
|
||||||
#include "perforceeditor.h"
|
#include "perforceeditor.h"
|
||||||
#include "perforcesubmiteditor.h"
|
#include "perforcesubmiteditor.h"
|
||||||
#include "perforceversioncontrol.h"
|
|
||||||
#include "perforcechecker.h"
|
#include "perforcechecker.h"
|
||||||
#include "settingspage.h"
|
#include "settingspage.h"
|
||||||
|
#include "perforcesettings.h"
|
||||||
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/actionmanager/actioncontainer.h>
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
||||||
@@ -49,6 +49,7 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/synchronousprocess.h>
|
#include <utils/synchronousprocess.h>
|
||||||
#include <utils/temporarydirectory.h>
|
#include <utils/temporarydirectory.h>
|
||||||
|
|
||||||
#include <vcsbase/basevcseditorfactory.h>
|
#include <vcsbase/basevcseditorfactory.h>
|
||||||
#include <vcsbase/basevcssubmiteditorfactory.h>
|
#include <vcsbase/basevcssubmiteditorfactory.h>
|
||||||
#include <vcsbase/vcsbaseeditor.h>
|
#include <vcsbase/vcsbaseeditor.h>
|
||||||
@@ -191,12 +192,10 @@ bool PerforcePlugin::initialize(const QStringList & /* arguments */, QString *er
|
|||||||
}
|
}
|
||||||
|
|
||||||
PerforcePluginPrivate::PerforcePluginPrivate()
|
PerforcePluginPrivate::PerforcePluginPrivate()
|
||||||
|
: VcsBase::VcsBasePluginPrivate(Context(PERFORCE_CONTEXT))
|
||||||
{
|
{
|
||||||
Context context(PERFORCE_CONTEXT);
|
Context context(PERFORCE_CONTEXT);
|
||||||
|
|
||||||
auto vcsCtrl = new PerforceVersionControl(this);
|
|
||||||
initializeVcs(vcsCtrl, context);
|
|
||||||
|
|
||||||
dd = this;
|
dd = this;
|
||||||
|
|
||||||
m_settings.fromSettings(ICore::settings());
|
m_settings.fromSettings(ICore::settings());
|
||||||
@@ -442,7 +441,7 @@ void PerforcePluginPrivate::revertCurrentFile()
|
|||||||
PerforceResponse result2 = runP4Cmd(state.currentFileTopLevel(), args,
|
PerforceResponse result2 = runP4Cmd(state.currentFileTopLevel(), args,
|
||||||
CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
|
CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
|
||||||
if (!result2.error)
|
if (!result2.error)
|
||||||
perforceVersionControl()->emitFilesChanged(QStringList(state.currentFile()));
|
emit filesChanged(QStringList(state.currentFile()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerforcePluginPrivate::diffCurrentFile()
|
void PerforcePluginPrivate::diffCurrentFile()
|
||||||
@@ -514,11 +513,11 @@ void PerforcePluginPrivate::updateCheckout(const QString &workingDir, const QStr
|
|||||||
CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
|
CommandToWindow|StdOutToWindow|StdErrToWindow|ErrorToWindow);
|
||||||
if (dirs.empty()) {
|
if (dirs.empty()) {
|
||||||
if (!workingDir.isEmpty())
|
if (!workingDir.isEmpty())
|
||||||
perforceVersionControl()->emitRepositoryChanged(workingDir);
|
emit repositoryChanged(workingDir);
|
||||||
} else {
|
} else {
|
||||||
const QChar slash = QLatin1Char('/');
|
const QChar slash = QLatin1Char('/');
|
||||||
foreach (const QString &dir, dirs)
|
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);
|
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 (topLevel) {
|
||||||
if (rc)
|
if (rc)
|
||||||
*topLevel = m_settings.topLevelSymLinkTarget();
|
*topLevel = m_settings.topLevelSymLinkTarget();
|
||||||
@@ -942,6 +941,99 @@ PerforcePluginPrivate::createTemporaryArgumentFile(const QStringList &extraArgs,
|
|||||||
return rc;
|
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
|
// Run messages
|
||||||
|
|
||||||
static inline QString msgNotStarted(const QString &cmd)
|
static inline QString msgNotStarted(const QString &cmd)
|
||||||
@@ -1415,7 +1507,7 @@ void PerforcePluginPrivate::setSettings(const Settings &newSettings)
|
|||||||
dd->m_managedDirectoryCache.clear();
|
dd->m_managedDirectoryCache.clear();
|
||||||
dd->m_settings.toSettings(ICore::settings());
|
dd->m_settings.toSettings(ICore::settings());
|
||||||
getTopLevel();
|
getTopLevel();
|
||||||
perforceVersionControl()->emitConfigurationChanged();
|
emit dd->configurationChanged();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1462,11 +1554,6 @@ QString PerforcePluginPrivate::fileNameFromPerforceName(const QString& perforceN
|
|||||||
return dd->m_settings.mapToFileSystem(p4fileSpec);
|
return dd->m_settings.mapToFileSystem(p4fileSpec);
|
||||||
}
|
}
|
||||||
|
|
||||||
PerforceVersionControl *PerforcePluginPrivate::perforceVersionControl()
|
|
||||||
{
|
|
||||||
return static_cast<PerforceVersionControl *>(dd->versionControl());
|
|
||||||
}
|
|
||||||
|
|
||||||
void PerforcePluginPrivate::setTopLevel(const QString &topLevel)
|
void PerforcePluginPrivate::setTopLevel(const QString &topLevel)
|
||||||
{
|
{
|
||||||
if (m_settings.topLevel() == topLevel)
|
if (m_settings.topLevel() == topLevel)
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
|
|
||||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||||
#include <coreplugin/iversioncontrol.h>
|
#include <coreplugin/iversioncontrol.h>
|
||||||
|
|
||||||
|
#include <vcsbase/vcsbaseconstants.h>
|
||||||
#include <vcsbase/vcsbaseplugin.h>
|
#include <vcsbase/vcsbaseplugin.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
@@ -76,8 +78,28 @@ class PerforcePluginPrivate final : public VcsBase::VcsBasePluginPrivate
|
|||||||
public:
|
public:
|
||||||
PerforcePluginPrivate();
|
PerforcePluginPrivate();
|
||||||
|
|
||||||
bool managesDirectory(const QString &directory, QString *topLevel = nullptr);
|
// IVersionControl
|
||||||
bool managesFile(const QString &workingDirectory, const QString &fileName) const;
|
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 vcsOpen(const QString &workingDir, const QString &fileName, bool silently = false);
|
||||||
bool vcsAdd(const QString &workingDir, const QString &fileName);
|
bool vcsAdd(const QString &workingDir, const QString &fileName);
|
||||||
bool vcsDelete(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 revertProject(const QString &workingDir, const QStringList &args, bool unchangedOnly);
|
||||||
bool managesDirectoryFstat(const QString &directory);
|
bool managesDirectoryFstat(const QString &directory);
|
||||||
|
|
||||||
static PerforceVersionControl *perforceVersionControl();
|
|
||||||
|
|
||||||
Core::CommandLocator *m_commandLocator = nullptr;
|
Core::CommandLocator *m_commandLocator = nullptr;
|
||||||
Utils::ParameterAction *m_editAction = nullptr;
|
Utils::ParameterAction *m_editAction = nullptr;
|
||||||
Utils::ParameterAction *m_addAction = nullptr;
|
Utils::ParameterAction *m_addAction = nullptr;
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -5,7 +5,6 @@ add_qtc_plugin(Subversion
|
|||||||
settingspage.cpp settingspage.h settingspage.ui
|
settingspage.cpp settingspage.h settingspage.ui
|
||||||
subversionclient.cpp subversionclient.h
|
subversionclient.cpp subversionclient.h
|
||||||
subversionconstants.h
|
subversionconstants.h
|
||||||
subversioncontrol.cpp subversioncontrol.h
|
|
||||||
subversioneditor.cpp subversioneditor.h
|
subversioneditor.cpp subversioneditor.h
|
||||||
subversionplugin.cpp subversionplugin.h
|
subversionplugin.cpp subversionplugin.h
|
||||||
subversionsettings.cpp subversionsettings.h
|
subversionsettings.cpp subversionsettings.h
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ include(../../qtcreatorplugin.pri)
|
|||||||
HEADERS += annotationhighlighter.h \
|
HEADERS += annotationhighlighter.h \
|
||||||
subversionplugin.h \
|
subversionplugin.h \
|
||||||
subversionclient.h \
|
subversionclient.h \
|
||||||
subversioncontrol.h \
|
|
||||||
settingspage.h \
|
settingspage.h \
|
||||||
subversioneditor.h \
|
subversioneditor.h \
|
||||||
subversionsubmiteditor.h \
|
subversionsubmiteditor.h \
|
||||||
@@ -13,7 +12,6 @@ HEADERS += annotationhighlighter.h \
|
|||||||
SOURCES += annotationhighlighter.cpp \
|
SOURCES += annotationhighlighter.cpp \
|
||||||
subversionplugin.cpp \
|
subversionplugin.cpp \
|
||||||
subversionclient.cpp \
|
subversionclient.cpp \
|
||||||
subversioncontrol.cpp \
|
|
||||||
settingspage.cpp \
|
settingspage.cpp \
|
||||||
subversioneditor.cpp \
|
subversioneditor.cpp \
|
||||||
subversionsubmiteditor.cpp \
|
subversionsubmiteditor.cpp \
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ QtcPlugin {
|
|||||||
"subversionclient.cpp",
|
"subversionclient.cpp",
|
||||||
"subversionclient.h",
|
"subversionclient.h",
|
||||||
"subversionconstants.h",
|
"subversionconstants.h",
|
||||||
"subversioncontrol.cpp",
|
|
||||||
"subversioncontrol.h",
|
|
||||||
"subversioneditor.cpp",
|
"subversioneditor.cpp",
|
||||||
"subversioneditor.h",
|
"subversioneditor.h",
|
||||||
"subversionplugin.cpp",
|
"subversionplugin.cpp",
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ QStringList SubversionClient::addAuthenticationOptions(const VcsBaseClientSettin
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString SubversionClient::synchronousTopic(const QString &repository)
|
QString SubversionClient::synchronousTopic(const QString &repository) const
|
||||||
{
|
{
|
||||||
QStringList args;
|
QStringList args;
|
||||||
|
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public:
|
|||||||
// Add authorization options to the command line arguments.
|
// Add authorization options to the command line arguments.
|
||||||
static QStringList addAuthenticationOptions(const VcsBase::VcsBaseClientSettings &settings);
|
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 QString escapeFile(const QString &file);
|
||||||
static QStringList escapeFiles(const QStringList &files);
|
static QStringList escapeFiles(const QStringList &files);
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -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
|
|
||||||
@@ -31,7 +31,6 @@
|
|||||||
#include "subversionsubmiteditor.h"
|
#include "subversionsubmiteditor.h"
|
||||||
#include "subversionclient.h"
|
#include "subversionclient.h"
|
||||||
#include "subversionconstants.h"
|
#include "subversionconstants.h"
|
||||||
#include "subversioncontrol.h"
|
|
||||||
|
|
||||||
#include <vcsbase/basevcseditorfactory.h>
|
#include <vcsbase/basevcseditorfactory.h>
|
||||||
#include <vcsbase/vcscommand.h>
|
#include <vcsbase/vcscommand.h>
|
||||||
@@ -168,6 +167,28 @@ static inline QStringList svnDirectories()
|
|||||||
return rc;
|
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
|
// ------------- SubversionPlugin
|
||||||
|
|
||||||
static SubversionPluginPrivate *dd = nullptr;
|
static SubversionPluginPrivate *dd = nullptr;
|
||||||
@@ -180,8 +201,8 @@ SubversionPlugin::~SubversionPlugin()
|
|||||||
|
|
||||||
SubversionPluginPrivate::~SubversionPluginPrivate()
|
SubversionPluginPrivate::~SubversionPluginPrivate()
|
||||||
{
|
{
|
||||||
delete m_client;
|
|
||||||
cleanCommitMessageFile();
|
cleanCommitMessageFile();
|
||||||
|
delete m_client;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubversionPluginPrivate::cleanCommitMessageFile()
|
void SubversionPluginPrivate::cleanCommitMessageFile()
|
||||||
@@ -217,21 +238,21 @@ void SubversionPlugin::extensionsInitialized()
|
|||||||
dd->extensionsInitialized();
|
dd->extensionsInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
SubversionPluginPrivate::SubversionPluginPrivate() :
|
SubversionPluginPrivate::SubversionPluginPrivate()
|
||||||
|
: VcsBasePluginPrivate(Context(Constants::SUBVERSION_CONTEXT)),
|
||||||
m_svnDirectories(svnDirectories())
|
m_svnDirectories(svnDirectories())
|
||||||
{
|
{
|
||||||
dd = this;
|
dd = this;
|
||||||
|
|
||||||
|
m_client = new SubversionClient(&m_settings);
|
||||||
|
|
||||||
|
setTopicCache(new SubversionTopicCache(this));
|
||||||
|
|
||||||
using namespace Constants;
|
using namespace Constants;
|
||||||
using namespace Core::Constants;
|
using namespace Core::Constants;
|
||||||
Context context(SUBVERSION_CONTEXT);
|
Context context(SUBVERSION_CONTEXT);
|
||||||
|
|
||||||
auto vcsCtrl = new SubversionControl(this);
|
new SubversionSettingsPage(this, &m_settings, this);
|
||||||
initializeVcs(vcsCtrl, context);
|
|
||||||
|
|
||||||
m_client = new SubversionClient(&m_settings);
|
|
||||||
|
|
||||||
new SubversionSettingsPage(versionControl(), &m_settings, this);
|
|
||||||
|
|
||||||
new VcsSubmitEditorFactory(&submitParameters,
|
new VcsSubmitEditorFactory(&submitParameters,
|
||||||
[]() { return new SubversionSubmitEditor(&submitParameters); }, this);
|
[]() { return new SubversionSubmitEditor(&submitParameters); }, this);
|
||||||
@@ -402,7 +423,7 @@ SubversionPluginPrivate::SubversionPluginPrivate() :
|
|||||||
m_commandLocator->appendCommand(command);
|
m_commandLocator->appendCommand(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SubversionPluginPrivate::isVcsDirectory(const FilePath &fileName)
|
bool SubversionPluginPrivate::isVcsDirectory(const FilePath &fileName) const
|
||||||
{
|
{
|
||||||
const QString baseName = fileName.fileName();
|
const QString baseName = fileName.fileName();
|
||||||
return fileName.isDir() && contains(m_svnDirectories, [baseName](const QString &s) {
|
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;
|
return m_client;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -541,7 +561,7 @@ void SubversionPluginPrivate::revertAll()
|
|||||||
QMessageBox::warning(ICore::dialogParent(), title,
|
QMessageBox::warning(ICore::dialogParent(), title,
|
||||||
tr("Revert failed: %1").arg(revertResponse.message), QMessageBox::Ok);
|
tr("Revert failed: %1").arg(revertResponse.message), QMessageBox::Ok);
|
||||||
else
|
else
|
||||||
subVersionControl()->emitRepositoryChanged(state.topLevel());
|
emit repositoryChanged(state.topLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubversionPluginPrivate::revertCurrentFile()
|
void SubversionPluginPrivate::revertCurrentFile()
|
||||||
@@ -579,7 +599,7 @@ void SubversionPluginPrivate::revertCurrentFile()
|
|||||||
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
|
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
|
||||||
|
|
||||||
if (!revertResponse.error)
|
if (!revertResponse.error)
|
||||||
subVersionControl()->emitFilesChanged(QStringList(state.currentFile()));
|
emit filesChanged(QStringList(state.currentFile()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubversionPluginPrivate::diffProject()
|
void SubversionPluginPrivate::diffProject()
|
||||||
@@ -751,17 +771,17 @@ void SubversionPluginPrivate::svnUpdate(const QString &workingDir, const QString
|
|||||||
= runSvn(workingDir, args, 10 * m_client->vcsTimeoutS(),
|
= runSvn(workingDir, args, 10 * m_client->vcsTimeoutS(),
|
||||||
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
|
VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut);
|
||||||
if (!response.error)
|
if (!response.error)
|
||||||
subVersionControl()->emitRepositoryChanged(workingDir);
|
emit repositoryChanged(workingDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubversionPluginPrivate::annotateCurrentFile()
|
void SubversionPluginPrivate::annotateCurrentFile()
|
||||||
{
|
{
|
||||||
const VcsBasePluginState state = currentState();
|
const VcsBasePluginState state = currentState();
|
||||||
QTC_ASSERT(state.hasFile(), return);
|
QTC_ASSERT(state.hasFile(), return);
|
||||||
vcsAnnotate(state.currentFileTopLevel(), state.relativeCurrentFile());
|
vcsAnnotateHelper(state.currentFileTopLevel(), state.relativeCurrentFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SubversionPluginPrivate::vcsAnnotate(const QString &workingDir, const QString &file,
|
void SubversionPluginPrivate::vcsAnnotateHelper(const QString &workingDir, const QString &file,
|
||||||
const QString &revision /* = QString() */,
|
const QString &revision /* = QString() */,
|
||||||
int lineNumber /* = -1 */)
|
int lineNumber /* = -1 */)
|
||||||
{
|
{
|
||||||
@@ -896,7 +916,8 @@ IEditor *SubversionPluginPrivate::showOutputInEditor(const QString &title, const
|
|||||||
auto e = qobject_cast<SubversionEditorWidget*>(editor->widget());
|
auto e = qobject_cast<SubversionEditorWidget*>(editor->widget());
|
||||||
if (!e)
|
if (!e)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
connect(e, &VcsBaseEditorWidget::annotateRevisionRequested, this, &SubversionPluginPrivate::vcsAnnotate);
|
connect(e, &VcsBaseEditorWidget::annotateRevisionRequested,
|
||||||
|
this, &SubversionPluginPrivate::vcsAnnotateHelper);
|
||||||
e->setForceReadOnly(true);
|
e->setForceReadOnly(true);
|
||||||
s.replace(QLatin1Char(' '), QLatin1Char('_'));
|
s.replace(QLatin1Char(' '), QLatin1Char('_'));
|
||||||
e->textDocument()->setFallbackSaveAsFileName(s);
|
e->textDocument()->setFallbackSaveAsFileName(s);
|
||||||
@@ -1050,9 +1071,99 @@ bool SubversionPluginPrivate::checkSVNSubDir(const QDir &directory) const
|
|||||||
return false;
|
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
|
#ifdef WITH_TESTS
|
||||||
@@ -1080,4 +1191,3 @@ void SubversionPlugin::testLogResolving()
|
|||||||
|
|
||||||
} // Internal
|
} // Internal
|
||||||
} // Subversion
|
} // Subversion
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ namespace Subversion {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class SubversionSubmitEditor;
|
class SubversionSubmitEditor;
|
||||||
class SubversionControl;
|
|
||||||
class SubversionClient;
|
class SubversionClient;
|
||||||
|
|
||||||
struct SubversionResponse
|
struct SubversionResponse
|
||||||
@@ -70,9 +69,33 @@ public:
|
|||||||
SubversionPluginPrivate();
|
SubversionPluginPrivate();
|
||||||
~SubversionPluginPrivate() final;
|
~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);
|
SubversionSubmitEditor *openSubversionSubmitEditor(const QString &fileName);
|
||||||
|
|
||||||
@@ -80,8 +103,6 @@ public:
|
|||||||
bool vcsAdd(const QString &workingDir, const QString &fileName);
|
bool vcsAdd(const QString &workingDir, const QString &fileName);
|
||||||
bool vcsDelete(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 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);
|
bool vcsCheckout(const QString &directory, const QByteArray &url);
|
||||||
|
|
||||||
static SubversionPluginPrivate *instance();
|
static SubversionPluginPrivate *instance();
|
||||||
@@ -92,7 +113,7 @@ public:
|
|||||||
const QStringList &arguments, int timeOutS,
|
const QStringList &arguments, int timeOutS,
|
||||||
unsigned flags, QTextCodec *outputCodec = nullptr) const;
|
unsigned flags, QTextCodec *outputCodec = nullptr) const;
|
||||||
void describe(const QString &source, const QString &changeNr);
|
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);
|
const QString &revision = QString(), int lineNumber = -1);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -134,7 +155,6 @@ private:
|
|||||||
void svnUpdate(const QString &workingDir, const QString &relativePath = QString());
|
void svnUpdate(const QString &workingDir, const QString &relativePath = QString());
|
||||||
bool checkSVNSubDir(const QDir &directory) const;
|
bool checkSVNSubDir(const QDir &directory) const;
|
||||||
void startCommit(const QString &workingDir, const QStringList &files = QStringList());
|
void startCommit(const QString &workingDir, const QStringList &files = QStringList());
|
||||||
inline SubversionControl *subVersionControl() const;
|
|
||||||
|
|
||||||
const QStringList m_svnDirectories;
|
const QStringList m_svnDirectories;
|
||||||
|
|
||||||
|
|||||||
@@ -202,7 +202,7 @@ signals:
|
|||||||
// Passes on changed signals from VcsJob to Control
|
// Passes on changed signals from VcsJob to Control
|
||||||
void changed(const QVariant &v);
|
void changed(const QVariant &v);
|
||||||
|
|
||||||
protected:
|
public:
|
||||||
enum VcsCommandTag
|
enum VcsCommandTag
|
||||||
{
|
{
|
||||||
CreateRepositoryCommand,
|
CreateRepositoryCommand,
|
||||||
@@ -221,6 +221,7 @@ protected:
|
|||||||
LogCommand,
|
LogCommand,
|
||||||
StatusCommand
|
StatusCommand
|
||||||
};
|
};
|
||||||
|
protected:
|
||||||
virtual QString vcsCommandString(VcsCommandTag cmd) const;
|
virtual QString vcsCommandString(VcsCommandTag cmd) const;
|
||||||
virtual Core::Id vcsEditorKind(VcsCommandTag cmd) const = 0;
|
virtual Core::Id vcsEditorKind(VcsCommandTag cmd) const = 0;
|
||||||
virtual Utils::ExitCodeInterpreter exitCodeInterpreter(VcsCommandTag cmd) const;
|
virtual Utils::ExitCodeInterpreter exitCodeInterpreter(VcsCommandTag cmd) const;
|
||||||
|
|||||||
@@ -518,26 +518,14 @@ VCSBASE_EXPORT QDebug operator<<(QDebug in, const VcsBasePluginState &state)
|
|||||||
|
|
||||||
bool VcsBasePluginPrivate::supportsRepositoryCreation() const
|
bool VcsBasePluginPrivate::supportsRepositoryCreation() const
|
||||||
{
|
{
|
||||||
return m_versionControl && m_versionControl->supportsOperation(IVersionControl::CreateRepositoryOperation);
|
return supportsOperation(IVersionControl::CreateRepositoryOperation);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Internal::StateListener *m_listener = nullptr;
|
static Internal::StateListener *m_listener = nullptr;
|
||||||
|
|
||||||
VcsBasePluginPrivate::VcsBasePluginPrivate()
|
VcsBasePluginPrivate::VcsBasePluginPrivate(const Context &context)
|
||||||
{ }
|
: m_context(context)
|
||||||
|
|
||||||
VcsBasePluginPrivate::~VcsBasePluginPrivate()
|
|
||||||
{
|
{
|
||||||
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();
|
Internal::VcsPlugin *plugin = Internal::VcsPlugin::instance();
|
||||||
connect(plugin, &Internal::VcsPlugin::submitEditorAboutToClose,
|
connect(plugin, &Internal::VcsPlugin::submitEditorAboutToClose,
|
||||||
this, &VcsBasePluginPrivate::slotSubmitEditorAboutToClose);
|
this, &VcsBasePluginPrivate::slotSubmitEditorAboutToClose);
|
||||||
@@ -547,9 +535,9 @@ void VcsBasePluginPrivate::initializeVcs(IVersionControl *vc, const Context &con
|
|||||||
connect(m_listener, &Internal::StateListener::stateChanged,
|
connect(m_listener, &Internal::StateListener::stateChanged,
|
||||||
this, &VcsBasePluginPrivate::slotStateChanged);
|
this, &VcsBasePluginPrivate::slotStateChanged);
|
||||||
// VCSes might have become (un-)available, so clear the VCS directory cache
|
// VCSes might have become (un-)available, so clear the VCS directory cache
|
||||||
connect(vc, &IVersionControl::configurationChanged,
|
connect(this, &IVersionControl::configurationChanged,
|
||||||
VcsManager::instance(), &VcsManager::clearVersionControlCache);
|
VcsManager::instance(), &VcsManager::clearVersionControlCache);
|
||||||
connect(vc, &IVersionControl::configurationChanged,
|
connect(this, &IVersionControl::configurationChanged,
|
||||||
m_listener, &Internal::StateListener::slotStateChanged);
|
m_listener, &Internal::StateListener::slotStateChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -569,14 +557,9 @@ void VcsBasePluginPrivate::slotSubmitEditorAboutToClose(VcsBaseSubmitEditor *sub
|
|||||||
*result = submitEditorAboutToClose();
|
*result = submitEditorAboutToClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
IVersionControl *VcsBasePluginPrivate::versionControl() const
|
void VcsBasePluginPrivate::slotStateChanged(const Internal::State &newInternalState, Core::IVersionControl *vc)
|
||||||
{
|
{
|
||||||
return m_versionControl;
|
if (vc == this) {
|
||||||
}
|
|
||||||
|
|
||||||
void VcsBasePluginPrivate::slotStateChanged(const VcsBase::Internal::State &newInternalState, IVersionControl *vc)
|
|
||||||
{
|
|
||||||
if (vc == m_versionControl) {
|
|
||||||
// We are directly affected: Change state
|
// We are directly affected: Change state
|
||||||
if (!m_state.equals(newInternalState)) {
|
if (!m_state.equals(newInternalState)) {
|
||||||
m_state.setState(newInternalState);
|
m_state.setState(newInternalState);
|
||||||
@@ -637,7 +620,7 @@ void VcsBasePluginPrivate::promptToDeleteCurrentFile()
|
|||||||
{
|
{
|
||||||
const VcsBasePluginState state = currentState();
|
const VcsBasePluginState state = currentState();
|
||||||
QTC_ASSERT(state.hasFile(), return);
|
QTC_ASSERT(state.hasFile(), return);
|
||||||
const bool rc = VcsManager::promptToDelete(versionControl(), state.currentFile());
|
const bool rc = VcsManager::promptToDelete(this, state.currentFile());
|
||||||
if (!rc)
|
if (!rc)
|
||||||
QMessageBox::warning(ICore::dialogParent(), tr("Version Control"),
|
QMessageBox::warning(ICore::dialogParent(), tr("Version Control"),
|
||||||
tr("The file \"%1\" could not be deleted.").
|
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()
|
void VcsBasePluginPrivate::createRepository()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_versionControl->supportsOperation(IVersionControl::CreateRepositoryOperation), return);
|
QTC_ASSERT(supportsOperation(IVersionControl::CreateRepositoryOperation), return);
|
||||||
// Find current starting directory
|
// Find current starting directory
|
||||||
QString directory;
|
QString directory;
|
||||||
if (const Project *currentProject = ProjectTree::currentProject())
|
if (const Project *currentProject = ProjectTree::currentProject())
|
||||||
@@ -675,7 +658,7 @@ void VcsBasePluginPrivate::createRepository()
|
|||||||
return;
|
return;
|
||||||
} while (true);
|
} while (true);
|
||||||
// Create
|
// Create
|
||||||
const bool rc = m_versionControl->vcsCreateRepository(directory);
|
const bool rc = vcsCreateRepository(directory);
|
||||||
const QString nativeDir = QDir::toNativeSeparators(directory);
|
const QString nativeDir = QDir::toNativeSeparators(directory);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
QMessageBox::information(mw, tr("Repository Created"),
|
QMessageBox::information(mw, tr("Repository Created"),
|
||||||
|
|||||||
@@ -154,20 +154,17 @@ VCSBASE_EXPORT Utils::SynchronousProcessResponse runVcs(const QString &workingDi
|
|||||||
QTextCodec *outputCodec = nullptr,
|
QTextCodec *outputCodec = nullptr,
|
||||||
const QProcessEnvironment &env = {});
|
const QProcessEnvironment &env = {});
|
||||||
|
|
||||||
class VCSBASE_EXPORT VcsBasePluginPrivate : public QObject
|
class VCSBASE_EXPORT VcsBasePluginPrivate : public Core::IVersionControl
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit VcsBasePluginPrivate();
|
explicit VcsBasePluginPrivate(const Core::Context &context);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~VcsBasePluginPrivate() override;
|
|
||||||
|
|
||||||
void extensionsInitialized();
|
void extensionsInitialized();
|
||||||
|
|
||||||
const VcsBasePluginState ¤tState() const;
|
const VcsBasePluginState ¤tState() const;
|
||||||
Core::IVersionControl *versionControl() const;
|
|
||||||
|
|
||||||
// Display name of the commit action
|
// Display name of the commit action
|
||||||
virtual QString commitDisplayName() const;
|
virtual QString commitDisplayName() const;
|
||||||
@@ -209,16 +206,13 @@ protected:
|
|||||||
// Returns whether actions should be set up further.
|
// Returns whether actions should be set up further.
|
||||||
bool enableMenuAction(ActionState as, QAction *in) const;
|
bool enableMenuAction(ActionState as, QAction *in) const;
|
||||||
|
|
||||||
void initializeVcs(Core::IVersionControl *vc, const Core::Context &context);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void slotSubmitEditorAboutToClose(VcsBaseSubmitEditor *submitEditor, bool *result);
|
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;
|
bool supportsRepositoryCreation() const;
|
||||||
|
|
||||||
QPointer<VcsBaseSubmitEditor> m_submitEditor;
|
QPointer<VcsBaseSubmitEditor> m_submitEditor;
|
||||||
QPointer<Core::IVersionControl> m_versionControl;
|
|
||||||
Core::Context m_context;
|
Core::Context m_context;
|
||||||
VcsBasePluginState m_state;
|
VcsBasePluginState m_state;
|
||||||
int m_actionState = -1;
|
int m_actionState = -1;
|
||||||
|
|||||||
@@ -535,8 +535,7 @@ VcsBaseSubmitEditor::PromptSubmitResult
|
|||||||
return SubmitConfirmed;
|
return SubmitConfirmed;
|
||||||
CheckableMessageBox mb(Core::ICore::dialogParent());
|
CheckableMessageBox mb(Core::ICore::dialogParent());
|
||||||
const QString commitName = plugin->commitDisplayName();
|
const QString commitName = plugin->commitDisplayName();
|
||||||
mb.setWindowTitle(tr("Close %1 %2 Editor")
|
mb.setWindowTitle(tr("Close %1 %2 Editor").arg(plugin->displayName(), commitName));
|
||||||
.arg(plugin->versionControl()->displayName(), commitName));
|
|
||||||
mb.setIcon(QMessageBox::Question);
|
mb.setIcon(QMessageBox::Question);
|
||||||
QString message;
|
QString message;
|
||||||
if (canCommit) {
|
if (canCommit) {
|
||||||
|
|||||||
Reference in New Issue
Block a user