forked from qt-creator/qt-creator
Mercurial: Move plugin pimpl to .cpp
And remove a couple of singleton accesses and indirections. Change-Id: Ib54a0e5c580b5354d2b700de02034cce506d8017 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -58,15 +58,15 @@ namespace Internal {
|
||||
class MercurialDiffEditorController : public VcsBaseDiffEditorController
|
||||
{
|
||||
public:
|
||||
MercurialDiffEditorController(IDocument *document, const QString &workingDirectory);
|
||||
MercurialDiffEditorController(IDocument *document, VcsBaseClientImpl *client, const QString &workingDirectory);
|
||||
|
||||
protected:
|
||||
void runCommand(const QList<QStringList> &args, QTextCodec *codec = nullptr);
|
||||
QStringList addConfigurationArguments(const QStringList &args) const;
|
||||
};
|
||||
|
||||
MercurialDiffEditorController::MercurialDiffEditorController(IDocument *document, const QString &workingDirectory):
|
||||
VcsBaseDiffEditorController(document, MercurialPluginPrivate::client(), workingDirectory)
|
||||
MercurialDiffEditorController::MercurialDiffEditorController(IDocument *document, VcsBaseClientImpl *client, const QString &workingDirectory):
|
||||
VcsBaseDiffEditorController(document, client, workingDirectory)
|
||||
{
|
||||
setDisplayName("Hg Diff");
|
||||
}
|
||||
@@ -90,8 +90,8 @@ QStringList MercurialDiffEditorController::addConfigurationArguments(const QStri
|
||||
class FileDiffController : public MercurialDiffEditorController
|
||||
{
|
||||
public:
|
||||
FileDiffController(IDocument *document, const QString &dir, const QString &fileName) :
|
||||
MercurialDiffEditorController(document, dir),
|
||||
FileDiffController(IDocument *document, VcsBaseClient *client, const QString &dir, const QString &fileName) :
|
||||
MercurialDiffEditorController(document, client, dir),
|
||||
m_fileName(fileName)
|
||||
{ }
|
||||
|
||||
@@ -108,8 +108,8 @@ private:
|
||||
class FileListDiffController : public MercurialDiffEditorController
|
||||
{
|
||||
public:
|
||||
FileListDiffController(IDocument *document, const QString &dir, const QStringList &fileNames) :
|
||||
MercurialDiffEditorController(document, dir),
|
||||
FileListDiffController(IDocument *document, VcsBaseClient *client, const QString &dir, const QStringList &fileNames) :
|
||||
MercurialDiffEditorController(document, client, dir),
|
||||
m_fileNames(fileNames)
|
||||
{ }
|
||||
|
||||
@@ -128,8 +128,8 @@ private:
|
||||
class RepositoryDiffController : public MercurialDiffEditorController
|
||||
{
|
||||
public:
|
||||
RepositoryDiffController(IDocument *document, const QString &dir) :
|
||||
MercurialDiffEditorController(document, dir)
|
||||
RepositoryDiffController(IDocument *document, VcsBaseClient *client, const QString &dir) :
|
||||
MercurialDiffEditorController(document, client, dir)
|
||||
{ }
|
||||
|
||||
void reload() override
|
||||
@@ -401,8 +401,8 @@ void MercurialClient::diff(const QString &workingDir, const QStringList &files,
|
||||
const QString documentId = QString(Constants::MERCURIAL_PLUGIN)
|
||||
+ ".DiffRepo." + sourceFile;
|
||||
requestReload(documentId, sourceFile, title,
|
||||
[workingDir](IDocument *doc) {
|
||||
return new RepositoryDiffController(doc, workingDir);
|
||||
[this, workingDir](IDocument *doc) {
|
||||
return new RepositoryDiffController(doc, this, workingDir);
|
||||
});
|
||||
} else if (files.size() == 1) {
|
||||
fileName = files.at(0);
|
||||
@@ -411,8 +411,8 @@ void MercurialClient::diff(const QString &workingDir, const QStringList &files,
|
||||
const QString documentId = QString(Constants::MERCURIAL_PLUGIN)
|
||||
+ ".DiffFile." + sourceFile;
|
||||
requestReload(documentId, sourceFile, title,
|
||||
[workingDir, fileName](IDocument *doc) {
|
||||
return new FileDiffController(doc, workingDir, fileName);
|
||||
[this, workingDir, fileName](IDocument *doc) {
|
||||
return new FileDiffController(doc, this, workingDir, fileName);
|
||||
});
|
||||
} else {
|
||||
const QString title = tr("Mercurial Diff \"%1\"").arg(workingDir);
|
||||
@@ -420,8 +420,8 @@ void MercurialClient::diff(const QString &workingDir, const QStringList &files,
|
||||
const QString documentId = QString(Constants::MERCURIAL_PLUGIN)
|
||||
+ ".DiffFile." + workingDir;
|
||||
requestReload(documentId, sourceFile, title,
|
||||
[workingDir, files](IDocument *doc) {
|
||||
return new FileListDiffController(doc, workingDir, files);
|
||||
[this, workingDir, files](IDocument *doc) {
|
||||
return new FileListDiffController(doc, this, workingDir, files);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,11 +42,12 @@
|
||||
namespace Mercurial {
|
||||
namespace Internal {
|
||||
|
||||
MercurialEditorWidget::MercurialEditorWidget() :
|
||||
MercurialEditorWidget::MercurialEditorWidget(MercurialClient *client) :
|
||||
exactIdentifier12(QLatin1String(Constants::CHANGEIDEXACT12)),
|
||||
exactIdentifier40(QLatin1String(Constants::CHANGEIDEXACT40)),
|
||||
changesetIdentifier12(QLatin1String(Constants::CHANGESETID12)),
|
||||
changesetIdentifier40(QLatin1String(Constants::CHANGESETID40))
|
||||
changesetIdentifier40(QLatin1String(Constants::CHANGESETID40)),
|
||||
m_client(client)
|
||||
{
|
||||
setDiffFilePattern(QRegExp(QLatin1String(Constants::DIFFIDENTIFIER)));
|
||||
setLogEntryPattern(QRegExp(QLatin1String("^changeset:\\s+(\\S+)$")));
|
||||
@@ -94,7 +95,7 @@ QString MercurialEditorWidget::decorateVersion(const QString &revision) const
|
||||
const QFileInfo fi(source());
|
||||
const QString workingDirectory = fi.absolutePath();
|
||||
// Format with short summary
|
||||
return MercurialPluginPrivate::client()->shortDescriptionSync(workingDirectory, revision);
|
||||
return m_client->shortDescriptionSync(workingDirectory, revision);
|
||||
}
|
||||
|
||||
QStringList MercurialEditorWidget::annotationPreviousVersions(const QString &revision) const
|
||||
@@ -102,7 +103,7 @@ QStringList MercurialEditorWidget::annotationPreviousVersions(const QString &rev
|
||||
const QFileInfo fi(source());
|
||||
const QString workingDirectory = fi.absolutePath();
|
||||
// Retrieve parent revisions
|
||||
return MercurialPluginPrivate::client()->parentRevisionsSync(workingDirectory, fi.fileName(), revision);
|
||||
return m_client->parentRevisionsSync(workingDirectory, fi.fileName(), revision);
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -32,11 +32,13 @@
|
||||
namespace Mercurial {
|
||||
namespace Internal {
|
||||
|
||||
class MercurialClient;
|
||||
|
||||
class MercurialEditorWidget : public VcsBase::VcsBaseEditorWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
MercurialEditorWidget();
|
||||
explicit MercurialEditorWidget(MercurialClient *client);
|
||||
|
||||
private:
|
||||
QSet<QString> annotationChanges() const override;
|
||||
@@ -50,6 +52,8 @@ private:
|
||||
mutable QRegExp exactIdentifier40;
|
||||
mutable QRegExp changesetIdentifier12;
|
||||
const QRegExp changesetIdentifier40;
|
||||
|
||||
MercurialClient *m_client;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -100,13 +100,78 @@ static const VcsBaseSubmitEditorParameters submitEditorParameters = {
|
||||
VcsBaseSubmitEditorParameters::DiffFiles
|
||||
};
|
||||
|
||||
static MercurialPluginPrivate *dd = nullptr;
|
||||
|
||||
MercurialPluginPrivate::~MercurialPluginPrivate()
|
||||
class MercurialPluginPrivate final : public VcsBase::VcsBasePluginPrivate
|
||||
{
|
||||
delete m_client;
|
||||
m_client = nullptr;
|
||||
}
|
||||
Q_DECLARE_TR_FUNCTIONS(Mercurial::Internal::MercurialPlugin)
|
||||
|
||||
public:
|
||||
MercurialPluginPrivate();
|
||||
|
||||
private:
|
||||
void updateActions(VcsBase::VcsBasePluginPrivate::ActionState) final;
|
||||
bool submitEditorAboutToClose() final;
|
||||
|
||||
// File menu action slots
|
||||
void addCurrentFile();
|
||||
void annotateCurrentFile();
|
||||
void diffCurrentFile();
|
||||
void logCurrentFile();
|
||||
void revertCurrentFile();
|
||||
void statusCurrentFile();
|
||||
|
||||
// Directory menu action slots
|
||||
void diffRepository();
|
||||
void logRepository();
|
||||
void revertMulti();
|
||||
void statusMulti();
|
||||
|
||||
// Repository menu action slots
|
||||
void pull();
|
||||
void push();
|
||||
void update();
|
||||
void import();
|
||||
void incoming();
|
||||
void outgoing();
|
||||
void commit();
|
||||
void showCommitWidget(const QList<VcsBase::VcsBaseClient::StatusItem> &status);
|
||||
void commitFromEditor() override;
|
||||
void diffFromEditorSelected(const QStringList &files);
|
||||
|
||||
void createMenu(const Core::Context &context);
|
||||
void createFileActions(const Core::Context &context);
|
||||
void createDirectoryActions(const Core::Context &context);
|
||||
void createRepositoryActions(const Core::Context &context);
|
||||
|
||||
// Variables
|
||||
MercurialSettings m_settings;
|
||||
MercurialClient m_client{&m_settings};
|
||||
MercurialControl m_control{&m_client};
|
||||
|
||||
OptionsPage m_optionsPage{[this] { m_control.configurationChanged(); }, &m_settings};
|
||||
|
||||
Core::CommandLocator *m_commandLocator = nullptr;
|
||||
Core::ActionContainer *m_mercurialContainer = nullptr;
|
||||
|
||||
QList<QAction *> m_repositoryActionList;
|
||||
|
||||
// Menu items (file actions)
|
||||
ParameterAction *m_addAction = nullptr;
|
||||
ParameterAction *m_deleteAction = nullptr;
|
||||
ParameterAction *annotateFile = nullptr;
|
||||
ParameterAction *diffFile = nullptr;
|
||||
ParameterAction *logFile = nullptr;
|
||||
ParameterAction *revertFile = nullptr;
|
||||
ParameterAction *statusFile = nullptr;
|
||||
|
||||
QAction *m_createRepositoryAction = nullptr;
|
||||
QAction *m_menuAction = nullptr;
|
||||
|
||||
QString m_submitRepository;
|
||||
|
||||
bool m_submitActionTriggered = false;
|
||||
};
|
||||
|
||||
static MercurialPluginPrivate *dd = nullptr;
|
||||
|
||||
MercurialPlugin::~MercurialPlugin()
|
||||
{
|
||||
@@ -114,16 +179,6 @@ MercurialPlugin::~MercurialPlugin()
|
||||
dd = nullptr;
|
||||
}
|
||||
|
||||
MercurialPluginPrivate *MercurialPluginPrivate::instance()
|
||||
{
|
||||
return dd;
|
||||
}
|
||||
|
||||
MercurialClient *MercurialPluginPrivate::client()
|
||||
{
|
||||
return dd->m_client;
|
||||
}
|
||||
|
||||
bool MercurialPlugin::initialize(const QStringList & /* arguments */, QString * /*errorMessage */)
|
||||
{
|
||||
dd = new MercurialPluginPrivate;
|
||||
@@ -140,19 +195,15 @@ MercurialPluginPrivate::MercurialPluginPrivate()
|
||||
dd = this;
|
||||
Core::Context context(Constants::MERCURIAL_CONTEXT);
|
||||
|
||||
m_client = new MercurialClient(&m_settings);
|
||||
auto vc = new MercurialControl(m_client);
|
||||
initializeVcs(vc, context);
|
||||
initializeVcs(&m_control, context);
|
||||
|
||||
new OptionsPage(vc, this);
|
||||
|
||||
connect(m_client, &VcsBaseClient::changed, vc, &MercurialControl::changed);
|
||||
connect(m_client, &MercurialClient::needUpdate, this, &MercurialPluginPrivate::update);
|
||||
connect(&m_client, &VcsBaseClient::changed, &m_control, &MercurialControl::changed);
|
||||
connect(&m_client, &MercurialClient::needUpdate, this, &MercurialPluginPrivate::update);
|
||||
|
||||
const auto describeFunc = [this](const QString &source, const QString &id) {
|
||||
m_client->view(source, id);
|
||||
m_client.view(source, id);
|
||||
};
|
||||
const auto widgetCreator = []() { return new MercurialEditorWidget; };
|
||||
const auto widgetCreator = [this] { return new MercurialEditorWidget(&m_client); };
|
||||
for (auto &editor : editorParameters)
|
||||
new VcsEditorFactory(&editor, widgetCreator, describeFunc, this);
|
||||
|
||||
@@ -248,7 +299,7 @@ void MercurialPluginPrivate::addCurrentFile()
|
||||
{
|
||||
const VcsBasePluginState state = currentState();
|
||||
QTC_ASSERT(state.hasFile(), return);
|
||||
m_client->synchronousAdd(state.currentFileTopLevel(), state.relativeCurrentFile());
|
||||
m_client.synchronousAdd(state.currentFileTopLevel(), state.relativeCurrentFile());
|
||||
}
|
||||
|
||||
void MercurialPluginPrivate::annotateCurrentFile()
|
||||
@@ -258,21 +309,21 @@ void MercurialPluginPrivate::annotateCurrentFile()
|
||||
currentLine = editor->currentLine();
|
||||
const VcsBasePluginState state = currentState();
|
||||
QTC_ASSERT(state.hasFile(), return);
|
||||
m_client->annotate(state.currentFileTopLevel(), state.relativeCurrentFile(), QString(), currentLine);
|
||||
m_client.annotate(state.currentFileTopLevel(), state.relativeCurrentFile(), QString(), currentLine);
|
||||
}
|
||||
|
||||
void MercurialPluginPrivate::diffCurrentFile()
|
||||
{
|
||||
const VcsBasePluginState state = currentState();
|
||||
QTC_ASSERT(state.hasFile(), return);
|
||||
m_client->diff(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()));
|
||||
m_client.diff(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()));
|
||||
}
|
||||
|
||||
void MercurialPluginPrivate::logCurrentFile()
|
||||
{
|
||||
const VcsBasePluginState state = currentState();
|
||||
QTC_ASSERT(state.hasFile(), return);
|
||||
m_client->log(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()),
|
||||
m_client.log(state.currentFileTopLevel(), QStringList(state.relativeCurrentFile()),
|
||||
QStringList(), true);
|
||||
}
|
||||
|
||||
@@ -284,14 +335,14 @@ void MercurialPluginPrivate::revertCurrentFile()
|
||||
RevertDialog reverter(Core::ICore::dialogParent());
|
||||
if (reverter.exec() != QDialog::Accepted)
|
||||
return;
|
||||
m_client->revertFile(state.currentFileTopLevel(), state.relativeCurrentFile(), reverter.revision());
|
||||
m_client.revertFile(state.currentFileTopLevel(), state.relativeCurrentFile(), reverter.revision());
|
||||
}
|
||||
|
||||
void MercurialPluginPrivate::statusCurrentFile()
|
||||
{
|
||||
const VcsBasePluginState state = currentState();
|
||||
QTC_ASSERT(state.hasFile(), return);
|
||||
m_client->status(state.currentFileTopLevel(), state.relativeCurrentFile());
|
||||
m_client.status(state.currentFileTopLevel(), state.relativeCurrentFile());
|
||||
}
|
||||
|
||||
void MercurialPluginPrivate::createDirectoryActions(const Core::Context &context)
|
||||
@@ -329,14 +380,14 @@ void MercurialPluginPrivate::diffRepository()
|
||||
{
|
||||
const VcsBasePluginState state = currentState();
|
||||
QTC_ASSERT(state.hasTopLevel(), return);
|
||||
m_client->diff(state.topLevel());
|
||||
m_client.diff(state.topLevel());
|
||||
}
|
||||
|
||||
void MercurialPluginPrivate::logRepository()
|
||||
{
|
||||
const VcsBasePluginState state = currentState();
|
||||
QTC_ASSERT(state.hasTopLevel(), return);
|
||||
m_client->log(state.topLevel());
|
||||
m_client.log(state.topLevel());
|
||||
}
|
||||
|
||||
void MercurialPluginPrivate::revertMulti()
|
||||
@@ -347,7 +398,7 @@ void MercurialPluginPrivate::revertMulti()
|
||||
RevertDialog reverter(Core::ICore::dialogParent());
|
||||
if (reverter.exec() != QDialog::Accepted)
|
||||
return;
|
||||
m_client->revertAll(state.topLevel(), reverter.revision());
|
||||
m_client.revertAll(state.topLevel(), reverter.revision());
|
||||
}
|
||||
|
||||
void MercurialPluginPrivate::statusMulti()
|
||||
@@ -355,7 +406,7 @@ void MercurialPluginPrivate::statusMulti()
|
||||
const VcsBasePluginState state = currentState();
|
||||
QTC_ASSERT(state.hasTopLevel(), return);
|
||||
|
||||
m_client->status(state.topLevel());
|
||||
m_client.status(state.topLevel());
|
||||
}
|
||||
|
||||
void MercurialPluginPrivate::createRepositoryActions(const Core::Context &context)
|
||||
@@ -421,11 +472,11 @@ void MercurialPluginPrivate::pull()
|
||||
const VcsBasePluginState state = currentState();
|
||||
QTC_ASSERT(state.hasTopLevel(), return);
|
||||
|
||||
SrcDestDialog dialog(SrcDestDialog::incoming, Core::ICore::dialogParent());
|
||||
SrcDestDialog dialog(state, SrcDestDialog::incoming, Core::ICore::dialogParent());
|
||||
dialog.setWindowTitle(tr("Pull Source"));
|
||||
if (dialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
m_client->synchronousPull(dialog.workingDir(), dialog.getRepositoryString());
|
||||
m_client.synchronousPull(dialog.workingDir(), dialog.getRepositoryString());
|
||||
}
|
||||
|
||||
void MercurialPluginPrivate::push()
|
||||
@@ -433,11 +484,11 @@ void MercurialPluginPrivate::push()
|
||||
const VcsBasePluginState state = currentState();
|
||||
QTC_ASSERT(state.hasTopLevel(), return);
|
||||
|
||||
SrcDestDialog dialog(SrcDestDialog::outgoing, Core::ICore::dialogParent());
|
||||
SrcDestDialog dialog(state, SrcDestDialog::outgoing, Core::ICore::dialogParent());
|
||||
dialog.setWindowTitle(tr("Push Destination"));
|
||||
if (dialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
m_client->synchronousPush(dialog.workingDir(), dialog.getRepositoryString());
|
||||
m_client.synchronousPush(dialog.workingDir(), dialog.getRepositoryString());
|
||||
}
|
||||
|
||||
void MercurialPluginPrivate::update()
|
||||
@@ -449,7 +500,7 @@ void MercurialPluginPrivate::update()
|
||||
updateDialog.setWindowTitle(tr("Update"));
|
||||
if (updateDialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
m_client->update(state.topLevel(), updateDialog.revision());
|
||||
m_client.update(state.topLevel(), updateDialog.revision());
|
||||
}
|
||||
|
||||
void MercurialPluginPrivate::import()
|
||||
@@ -465,7 +516,7 @@ void MercurialPluginPrivate::import()
|
||||
return;
|
||||
|
||||
const QStringList fileNames = importDialog.selectedFiles();
|
||||
m_client->import(state.topLevel(), fileNames);
|
||||
m_client.import(state.topLevel(), fileNames);
|
||||
}
|
||||
|
||||
void MercurialPluginPrivate::incoming()
|
||||
@@ -473,18 +524,18 @@ void MercurialPluginPrivate::incoming()
|
||||
const VcsBasePluginState state = currentState();
|
||||
QTC_ASSERT(state.hasTopLevel(), return);
|
||||
|
||||
SrcDestDialog dialog(SrcDestDialog::incoming, Core::ICore::dialogParent());
|
||||
SrcDestDialog dialog(state, SrcDestDialog::incoming, Core::ICore::dialogParent());
|
||||
dialog.setWindowTitle(tr("Incoming Source"));
|
||||
if (dialog.exec() != QDialog::Accepted)
|
||||
return;
|
||||
m_client->incoming(state.topLevel(), dialog.getRepositoryString());
|
||||
m_client.incoming(state.topLevel(), dialog.getRepositoryString());
|
||||
}
|
||||
|
||||
void MercurialPluginPrivate::outgoing()
|
||||
{
|
||||
const VcsBasePluginState state = currentState();
|
||||
QTC_ASSERT(state.hasTopLevel(), return);
|
||||
m_client->outgoing(state.topLevel());
|
||||
m_client.outgoing(state.topLevel());
|
||||
}
|
||||
|
||||
void MercurialPluginPrivate::commit()
|
||||
@@ -500,14 +551,14 @@ void MercurialPluginPrivate::commit()
|
||||
|
||||
m_submitRepository = state.topLevel();
|
||||
|
||||
connect(m_client, &MercurialClient::parsedStatus, this, &MercurialPluginPrivate::showCommitWidget);
|
||||
m_client->emitParsedStatus(m_submitRepository);
|
||||
connect(&m_client, &MercurialClient::parsedStatus, this, &MercurialPluginPrivate::showCommitWidget);
|
||||
m_client.emitParsedStatus(m_submitRepository);
|
||||
}
|
||||
|
||||
void MercurialPluginPrivate::showCommitWidget(const QList<VcsBaseClient::StatusItem> &status)
|
||||
{
|
||||
//Once we receive our data release the connection so it can be reused elsewhere
|
||||
disconnect(m_client, &MercurialClient::parsedStatus, this, &MercurialPluginPrivate::showCommitWidget);
|
||||
disconnect(&m_client, &MercurialClient::parsedStatus, this, &MercurialPluginPrivate::showCommitWidget);
|
||||
|
||||
if (status.isEmpty()) {
|
||||
VcsOutputWindow::appendError(tr("There are no changes to commit."));
|
||||
@@ -542,15 +593,15 @@ void MercurialPluginPrivate::showCommitWidget(const QList<VcsBaseClient::StatusI
|
||||
arg(QDir::toNativeSeparators(m_submitRepository));
|
||||
commitEditor->document()->setPreferredDisplayName(msg);
|
||||
|
||||
QString branch = versionControl()->vcsTopic(m_submitRepository);
|
||||
QString branch = m_control.vcsTopic(m_submitRepository);
|
||||
commitEditor->setFields(m_submitRepository, branch,
|
||||
m_client->settings().stringValue(MercurialSettings::userNameKey),
|
||||
m_client->settings().stringValue(MercurialSettings::userEmailKey), status);
|
||||
m_settings.stringValue(MercurialSettings::userNameKey),
|
||||
m_settings.stringValue(MercurialSettings::userEmailKey), status);
|
||||
}
|
||||
|
||||
void MercurialPluginPrivate::diffFromEditorSelected(const QStringList &files)
|
||||
{
|
||||
m_client->diff(m_submitRepository, files);
|
||||
m_client.diff(m_submitRepository, files);
|
||||
}
|
||||
|
||||
void MercurialPluginPrivate::commitFromEditor()
|
||||
@@ -590,7 +641,7 @@ bool MercurialPluginPrivate::submitEditorAboutToClose()
|
||||
QStringList extraOptions;
|
||||
if (!commitEditor->committerInfo().isEmpty())
|
||||
extraOptions << QLatin1String("-u") << commitEditor->committerInfo();
|
||||
m_client->commit(m_submitRepository, files, editorFile->filePath().toString(),
|
||||
m_client.commit(m_submitRepository, files, editorFile->filePath().toString(),
|
||||
extraOptions);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -25,119 +25,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mercurialsettings.h"
|
||||
|
||||
#include <vcsbase/vcsbaseclient.h>
|
||||
#include <vcsbase/vcsbaseplugin.h>
|
||||
#include <coreplugin/icontext.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAction;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Core {
|
||||
class ActionContainer;
|
||||
class CommandLocator;
|
||||
} // namespace Core
|
||||
|
||||
namespace Utils { class ParameterAction; }
|
||||
namespace VcsBase { class VcsBaseSubmitEditor; }
|
||||
#include <extensionsystem/iplugin.h>
|
||||
|
||||
namespace Mercurial {
|
||||
namespace Internal {
|
||||
|
||||
class OptionsPage;
|
||||
class MercurialClient;
|
||||
|
||||
class MercurialPluginPrivate final : public VcsBase::VcsBasePluginPrivate
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MercurialPluginPrivate();
|
||||
~MercurialPluginPrivate() final;
|
||||
|
||||
static MercurialPluginPrivate *instance();
|
||||
static MercurialClient *client();
|
||||
|
||||
protected:
|
||||
void updateActions(VcsBase::VcsBasePluginPrivate::ActionState) override;
|
||||
bool submitEditorAboutToClose() override;
|
||||
|
||||
private:
|
||||
// File menu action slots
|
||||
void addCurrentFile();
|
||||
void annotateCurrentFile();
|
||||
void diffCurrentFile();
|
||||
void logCurrentFile();
|
||||
void revertCurrentFile();
|
||||
void statusCurrentFile();
|
||||
|
||||
// Directory menu action slots
|
||||
void diffRepository();
|
||||
void logRepository();
|
||||
void revertMulti();
|
||||
void statusMulti();
|
||||
|
||||
// Repository menu action slots
|
||||
void pull();
|
||||
void push();
|
||||
void update();
|
||||
void import();
|
||||
void incoming();
|
||||
void outgoing();
|
||||
void commit();
|
||||
void showCommitWidget(const QList<VcsBase::VcsBaseClient::StatusItem> &status);
|
||||
void commitFromEditor() override;
|
||||
void diffFromEditorSelected(const QStringList &files);
|
||||
|
||||
//TODO implement
|
||||
/* //repository management action slots
|
||||
void merge();
|
||||
void branch();
|
||||
void heads();
|
||||
void parents();
|
||||
void tags();
|
||||
void tip();
|
||||
void paths();
|
||||
|
||||
//less used repository action
|
||||
void init();
|
||||
void serve();*/
|
||||
|
||||
void createMenu(const Core::Context &context);
|
||||
void createFileActions(const Core::Context &context);
|
||||
void createDirectoryActions(const Core::Context &context);
|
||||
void createRepositoryActions(const Core::Context &context);
|
||||
|
||||
// Variables
|
||||
MercurialSettings m_settings;
|
||||
OptionsPage *optionsPage = nullptr;
|
||||
MercurialClient *m_client = nullptr;
|
||||
|
||||
Core::CommandLocator *m_commandLocator = nullptr;
|
||||
Core::ActionContainer *m_mercurialContainer = nullptr;
|
||||
|
||||
QList<QAction *> m_repositoryActionList;
|
||||
|
||||
// Menu items (file actions)
|
||||
Utils::ParameterAction *m_addAction = nullptr;
|
||||
Utils::ParameterAction *m_deleteAction = nullptr;
|
||||
Utils::ParameterAction *annotateFile = nullptr;
|
||||
Utils::ParameterAction *diffFile = nullptr;
|
||||
Utils::ParameterAction *logFile = nullptr;
|
||||
Utils::ParameterAction *renameFile = nullptr;
|
||||
Utils::ParameterAction *revertFile = nullptr;
|
||||
Utils::ParameterAction *statusFile = nullptr;
|
||||
|
||||
QAction *m_createRepositoryAction = nullptr;
|
||||
QAction *m_menuAction = nullptr;
|
||||
|
||||
QString m_submitRepository;
|
||||
|
||||
bool m_submitActionTriggered = false;
|
||||
};
|
||||
|
||||
class MercurialPlugin final : public ExtensionSystem::IPlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -45,23 +45,24 @@ class OptionsPageWidget final : public Core::IOptionsPageWidget
|
||||
Q_DECLARE_TR_FUNCTIONS(Mercurial::Internal::OptionsPageWidget)
|
||||
|
||||
public:
|
||||
explicit OptionsPageWidget(Core::IVersionControl *control);
|
||||
OptionsPageWidget(const std::function<void()> &onApply, MercurialSettings *settings);
|
||||
void apply() final;
|
||||
|
||||
private:
|
||||
Ui::OptionsPage m_ui;
|
||||
Core::IVersionControl *m_control;
|
||||
std::function<void()> m_onApply;
|
||||
MercurialSettings *m_settings;
|
||||
};
|
||||
|
||||
OptionsPageWidget::OptionsPageWidget(Core::IVersionControl *control)
|
||||
: m_control(control)
|
||||
OptionsPageWidget::OptionsPageWidget(const std::function<void()> &onApply, MercurialSettings *settings)
|
||||
: m_onApply(onApply), m_settings(settings)
|
||||
{
|
||||
m_ui.setupUi(this);
|
||||
m_ui.commandChooser->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
||||
m_ui.commandChooser->setHistoryCompleter(QLatin1String("Mercurial.Command.History"));
|
||||
m_ui.commandChooser->setPromptDialogTitle(tr("Mercurial Command"));
|
||||
|
||||
const VcsBaseClientSettings &s = MercurialPluginPrivate::client()->settings();
|
||||
const VcsBaseClientSettings &s = *settings;
|
||||
|
||||
m_ui.commandChooser->setPath(s.stringValue(MercurialSettings::binaryPathKey));
|
||||
m_ui.defaultUsernameLineEdit->setText(s.stringValue(MercurialSettings::userNameKey));
|
||||
@@ -79,20 +80,18 @@ void OptionsPageWidget::apply()
|
||||
ms.setValue(MercurialSettings::logCountKey, m_ui.logEntriesCount->value());
|
||||
ms.setValue(MercurialSettings::timeoutKey, m_ui.timeout->value());
|
||||
|
||||
VcsBaseClientSettings &s = MercurialPluginPrivate::client()->settings();
|
||||
if (s != ms) {
|
||||
s = ms;
|
||||
m_control->configurationChanged();
|
||||
if (*m_settings != ms) {
|
||||
*m_settings = ms;
|
||||
m_onApply();
|
||||
}
|
||||
}
|
||||
|
||||
OptionsPage::OptionsPage(Core::IVersionControl *control, QObject *parent)
|
||||
: Core::IOptionsPage(parent)
|
||||
OptionsPage::OptionsPage(const std::function<void()> &onApply, MercurialSettings *settings)
|
||||
{
|
||||
setId(VcsBase::Constants::VCS_ID_MERCURIAL);
|
||||
setDisplayName(OptionsPageWidget::tr("Mercurial"));
|
||||
setCategory(VcsBase::Constants::VCS_SETTINGS_CATEGORY);
|
||||
setWidgetCreator([control] { return new OptionsPageWidget(control); });
|
||||
setWidgetCreator([onApply, settings] { return new OptionsPageWidget(onApply, settings); });
|
||||
}
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -27,15 +27,15 @@
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
namespace Core { class IVersionControl; }
|
||||
|
||||
namespace Mercurial {
|
||||
namespace Internal {
|
||||
|
||||
class MercurialSettings;
|
||||
|
||||
class OptionsPage final : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
OptionsPage(Core::IVersionControl *control, QObject *parent);
|
||||
OptionsPage(const std::function<void()> &onApply, MercurialSettings *settings);
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "authenticationdialog.h"
|
||||
#include "mercurialplugin.h"
|
||||
#include "srcdestdialog.h"
|
||||
#include "ui_srcdestdialog.h"
|
||||
|
||||
@@ -36,10 +35,11 @@ using namespace VcsBase;
|
||||
namespace Mercurial {
|
||||
namespace Internal {
|
||||
|
||||
SrcDestDialog::SrcDestDialog(Direction dir, QWidget *parent) :
|
||||
SrcDestDialog::SrcDestDialog(const VcsBasePluginState &state, Direction dir, QWidget *parent) :
|
||||
QDialog(parent),
|
||||
m_ui(new Ui::SrcDestDialog),
|
||||
m_direction(dir)
|
||||
m_direction(dir),
|
||||
m_state(state)
|
||||
{
|
||||
m_ui->setupUi(this);
|
||||
m_ui->localPathChooser->setExpectedKind(Utils::PathChooser::ExistingDirectory);
|
||||
@@ -97,10 +97,9 @@ QString SrcDestDialog::workingDir() const
|
||||
|
||||
QUrl SrcDestDialog::getRepoUrl() const
|
||||
{
|
||||
const VcsBasePluginState state = MercurialPluginPrivate::instance()->currentState();
|
||||
// Repo to use: Default to the project repo, but use the current
|
||||
const QString projectLoc = state.currentProjectPath();
|
||||
const QString fileLoc = state.currentFileTopLevel();
|
||||
const QString projectLoc = m_state.currentProjectPath();
|
||||
const QString fileLoc = m_state.currentFileTopLevel();
|
||||
m_workingdir = projectLoc;
|
||||
if (!fileLoc.isEmpty())
|
||||
m_workingdir = fileLoc;
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <utils/pathchooser.h>
|
||||
#include <vcsbase/vcsbaseplugin.h>
|
||||
#include <QDialog>
|
||||
|
||||
namespace Mercurial {
|
||||
@@ -39,7 +40,7 @@ class SrcDestDialog : public QDialog
|
||||
|
||||
public:
|
||||
enum Direction { outgoing, incoming };
|
||||
explicit SrcDestDialog(Direction dir, QWidget *parent = nullptr);
|
||||
explicit SrcDestDialog(const VcsBase::VcsBasePluginState &state, Direction dir, QWidget *parent = nullptr);
|
||||
~SrcDestDialog() override;
|
||||
|
||||
void setPathChooserKind(Utils::PathChooser::Kind kind);
|
||||
@@ -53,6 +54,7 @@ private:
|
||||
Ui::SrcDestDialog *m_ui;
|
||||
Direction m_direction;
|
||||
mutable QString m_workingdir;
|
||||
VcsBase::VcsBasePluginState m_state;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
Reference in New Issue
Block a user