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:
@@ -30,7 +30,6 @@ add_qtc_plugin(Git
|
||||
gitsubmiteditorwidget.cpp gitsubmiteditorwidget.h
|
||||
gitsubmitpanel.ui
|
||||
gitutils.cpp gitutils.h
|
||||
gitversioncontrol.cpp gitversioncontrol.h
|
||||
logchangedialog.cpp logchangedialog.h
|
||||
mergetool.cpp mergetool.h
|
||||
remoteadditiondialog.ui
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
|
||||
#include "../gitplugin.h"
|
||||
#include "../gitclient.h"
|
||||
#include "../gitversioncontrol.h"
|
||||
#include "../gitconstants.h"
|
||||
#include <vcsbase/vcsbaseconstants.h>
|
||||
#include <vcsbase/vcsbaseeditor.h>
|
||||
@@ -473,7 +472,7 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
|
||||
// Try to find a matching repository for a project by asking the VcsManager.
|
||||
QString GerritPlugin::findLocalRepository(QString project, const QString &branch) const
|
||||
{
|
||||
const QStringList gitRepositories = VcsManager::repositories(GitPluginPrivate::instance()->gitVersionControl());
|
||||
const QStringList gitRepositories = VcsManager::repositories(GitPluginPrivate::instance());
|
||||
// Determine key (file name) to look for (qt/qtbase->'qtbase').
|
||||
const int slashPos = project.lastIndexOf('/');
|
||||
if (slashPos != -1)
|
||||
|
||||
@@ -12,7 +12,6 @@ HEADERS += gitplugin.h \
|
||||
annotationhighlighter.h \
|
||||
gitsubmiteditorwidget.h \
|
||||
gitsubmiteditor.h \
|
||||
gitversioncontrol.h \
|
||||
gitsettings.h \
|
||||
branchmodel.h \
|
||||
stashdialog.h \
|
||||
@@ -36,7 +35,6 @@ SOURCES += gitplugin.cpp \
|
||||
annotationhighlighter.cpp \
|
||||
gitsubmiteditorwidget.cpp \
|
||||
gitsubmiteditor.cpp \
|
||||
gitversioncontrol.cpp \
|
||||
gitsettings.cpp \
|
||||
branchmodel.cpp \
|
||||
stashdialog.cpp \
|
||||
|
||||
@@ -52,8 +52,6 @@ QtcPlugin {
|
||||
"gitsubmitpanel.ui",
|
||||
"gitutils.cpp",
|
||||
"gitutils.h",
|
||||
"gitversioncontrol.cpp",
|
||||
"gitversioncontrol.h",
|
||||
"logchangedialog.cpp",
|
||||
"logchangedialog.h",
|
||||
"mergetool.cpp",
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
#include "giteditor.h"
|
||||
#include "gitplugin.h"
|
||||
#include "gitsubmiteditor.h"
|
||||
#include "gitversioncontrol.h"
|
||||
#include "mergetool.h"
|
||||
#include "branchadddialog.h"
|
||||
#include "gerrit/gerritplugin.h"
|
||||
@@ -2520,7 +2519,7 @@ bool GitClient::launchGitGui(const QString &workingDirectory) {
|
||||
return success;
|
||||
}
|
||||
|
||||
FilePath GitClient::gitBinDirectory()
|
||||
FilePath GitClient::gitBinDirectory() const
|
||||
{
|
||||
const QString git = vcsBinary().toString();
|
||||
if (git.isEmpty())
|
||||
@@ -2945,7 +2944,7 @@ void GitClient::revert(const QStringList &files, bool revertStaging)
|
||||
QString errorMessage;
|
||||
switch (revertI(files, &isDirectory, &errorMessage, revertStaging)) {
|
||||
case RevertOk:
|
||||
GitPluginPrivate::instance()->gitVersionControl()->emitFilesChanged(files);
|
||||
emit GitPluginPrivate::instance()->filesChanged(files);
|
||||
break;
|
||||
case RevertCanceled:
|
||||
break;
|
||||
|
||||
@@ -326,7 +326,7 @@ public:
|
||||
void launchGitK(const QString &workingDirectory, const QString &fileName);
|
||||
void launchGitK(const QString &workingDirectory) { launchGitK(workingDirectory, QString()); }
|
||||
bool launchGitGui(const QString &workingDirectory);
|
||||
Utils::FilePath gitBinDirectory();
|
||||
Utils::FilePath gitBinDirectory() const;
|
||||
|
||||
void launchRepositoryBrowser(const QString &workingDirectory);
|
||||
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "gitconstants.h"
|
||||
#include "giteditor.h"
|
||||
#include "gitsubmiteditor.h"
|
||||
#include "gitversioncontrol.h"
|
||||
#include "remotedialog.h"
|
||||
#include "stashdialog.h"
|
||||
#include "settingspage.h"
|
||||
@@ -71,6 +70,7 @@
|
||||
#include <vcsbase/submitfilemodel.h>
|
||||
#include <vcsbase/vcsbaseeditor.h>
|
||||
#include <vcsbase/vcsbaseconstants.h>
|
||||
#include <vcsbase/vcscommand.h>
|
||||
#include <vcsbase/basevcssubmiteditorfactory.h>
|
||||
#include <vcsbase/vcsoutputwindow.h>
|
||||
#include <vcsbase/cleandialog.h>
|
||||
@@ -78,13 +78,11 @@
|
||||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QtPlugin>
|
||||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QFileDialog>
|
||||
#include <QMenu>
|
||||
#include <QScopedPointer>
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
#include <QTest>
|
||||
@@ -100,6 +98,29 @@ using namespace VcsBase;
|
||||
namespace Git {
|
||||
namespace Internal {
|
||||
|
||||
class GitTopicCache : public Core::IVersionControl::TopicCache
|
||||
{
|
||||
public:
|
||||
GitTopicCache(GitClient *client) :
|
||||
m_client(client)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
QString trackFile(const QString &repository) override
|
||||
{
|
||||
const QString gitDir = m_client->findGitDirForRepository(repository);
|
||||
return gitDir.isEmpty() ? QString() : (gitDir + "/HEAD");
|
||||
}
|
||||
|
||||
QString refreshTopic(const QString &repository) override
|
||||
{
|
||||
return m_client->synchronousTopic(repository);
|
||||
}
|
||||
|
||||
private:
|
||||
GitClient *m_client;
|
||||
};
|
||||
|
||||
const unsigned minimumRequiredVersion = 0x010900;
|
||||
|
||||
const VcsBaseEditorParameters editorParameters[] = {
|
||||
@@ -138,7 +159,6 @@ GitPluginPrivate::~GitPluginPrivate()
|
||||
delete m_branchViewFactory;
|
||||
}
|
||||
|
||||
|
||||
GitPlugin::~GitPlugin()
|
||||
{
|
||||
delete dd;
|
||||
@@ -311,22 +331,22 @@ void GitPlugin::extensionsInitialized()
|
||||
}
|
||||
|
||||
GitPluginPrivate::GitPluginPrivate()
|
||||
: VcsBase::VcsBasePluginPrivate(Context(Constants::GIT_CONTEXT))
|
||||
{
|
||||
dd = this;
|
||||
|
||||
m_gitClient = new GitClient(&m_settings);
|
||||
setTopicCache(new GitTopicCache(m_gitClient));
|
||||
|
||||
m_fileActions.reserve(10);
|
||||
m_projectActions.reserve(10);
|
||||
m_repositoryActions.reserve(50);
|
||||
|
||||
Context context(Constants::GIT_CONTEXT);
|
||||
|
||||
m_gitClient = new GitClient(&m_settings);
|
||||
|
||||
auto vc = new GitVersionControl(m_gitClient);
|
||||
initializeVcs(vc, context);
|
||||
|
||||
// Create the settings Page
|
||||
auto onApply = [this, vc] {
|
||||
vc->configurationChanged();
|
||||
auto onApply = [this] {
|
||||
configurationChanged();
|
||||
updateRepositoryBrowserAction();
|
||||
bool gitFoundOk;
|
||||
QString errorMessage;
|
||||
@@ -691,11 +711,6 @@ GitPluginPrivate::GitPluginPrivate()
|
||||
m_gerritPlugin->addToLocator(m_commandLocator);
|
||||
}
|
||||
|
||||
GitVersionControl *GitPluginPrivate::gitVersionControl() const
|
||||
{
|
||||
return static_cast<GitVersionControl *>(versionControl());
|
||||
}
|
||||
|
||||
void GitPluginPrivate::diffCurrentFile()
|
||||
{
|
||||
const VcsBasePluginState state = currentState();
|
||||
@@ -1480,6 +1495,153 @@ Gerrit::Internal::GerritPlugin *GitPluginPrivate::gerritPlugin() const
|
||||
return m_gerritPlugin;
|
||||
}
|
||||
|
||||
QString GitPluginPrivate::displayName() const
|
||||
{
|
||||
return QLatin1String("Git");
|
||||
}
|
||||
|
||||
Core::Id GitPluginPrivate::id() const
|
||||
{
|
||||
return Core::Id(VcsBase::Constants::VCS_ID_GIT);
|
||||
}
|
||||
|
||||
bool GitPluginPrivate::isVcsFileOrDirectory(const Utils::FilePath &fileName) const
|
||||
{
|
||||
if (fileName.fileName().compare(".git", Utils::HostOsInfo::fileNameCaseSensitivity()))
|
||||
return false;
|
||||
if (fileName.isDir())
|
||||
return true;
|
||||
QFile file(fileName.toString());
|
||||
if (!file.open(QFile::ReadOnly))
|
||||
return false;
|
||||
return file.read(8) == "gitdir: ";
|
||||
}
|
||||
|
||||
bool GitPluginPrivate::isConfigured() const
|
||||
{
|
||||
return !m_gitClient->vcsBinary().isEmpty();
|
||||
}
|
||||
|
||||
bool GitPluginPrivate::supportsOperation(Operation operation) const
|
||||
{
|
||||
if (!isConfigured())
|
||||
return false;
|
||||
|
||||
switch (operation) {
|
||||
case AddOperation:
|
||||
case DeleteOperation:
|
||||
case MoveOperation:
|
||||
case CreateRepositoryOperation:
|
||||
case SnapshotOperations:
|
||||
case AnnotateOperation:
|
||||
case InitialCheckoutOperation:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GitPluginPrivate::vcsOpen(const QString & /*fileName*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool GitPluginPrivate::vcsAdd(const QString & fileName)
|
||||
{
|
||||
const QFileInfo fi(fileName);
|
||||
return m_gitClient->synchronousAdd(fi.absolutePath(), {fi.fileName()});
|
||||
}
|
||||
|
||||
bool GitPluginPrivate::vcsDelete(const QString & fileName)
|
||||
{
|
||||
const QFileInfo fi(fileName);
|
||||
return m_gitClient->synchronousDelete(fi.absolutePath(), true, {fi.fileName()});
|
||||
}
|
||||
|
||||
bool GitPluginPrivate::vcsMove(const QString &from, const QString &to)
|
||||
{
|
||||
const QFileInfo fromInfo(from);
|
||||
const QFileInfo toInfo(to);
|
||||
return m_gitClient->synchronousMove(fromInfo.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath());
|
||||
}
|
||||
|
||||
bool GitPluginPrivate::vcsCreateRepository(const QString &directory)
|
||||
{
|
||||
return m_gitClient->synchronousInit(directory);
|
||||
}
|
||||
|
||||
QString GitPluginPrivate::vcsTopic(const QString &directory)
|
||||
{
|
||||
QString topic = Core::IVersionControl::vcsTopic(directory);
|
||||
const QString commandInProgress = m_gitClient->commandInProgressDescription(directory);
|
||||
if (!commandInProgress.isEmpty())
|
||||
topic += " (" + commandInProgress + ')';
|
||||
return topic;
|
||||
}
|
||||
|
||||
Core::ShellCommand *GitPluginPrivate::createInitialCheckoutCommand(const QString &url,
|
||||
const Utils::FilePath &baseDirectory,
|
||||
const QString &localName,
|
||||
const QStringList &extraArgs)
|
||||
{
|
||||
QStringList args = {"clone", "--progress"};
|
||||
args << extraArgs << url << localName;
|
||||
|
||||
auto command = new VcsBase::VcsCommand(baseDirectory.toString(), m_gitClient->processEnvironment());
|
||||
command->addFlags(VcsBase::VcsCommand::SuppressStdErr);
|
||||
command->addJob({m_gitClient->vcsBinary(), args}, -1);
|
||||
return command;
|
||||
}
|
||||
|
||||
GitPluginPrivate::RepoUrl GitPluginPrivate::getRepoUrl(const QString &location) const
|
||||
{
|
||||
return GitRemote(location);
|
||||
}
|
||||
|
||||
QStringList GitPluginPrivate::additionalToolsPath() const
|
||||
{
|
||||
QStringList res = m_gitClient->settings().searchPathList();
|
||||
const QString binaryPath = m_gitClient->gitBinDirectory().toString();
|
||||
if (!binaryPath.isEmpty() && !res.contains(binaryPath))
|
||||
res << binaryPath;
|
||||
return res;
|
||||
}
|
||||
|
||||
bool GitPluginPrivate::managesDirectory(const QString &directory, QString *topLevel) const
|
||||
{
|
||||
const QString topLevelFound = m_gitClient->findRepositoryForDirectory(directory);
|
||||
if (topLevel)
|
||||
*topLevel = topLevelFound;
|
||||
return !topLevelFound.isEmpty();
|
||||
}
|
||||
|
||||
bool GitPluginPrivate::managesFile(const QString &workingDirectory, const QString &fileName) const
|
||||
{
|
||||
return m_gitClient->managesFile(workingDirectory, fileName);
|
||||
}
|
||||
|
||||
QStringList GitPluginPrivate::unmanagedFiles(const QString &workingDir,
|
||||
const QStringList &filePaths) const
|
||||
{
|
||||
return m_gitClient->unmanagedFiles(workingDir, filePaths);
|
||||
}
|
||||
|
||||
bool GitPluginPrivate::vcsAnnotate(const QString &file, int line)
|
||||
{
|
||||
const QFileInfo fi(file);
|
||||
m_gitClient->annotate(fi.absolutePath(), fi.fileName(), QString(), line);
|
||||
return true;
|
||||
}
|
||||
|
||||
void GitPluginPrivate::emitFilesChanged(const QStringList &l)
|
||||
{
|
||||
emit filesChanged(l);
|
||||
}
|
||||
|
||||
void GitPluginPrivate::emitRepositoryChanged(const QString &r)
|
||||
{
|
||||
emit repositoryChanged(r);
|
||||
}
|
||||
|
||||
#ifdef WITH_TESTS
|
||||
|
||||
void GitPlugin::testStatusParsing_data()
|
||||
|
||||
@@ -57,7 +57,6 @@ namespace Internal { class GerritPlugin; }
|
||||
namespace Git {
|
||||
namespace Internal {
|
||||
|
||||
class GitVersionControl;
|
||||
class GitClient;
|
||||
class CommitData;
|
||||
class StashDialog;
|
||||
@@ -75,11 +74,43 @@ public:
|
||||
GitPluginPrivate();
|
||||
~GitPluginPrivate() final;
|
||||
|
||||
// IVersionControl
|
||||
QString displayName() const final;
|
||||
Core::Id id() const final;
|
||||
|
||||
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final;
|
||||
|
||||
bool managesDirectory(const QString &directory, QString *topLevel) const final;
|
||||
bool managesFile(const QString &workingDirectory, const QString &fileName) const final;
|
||||
QStringList unmanagedFiles(const QString &workingDir, const QStringList &filePaths) const final;
|
||||
|
||||
bool isConfigured() const final;
|
||||
bool supportsOperation(Operation operation) const final;
|
||||
bool vcsOpen(const QString &fileName) final;
|
||||
bool vcsAdd(const QString &fileName) final;
|
||||
bool vcsDelete(const QString &filename) final;
|
||||
bool vcsMove(const QString &from, const QString &to) final;
|
||||
bool vcsCreateRepository(const QString &directory) final;
|
||||
|
||||
bool vcsAnnotate(const QString &file, int line) final;
|
||||
QString vcsTopic(const QString &directory) final;
|
||||
|
||||
Core::ShellCommand *createInitialCheckoutCommand(const QString &url,
|
||||
const Utils::FilePath &baseDirectory,
|
||||
const QString &localName,
|
||||
const QStringList &extraArgs) final;
|
||||
|
||||
RepoUrl getRepoUrl(const QString &location) const override;
|
||||
|
||||
QStringList additionalToolsPath() const final;
|
||||
|
||||
void emitFilesChanged(const QStringList &);
|
||||
void emitRepositoryChanged(const QString &);
|
||||
|
||||
///
|
||||
static GitPluginPrivate *instance();
|
||||
static GitClient *client();
|
||||
|
||||
GitVersionControl *gitVersionControl() const;
|
||||
|
||||
Gerrit::Internal::GerritPlugin *gerritPlugin() const;
|
||||
bool isCommitEditorOpen() const;
|
||||
static QString msgRepositoryLabel(const QString &repository);
|
||||
|
||||
@@ -103,7 +103,7 @@ GitSubmitEditor::GitSubmitEditor(const VcsBaseSubmitEditorParameters *parameters
|
||||
{
|
||||
connect(this, &VcsBaseSubmitEditor::diffSelectedRows, this, &GitSubmitEditor::slotDiffSelected);
|
||||
connect(submitEditorWidget(), &GitSubmitEditorWidget::show, this, &GitSubmitEditor::showCommit);
|
||||
connect(GitPluginPrivate::instance()->versionControl(), &Core::IVersionControl::repositoryChanged,
|
||||
connect(GitPluginPrivate::instance(), &Core::IVersionControl::repositoryChanged,
|
||||
this, &GitSubmitEditor::forceUpdateFileModel);
|
||||
connect(&m_fetchWatcher, &QFutureWatcher<CommitDataFetchResult>::finished,
|
||||
this, &GitSubmitEditor::commitDataRetrieved);
|
||||
|
||||
@@ -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 "gitclient.h"
|
||||
#include "gitplugin.h"
|
||||
#include "gitversioncontrol.h"
|
||||
|
||||
#include <coreplugin/documentmanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
@@ -265,7 +264,7 @@ void MergeTool::done()
|
||||
.arg(exitCode));
|
||||
}
|
||||
GitPluginPrivate::client()->continueCommandIfNeeded(workingDirectory, exitCode == 0);
|
||||
GitPluginPrivate::instance()->gitVersionControl()->emitRepositoryChanged(workingDirectory);
|
||||
GitPluginPrivate::instance()->emitRepositoryChanged(workingDirectory);
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user