forked from qt-creator/qt-creator
Git: Modernize
* pragma once * member initialization * s/struct/class/ * Introduce a static GitPlugin::client() method and use it Change-Id: Ifdcac86dd16f3cdba11d564d03e9a15f00a6afdb Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -23,8 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef ANNOTATIONHIGHLIGHTER_H
|
#pragma once
|
||||||
#define ANNOTATIONHIGHLIGHTER_H
|
|
||||||
|
|
||||||
#include <vcsbase/baseannotationhighlighter.h>
|
#include <vcsbase/baseannotationhighlighter.h>
|
||||||
|
|
||||||
@@ -47,5 +46,3 @@ private:
|
|||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
#endif // ANNOTATIONHIGHLIGHTER_H
|
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef BRANCHADDDIALOG_H
|
#pragma once
|
||||||
#define BRANCHADDDIALOG_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
@@ -40,7 +39,7 @@ class BranchAddDialog : public QDialog
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
BranchAddDialog(const QStringList &localBranches, bool addBranch, QWidget *parent);
|
BranchAddDialog(const QStringList &localBranches, bool addBranch, QWidget *parent);
|
||||||
~BranchAddDialog();
|
~BranchAddDialog() override;
|
||||||
|
|
||||||
void setBranchName(const QString &);
|
void setBranchName(const QString &);
|
||||||
QString branchName() const;
|
QString branchName() const;
|
||||||
@@ -57,5 +56,3 @@ private:
|
|||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
#endif // BRANCHADDDIALOG_H
|
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef BRANCHCHECKOUTDIALOG_H
|
#pragma once
|
||||||
#define BRANCHCHECKOUTDIALOG_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
@@ -40,7 +39,7 @@ class BranchCheckoutDialog : public QDialog
|
|||||||
public:
|
public:
|
||||||
explicit BranchCheckoutDialog(QWidget *parent, const QString ¤tBranch,
|
explicit BranchCheckoutDialog(QWidget *parent, const QString ¤tBranch,
|
||||||
const QString &nextBranch);
|
const QString &nextBranch);
|
||||||
~BranchCheckoutDialog();
|
~BranchCheckoutDialog() override;
|
||||||
|
|
||||||
void foundNoLocalChanges();
|
void foundNoLocalChanges();
|
||||||
void foundStashForNextBranch();
|
void foundStashForNextBranch();
|
||||||
@@ -63,5 +62,3 @@ private:
|
|||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
#endif // BRANCHCHECKOUTDIALOG_H
|
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ namespace Internal {
|
|||||||
BranchDialog::BranchDialog(QWidget *parent) :
|
BranchDialog::BranchDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
m_ui(new Ui::BranchDialog),
|
m_ui(new Ui::BranchDialog),
|
||||||
m_model(new BranchModel(GitPlugin::instance()->client(), this))
|
m_model(new BranchModel(GitPlugin::client(), this))
|
||||||
{
|
{
|
||||||
setModal(false);
|
setModal(false);
|
||||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
@@ -192,13 +192,13 @@ void BranchDialog::checkout()
|
|||||||
QLatin1Char(' ') + nextBranch + QLatin1String("-AutoStash ");
|
QLatin1Char(' ') + nextBranch + QLatin1String("-AutoStash ");
|
||||||
|
|
||||||
BranchCheckoutDialog branchCheckoutDialog(this, currentBranch, nextBranch);
|
BranchCheckoutDialog branchCheckoutDialog(this, currentBranch, nextBranch);
|
||||||
GitClient *gitClient = GitPlugin::instance()->client();
|
GitClient *client = GitPlugin::client();
|
||||||
|
|
||||||
if (gitClient->gitStatus(m_repository, StatusMode(NoUntracked | NoSubmodules)) != GitClient::StatusChanged)
|
if (client->gitStatus(m_repository, StatusMode(NoUntracked | NoSubmodules)) != GitClient::StatusChanged)
|
||||||
branchCheckoutDialog.foundNoLocalChanges();
|
branchCheckoutDialog.foundNoLocalChanges();
|
||||||
|
|
||||||
QList<Stash> stashes;
|
QList<Stash> stashes;
|
||||||
gitClient->synchronousStashList(m_repository, &stashes);
|
client->synchronousStashList(m_repository, &stashes);
|
||||||
foreach (const Stash &stash, stashes) {
|
foreach (const Stash &stash, stashes) {
|
||||||
if (stash.message.startsWith(popMessageStart)) {
|
if (stash.message.startsWith(popMessageStart)) {
|
||||||
branchCheckoutDialog.foundStashForNextBranch();
|
branchCheckoutDialog.foundStashForNextBranch();
|
||||||
@@ -213,22 +213,22 @@ void BranchDialog::checkout()
|
|||||||
} else if (branchCheckoutDialog.exec() == QDialog::Accepted) {
|
} else if (branchCheckoutDialog.exec() == QDialog::Accepted) {
|
||||||
|
|
||||||
if (branchCheckoutDialog.makeStashOfCurrentBranch()) {
|
if (branchCheckoutDialog.makeStashOfCurrentBranch()) {
|
||||||
if (gitClient->synchronousStash(m_repository,
|
if (client->synchronousStash(m_repository,
|
||||||
currentBranch + QLatin1String("-AutoStash")).isEmpty()) {
|
currentBranch + QLatin1String("-AutoStash")).isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (branchCheckoutDialog.moveLocalChangesToNextBranch()) {
|
} else if (branchCheckoutDialog.moveLocalChangesToNextBranch()) {
|
||||||
if (!gitClient->beginStashScope(m_repository, QLatin1String("Checkout"), NoPrompt))
|
if (!client->beginStashScope(m_repository, QLatin1String("Checkout"), NoPrompt))
|
||||||
return;
|
return;
|
||||||
} else if (branchCheckoutDialog.discardLocalChanges()) {
|
} else if (branchCheckoutDialog.discardLocalChanges()) {
|
||||||
if (!gitClient->synchronousReset(m_repository))
|
if (!client->synchronousReset(m_repository))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_model->checkoutBranch(idx);
|
m_model->checkoutBranch(idx);
|
||||||
|
|
||||||
QString stashName;
|
QString stashName;
|
||||||
gitClient->synchronousStashList(m_repository, &stashes);
|
client->synchronousStashList(m_repository, &stashes);
|
||||||
foreach (const Stash &stash, stashes) {
|
foreach (const Stash &stash, stashes) {
|
||||||
if (stash.message.startsWith(popMessageStart)) {
|
if (stash.message.startsWith(popMessageStart)) {
|
||||||
stashName = stash.name;
|
stashName = stash.name;
|
||||||
@@ -237,9 +237,9 @@ void BranchDialog::checkout()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (branchCheckoutDialog.moveLocalChangesToNextBranch())
|
if (branchCheckoutDialog.moveLocalChangesToNextBranch())
|
||||||
gitClient->endStashScope(m_repository);
|
client->endStashScope(m_repository);
|
||||||
else if (branchCheckoutDialog.popStashOfNextBranch())
|
else if (branchCheckoutDialog.popStashOfNextBranch())
|
||||||
gitClient->synchronousStashRestore(m_repository, stashName, true);
|
client->synchronousStashRestore(m_repository, stashName, true);
|
||||||
}
|
}
|
||||||
enableButtons();
|
enableButtons();
|
||||||
}
|
}
|
||||||
@@ -311,7 +311,7 @@ void BranchDialog::diff()
|
|||||||
QString fullName = m_model->fullName(selectedIndex(), true);
|
QString fullName = m_model->fullName(selectedIndex(), true);
|
||||||
if (fullName.isEmpty())
|
if (fullName.isEmpty())
|
||||||
return;
|
return;
|
||||||
GitPlugin::instance()->client()->diffBranch(m_repository, fullName);
|
GitPlugin::client()->diffBranch(m_repository, fullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BranchDialog::log()
|
void BranchDialog::log()
|
||||||
@@ -319,7 +319,7 @@ void BranchDialog::log()
|
|||||||
QString branchName = m_model->fullName(selectedIndex(), true);
|
QString branchName = m_model->fullName(selectedIndex(), true);
|
||||||
if (branchName.isEmpty())
|
if (branchName.isEmpty())
|
||||||
return;
|
return;
|
||||||
GitPlugin::instance()->client()->log(m_repository, QString(), false, QStringList(branchName));
|
GitPlugin::client()->log(m_repository, QString(), false, QStringList(branchName));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BranchDialog::reset()
|
void BranchDialog::reset()
|
||||||
@@ -332,7 +332,7 @@ void BranchDialog::reset()
|
|||||||
if (QMessageBox::question(this, tr("Git Reset"), tr("Hard reset branch \"%1\" to \"%2\"?")
|
if (QMessageBox::question(this, tr("Git Reset"), tr("Hard reset branch \"%1\" to \"%2\"?")
|
||||||
.arg(currentName).arg(branchName),
|
.arg(currentName).arg(branchName),
|
||||||
QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) {
|
QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) {
|
||||||
GitPlugin::instance()->client()->reset(m_repository, QLatin1String("--hard"), branchName);
|
GitPlugin::client()->reset(m_repository, QLatin1String("--hard"), branchName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,7 +344,7 @@ void BranchDialog::merge()
|
|||||||
QTC_CHECK(idx != m_model->currentBranch()); // otherwise the button would not be enabled!
|
QTC_CHECK(idx != m_model->currentBranch()); // otherwise the button would not be enabled!
|
||||||
|
|
||||||
const QString branch = m_model->fullName(idx, true);
|
const QString branch = m_model->fullName(idx, true);
|
||||||
GitClient *client = GitPlugin::instance()->client();
|
GitClient *client = GitPlugin::client();
|
||||||
bool allowFastForward = true;
|
bool allowFastForward = true;
|
||||||
if (client->isFastForwardMerge(m_repository, branch)) {
|
if (client->isFastForwardMerge(m_repository, branch)) {
|
||||||
QMenu popup;
|
QMenu popup;
|
||||||
@@ -367,7 +367,7 @@ void BranchDialog::rebase()
|
|||||||
QTC_CHECK(idx != m_model->currentBranch()); // otherwise the button would not be enabled!
|
QTC_CHECK(idx != m_model->currentBranch()); // otherwise the button would not be enabled!
|
||||||
|
|
||||||
const QString baseBranch = m_model->fullName(idx, true);
|
const QString baseBranch = m_model->fullName(idx, true);
|
||||||
GitClient *client = GitPlugin::instance()->client();
|
GitClient *client = GitPlugin::client();
|
||||||
if (client->beginStashScope(m_repository, QLatin1String("rebase")))
|
if (client->beginStashScope(m_repository, QLatin1String("rebase")))
|
||||||
client->rebase(m_repository, baseBranch);
|
client->rebase(m_repository, baseBranch);
|
||||||
}
|
}
|
||||||
@@ -380,7 +380,7 @@ void BranchDialog::cherryPick()
|
|||||||
QTC_CHECK(idx != m_model->currentBranch()); // otherwise the button would not be enabled!
|
QTC_CHECK(idx != m_model->currentBranch()); // otherwise the button would not be enabled!
|
||||||
|
|
||||||
const QString branch = m_model->fullName(idx, true);
|
const QString branch = m_model->fullName(idx, true);
|
||||||
GitPlugin::instance()->client()->synchronousCherryPick(m_repository, branch);
|
GitPlugin::client()->synchronousCherryPick(m_repository, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void BranchDialog::setRemoteTracking()
|
void BranchDialog::setRemoteTracking()
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef BRANCHDIALOG_H
|
#pragma once
|
||||||
#define BRANCHDIALOG_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
@@ -51,7 +50,7 @@ class BranchDialog : public QDialog
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BranchDialog(QWidget *parent = 0);
|
explicit BranchDialog(QWidget *parent = 0);
|
||||||
~BranchDialog();
|
~BranchDialog() override;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void refresh(const QString &repository, bool force);
|
void refresh(const QString &repository, bool force);
|
||||||
@@ -81,5 +80,3 @@ private:
|
|||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
#endif // BRANCHDIALOG_H
|
|
||||||
|
|||||||
@@ -193,8 +193,7 @@ public:
|
|||||||
BranchModel::BranchModel(GitClient *client, QObject *parent) :
|
BranchModel::BranchModel(GitClient *client, QObject *parent) :
|
||||||
QAbstractItemModel(parent),
|
QAbstractItemModel(parent),
|
||||||
m_client(client),
|
m_client(client),
|
||||||
m_rootNode(new BranchNode),
|
m_rootNode(new BranchNode)
|
||||||
m_currentBranch(0)
|
|
||||||
{
|
{
|
||||||
QTC_CHECK(m_client);
|
QTC_CHECK(m_client);
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef BRANCHMODEL_H
|
#pragma once
|
||||||
#define BRANCHMODEL_H
|
|
||||||
|
|
||||||
#include <QAbstractListModel>
|
#include <QAbstractListModel>
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
@@ -44,8 +43,8 @@ class BranchModel : public QAbstractItemModel {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit BranchModel(GitClient *client, QObject *parent = 0);
|
explicit BranchModel(GitClient *client, QObject *parent = nullptr);
|
||||||
~BranchModel();
|
~BranchModel() override;
|
||||||
|
|
||||||
// QAbstractItemModel
|
// QAbstractItemModel
|
||||||
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const override;
|
||||||
@@ -93,11 +92,9 @@ private:
|
|||||||
GitClient *m_client;
|
GitClient *m_client;
|
||||||
QString m_workingDirectory;
|
QString m_workingDirectory;
|
||||||
BranchNode *m_rootNode;
|
BranchNode *m_rootNode;
|
||||||
BranchNode *m_currentBranch;
|
BranchNode *m_currentBranch = nullptr;
|
||||||
QString m_currentSha;
|
QString m_currentSha;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
#endif // BRANCHMODEL_H
|
|
||||||
|
|||||||
@@ -52,19 +52,17 @@ using namespace Utils;
|
|||||||
namespace Git {
|
namespace Git {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
ChangeSelectionDialog::ChangeSelectionDialog(const QString &workingDirectory, Core::Id id, QWidget *parent)
|
ChangeSelectionDialog::ChangeSelectionDialog(const QString &workingDirectory, Core::Id id,
|
||||||
: QDialog(parent)
|
QWidget *parent) :
|
||||||
, m_ui(new Ui::ChangeSelectionDialog)
|
QDialog(parent), m_ui(new Ui::ChangeSelectionDialog)
|
||||||
, m_process(0)
|
|
||||||
, m_command(NoCommand)
|
|
||||||
{
|
{
|
||||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
m_gitExecutable = GitPlugin::instance()->client()->vcsBinary();
|
m_gitExecutable = GitPlugin::client()->vcsBinary();
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
m_ui->workingDirectoryChooser->setExpectedKind(PathChooser::ExistingDirectory);
|
m_ui->workingDirectoryChooser->setExpectedKind(PathChooser::ExistingDirectory);
|
||||||
m_ui->workingDirectoryChooser->setPromptDialogTitle(tr("Select Git Directory"));
|
m_ui->workingDirectoryChooser->setPromptDialogTitle(tr("Select Git Directory"));
|
||||||
m_ui->workingDirectoryChooser->setPath(workingDirectory);
|
m_ui->workingDirectoryChooser->setPath(workingDirectory);
|
||||||
m_gitEnvironment = GitPlugin::instance()->client()->processEnvironment();
|
m_gitEnvironment = GitPlugin::client()->processEnvironment();
|
||||||
m_ui->changeNumberEdit->setFocus();
|
m_ui->changeNumberEdit->setFocus();
|
||||||
m_ui->changeNumberEdit->selectAll();
|
m_ui->changeNumberEdit->selectAll();
|
||||||
|
|
||||||
@@ -216,7 +214,7 @@ void ChangeSelectionDialog::recalculateCompletion()
|
|||||||
m_oldWorkingDir = workingDir;
|
m_oldWorkingDir = workingDir;
|
||||||
|
|
||||||
if (!workingDir.isEmpty()) {
|
if (!workingDir.isEmpty()) {
|
||||||
GitClient *client = GitPlugin::instance()->client();
|
GitClient *client = GitPlugin::client();
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args << QLatin1String("--format=%(refname:short)");
|
args << QLatin1String("--format=%(refname:short)");
|
||||||
QString output;
|
QString output;
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef CHANGESELECTIONDIALOG_H
|
#pragma once
|
||||||
#define CHANGESELECTIONDIALOG_H
|
|
||||||
|
|
||||||
#include <coreplugin/id.h>
|
#include <coreplugin/id.h>
|
||||||
|
|
||||||
@@ -60,7 +59,7 @@ class ChangeSelectionDialog : public QDialog
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ChangeSelectionDialog(const QString &workingDirectory, Core::Id id, QWidget *parent);
|
ChangeSelectionDialog(const QString &workingDirectory, Core::Id id, QWidget *parent);
|
||||||
~ChangeSelectionDialog();
|
~ChangeSelectionDialog() override;
|
||||||
|
|
||||||
QString change() const;
|
QString change() const;
|
||||||
|
|
||||||
@@ -83,15 +82,13 @@ private:
|
|||||||
|
|
||||||
Ui::ChangeSelectionDialog *m_ui;
|
Ui::ChangeSelectionDialog *m_ui;
|
||||||
|
|
||||||
QProcess *m_process;
|
QProcess *m_process = nullptr;
|
||||||
Utils::FileName m_gitExecutable;
|
Utils::FileName m_gitExecutable;
|
||||||
QProcessEnvironment m_gitEnvironment;
|
QProcessEnvironment m_gitEnvironment;
|
||||||
ChangeCommand m_command;
|
ChangeCommand m_command = NoCommand;
|
||||||
QStringListModel *m_changeModel;
|
QStringListModel *m_changeModel = nullptr;
|
||||||
QString m_oldWorkingDir;
|
QString m_oldWorkingDir;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
#endif // CHANGESELECTIONDIALOG_H
|
|
||||||
|
|||||||
@@ -28,7 +28,6 @@
|
|||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDebug>
|
|
||||||
|
|
||||||
namespace Git {
|
namespace Git {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
@@ -39,12 +38,6 @@ void GitSubmitEditorPanelInfo::clear()
|
|||||||
branch.clear();
|
branch.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
QDebug operator<<(QDebug d, const GitSubmitEditorPanelInfo &data)
|
|
||||||
{
|
|
||||||
d.nospace() << "Rep: " << data.repository << " branch: " << data.branch;
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GitSubmitEditorPanelData::clear()
|
void GitSubmitEditorPanelData::clear()
|
||||||
{
|
{
|
||||||
author.clear();
|
author.clear();
|
||||||
@@ -67,14 +60,6 @@ QString GitSubmitEditorPanelData::authorString() const
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDebug operator<<(QDebug d, const GitSubmitEditorPanelData &data)
|
|
||||||
{
|
|
||||||
d.nospace() << " author:" << data.author << " email: " << data.email
|
|
||||||
<< " bypass hooks: " << data.bypassHooks
|
|
||||||
<< " action after commit " << data.pushAction;
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
CommitData::CommitData(CommitType type)
|
CommitData::CommitData(CommitType type)
|
||||||
: commitType(type)
|
: commitType(type)
|
||||||
, commitEncoding(0)
|
, commitEncoding(0)
|
||||||
|
|||||||
@@ -23,39 +23,34 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef COMMITDATA_H
|
#pragma once
|
||||||
#define COMMITDATA_H
|
|
||||||
|
|
||||||
#include "gitsettings.h" // CommitType
|
#include "gitsettings.h" // CommitType
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QPair>
|
#include <QPair>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
|
||||||
class QDebug;
|
|
||||||
QT_END_NAMESPACE
|
|
||||||
|
|
||||||
namespace Git {
|
namespace Git {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
// Read-only
|
// Read-only
|
||||||
struct GitSubmitEditorPanelInfo
|
class GitSubmitEditorPanelInfo
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
void clear();
|
void clear();
|
||||||
QString repository;
|
QString repository;
|
||||||
QString branch;
|
QString branch;
|
||||||
};
|
};
|
||||||
|
|
||||||
QDebug operator<<(QDebug d, const GitSubmitEditorPanelInfo &);
|
|
||||||
|
|
||||||
enum PushAction {
|
enum PushAction {
|
||||||
NoPush,
|
NoPush,
|
||||||
NormalPush,
|
NormalPush,
|
||||||
PushToGerrit
|
PushToGerrit
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GitSubmitEditorPanelData
|
class GitSubmitEditorPanelData
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
void clear();
|
void clear();
|
||||||
// Format as "John Doe <jdoe@foobar.com>"
|
// Format as "John Doe <jdoe@foobar.com>"
|
||||||
QString authorString() const;
|
QString authorString() const;
|
||||||
@@ -66,8 +61,6 @@ struct GitSubmitEditorPanelData
|
|||||||
PushAction pushAction;
|
PushAction pushAction;
|
||||||
};
|
};
|
||||||
|
|
||||||
QDebug operator<<(QDebug d, const GitSubmitEditorPanelData &);
|
|
||||||
|
|
||||||
enum FileState {
|
enum FileState {
|
||||||
EmptyFileState = 0x00,
|
EmptyFileState = 0x00,
|
||||||
|
|
||||||
@@ -132,5 +125,3 @@ bool operator<(const CommitData::StateFilePair &a,
|
|||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
#endif // COMMITDATA_H
|
|
||||||
|
|||||||
@@ -30,17 +30,13 @@
|
|||||||
using namespace Git::Internal;
|
using namespace Git::Internal;
|
||||||
using namespace Gerrit::Internal;
|
using namespace Gerrit::Internal;
|
||||||
|
|
||||||
BranchComboBox::BranchComboBox(QWidget *parent) :
|
BranchComboBox::BranchComboBox(QWidget *parent) : QComboBox(parent)
|
||||||
QComboBox(parent),
|
{ }
|
||||||
m_detached(false)
|
|
||||||
{
|
|
||||||
m_client = GitPlugin::instance()->client();
|
|
||||||
}
|
|
||||||
|
|
||||||
void BranchComboBox::init(const QString &repository)
|
void BranchComboBox::init(const QString &repository)
|
||||||
{
|
{
|
||||||
m_repository = repository;
|
m_repository = repository;
|
||||||
QString currentBranch = m_client->synchronousCurrentLocalBranch(repository);
|
QString currentBranch = GitPlugin::client()->synchronousCurrentLocalBranch(repository);
|
||||||
if (currentBranch.isEmpty()) {
|
if (currentBranch.isEmpty()) {
|
||||||
m_detached = true;
|
m_detached = true;
|
||||||
currentBranch = QLatin1String("HEAD");
|
currentBranch = QLatin1String("HEAD");
|
||||||
@@ -50,7 +46,7 @@ void BranchComboBox::init(const QString &repository)
|
|||||||
const QString branchPrefix(QLatin1String("refs/heads/"));
|
const QString branchPrefix(QLatin1String("refs/heads/"));
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args << QLatin1String("--format=%(refname)") << branchPrefix;
|
args << QLatin1String("--format=%(refname)") << branchPrefix;
|
||||||
if (!m_client->synchronousForEachRefCmd(m_repository, args, &output))
|
if (!GitPlugin::client()->synchronousForEachRefCmd(m_repository, args, &output))
|
||||||
return;
|
return;
|
||||||
QStringList branches = output.trimmed().split(QLatin1Char('\n'));
|
QStringList branches = output.trimmed().split(QLatin1Char('\n'));
|
||||||
foreach (const QString &ref, branches) {
|
foreach (const QString &ref, branches) {
|
||||||
|
|||||||
@@ -38,13 +38,12 @@ namespace Internal {
|
|||||||
class BranchComboBox : public QComboBox
|
class BranchComboBox : public QComboBox
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BranchComboBox(QWidget *parent = 0);
|
explicit BranchComboBox(QWidget *parent = nullptr);
|
||||||
void init(const QString &repository);
|
void init(const QString &repository);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Git::Internal::GitClient *m_client;
|
|
||||||
QString m_repository;
|
QString m_repository;
|
||||||
bool m_detached;
|
bool m_detached = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -272,8 +272,7 @@ QueryContext::QueryContext(const QStringList &queries,
|
|||||||
this, &QueryContext::processError);
|
this, &QueryContext::processError);
|
||||||
connect(&m_watcher, &QFutureWatcherBase::canceled, this, &QueryContext::terminate);
|
connect(&m_watcher, &QFutureWatcherBase::canceled, this, &QueryContext::terminate);
|
||||||
m_watcher.setFuture(m_progress.future());
|
m_watcher.setFuture(m_progress.future());
|
||||||
m_process.setProcessEnvironment(Git::Internal::GitPlugin::instance()->
|
m_process.setProcessEnvironment(Git::Internal::GitPlugin::client()->processEnvironment());
|
||||||
client()->processEnvironment());
|
|
||||||
m_progress.setProgressRange(0, m_queries.size());
|
m_progress.setProgressRange(0, m_queries.size());
|
||||||
|
|
||||||
// Determine binary and common command line arguments.
|
// Determine binary and common command line arguments.
|
||||||
|
|||||||
@@ -84,11 +84,6 @@ enum FetchMode
|
|||||||
FetchCheckout
|
FetchCheckout
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline GitClient *gitClient()
|
|
||||||
{
|
|
||||||
return GitPlugin::instance()->client();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* FetchContext: Retrieves the patch and displays
|
/* FetchContext: Retrieves the patch and displays
|
||||||
* or applies it as desired. Does deleteLater() once it is done. */
|
* or applies it as desired. Does deleteLater() once it is done. */
|
||||||
|
|
||||||
@@ -158,7 +153,7 @@ FetchContext::FetchContext(const QSharedPointer<GerritChange> &change,
|
|||||||
connect(&m_watcher, &QFutureWatcher<void>::canceled, this, &FetchContext::terminate);
|
connect(&m_watcher, &QFutureWatcher<void>::canceled, this, &FetchContext::terminate);
|
||||||
m_watcher.setFuture(m_progress.future());
|
m_watcher.setFuture(m_progress.future());
|
||||||
m_process.setWorkingDirectory(repository);
|
m_process.setWorkingDirectory(repository);
|
||||||
m_process.setProcessEnvironment(gitClient()->processEnvironment());
|
m_process.setProcessEnvironment(GitPlugin::client()->processEnvironment());
|
||||||
m_process.closeWriteChannel();
|
m_process.closeWriteChannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,7 +245,7 @@ void FetchContext::show()
|
|||||||
{
|
{
|
||||||
const QString title = QString::number(m_change->number) + QLatin1Char('/')
|
const QString title = QString::number(m_change->number) + QLatin1Char('/')
|
||||||
+ QString::number(m_change->currentPatchSet.patchSetNumber);
|
+ QString::number(m_change->currentPatchSet.patchSetNumber);
|
||||||
gitClient()->show(m_repository, QLatin1String("FETCH_HEAD"), title);
|
GitPlugin::client()->show(m_repository, QLatin1String("FETCH_HEAD"), title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FetchContext::cherryPick()
|
void FetchContext::cherryPick()
|
||||||
@@ -258,12 +253,12 @@ void FetchContext::cherryPick()
|
|||||||
// Point user to errors.
|
// Point user to errors.
|
||||||
VcsBase::VcsOutputWindow::instance()->popup(IOutputPane::ModeSwitch
|
VcsBase::VcsOutputWindow::instance()->popup(IOutputPane::ModeSwitch
|
||||||
| IOutputPane::WithFocus);
|
| IOutputPane::WithFocus);
|
||||||
gitClient()->synchronousCherryPick(m_repository, QLatin1String("FETCH_HEAD"));
|
GitPlugin::client()->synchronousCherryPick(m_repository, QLatin1String("FETCH_HEAD"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FetchContext::checkout()
|
void FetchContext::checkout()
|
||||||
{
|
{
|
||||||
gitClient()->stashAndCheckout(m_repository, QLatin1String("FETCH_HEAD"));
|
GitPlugin::client()->stashAndCheckout(m_repository, QLatin1String("FETCH_HEAD"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FetchContext::terminate()
|
void FetchContext::terminate()
|
||||||
@@ -355,7 +350,7 @@ void GerritPlugin::push(const QString &topLevel)
|
|||||||
|
|
||||||
args << target;
|
args << target;
|
||||||
|
|
||||||
gitClient()->push(topLevel, args);
|
GitPlugin::client()->push(topLevel, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open or raise the Gerrit dialog window.
|
// Open or raise the Gerrit dialog window.
|
||||||
@@ -393,13 +388,13 @@ void GerritPlugin::push()
|
|||||||
|
|
||||||
Utils::FileName GerritPlugin::gitBinDirectory()
|
Utils::FileName GerritPlugin::gitBinDirectory()
|
||||||
{
|
{
|
||||||
return gitClient()->gitBinDirectory();
|
return GitPlugin::client()->gitBinDirectory();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find the branch of a repository.
|
// Find the branch of a repository.
|
||||||
QString GerritPlugin::branch(const QString &repository)
|
QString GerritPlugin::branch(const QString &repository)
|
||||||
{
|
{
|
||||||
return gitClient()->synchronousCurrentLocalBranch(repository);
|
return GitPlugin::client()->synchronousCurrentLocalBranch(repository);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GerritPlugin::fetchDisplay(const QSharedPointer<GerritChange> &change)
|
void GerritPlugin::fetchDisplay(const QSharedPointer<GerritChange> &change)
|
||||||
@@ -420,14 +415,12 @@ void GerritPlugin::fetchCheckout(const QSharedPointer<GerritChange> &change)
|
|||||||
void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
|
void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
|
||||||
{
|
{
|
||||||
// Locate git.
|
// Locate git.
|
||||||
const Utils::FileName git = gitClient()->vcsBinary();
|
const Utils::FileName git = GitPlugin::client()->vcsBinary();
|
||||||
if (git.isEmpty()) {
|
if (git.isEmpty()) {
|
||||||
VcsBase::VcsOutputWindow::appendError(tr("Git is not available."));
|
VcsBase::VcsOutputWindow::appendError(tr("Git is not available."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GitClient *client = gitClient();
|
|
||||||
|
|
||||||
QString repository;
|
QString repository;
|
||||||
bool verifiedRepository = false;
|
bool verifiedRepository = false;
|
||||||
if (!m_dialog.isNull() && !m_parameters.isNull() && QFile::exists(m_dialog->repositoryPath()))
|
if (!m_dialog.isNull() && !m_parameters.isNull() && QFile::exists(m_dialog->repositoryPath()))
|
||||||
@@ -435,7 +428,7 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
|
|||||||
|
|
||||||
if (!repository.isEmpty()) {
|
if (!repository.isEmpty()) {
|
||||||
// Check if remote from a working dir is the same as remote from patch
|
// Check if remote from a working dir is the same as remote from patch
|
||||||
QMap<QString, QString> remotesList = client->synchronousRemotesList(repository);
|
QMap<QString, QString> remotesList = GitPlugin::client()->synchronousRemotesList(repository);
|
||||||
if (!remotesList.isEmpty()) {
|
if (!remotesList.isEmpty()) {
|
||||||
QStringList remotes = remotesList.values();
|
QStringList remotes = remotesList.values();
|
||||||
foreach (QString remote, remotes) {
|
foreach (QString remote, remotes) {
|
||||||
@@ -448,7 +441,7 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!verifiedRepository) {
|
if (!verifiedRepository) {
|
||||||
SubmoduleDataMap submodules = client->submoduleList(repository);
|
SubmoduleDataMap submodules = GitPlugin::client()->submoduleList(repository);
|
||||||
foreach (const SubmoduleData &submoduleData, submodules) {
|
foreach (const SubmoduleData &submoduleData, submodules) {
|
||||||
QString remote = submoduleData.url;
|
QString remote = submoduleData.url;
|
||||||
if (remote.endsWith(QLatin1String(".git")))
|
if (remote.endsWith(QLatin1String(".git")))
|
||||||
|
|||||||
@@ -65,14 +65,14 @@ QString GerritPushDialog::determineRemoteBranch(const QString &localBranch)
|
|||||||
args << QLatin1String("-r") << QLatin1String("--contains")
|
args << QLatin1String("-r") << QLatin1String("--contains")
|
||||||
<< earliestCommit + QLatin1Char('^');
|
<< earliestCommit + QLatin1Char('^');
|
||||||
|
|
||||||
if (!m_client->synchronousBranchCmd(m_workingDir, args, &output, &error))
|
if (!GitPlugin::client()->synchronousBranchCmd(m_workingDir, args, &output, &error))
|
||||||
return QString();
|
return QString();
|
||||||
const QString head = QLatin1String("/HEAD");
|
const QString head = QLatin1String("/HEAD");
|
||||||
QStringList refs = output.split(QLatin1Char('\n'));
|
QStringList refs = output.split(QLatin1Char('\n'));
|
||||||
|
|
||||||
QString remoteTrackingBranch;
|
QString remoteTrackingBranch;
|
||||||
if (localBranch != QLatin1String("HEAD"))
|
if (localBranch != QLatin1String("HEAD"))
|
||||||
remoteTrackingBranch = m_client->synchronousTrackingBranch(m_workingDir, localBranch);
|
remoteTrackingBranch = GitPlugin::client()->synchronousTrackingBranch(m_workingDir, localBranch);
|
||||||
|
|
||||||
QString remoteBranch;
|
QString remoteBranch;
|
||||||
foreach (const QString &reference, refs) {
|
foreach (const QString &reference, refs) {
|
||||||
@@ -99,7 +99,7 @@ void GerritPushDialog::initRemoteBranches()
|
|||||||
QString remotesPrefix(QLatin1String("refs/remotes/"));
|
QString remotesPrefix(QLatin1String("refs/remotes/"));
|
||||||
args << QLatin1String("--format=%(refname)\t%(committerdate:raw)")
|
args << QLatin1String("--format=%(refname)\t%(committerdate:raw)")
|
||||||
<< remotesPrefix;
|
<< remotesPrefix;
|
||||||
if (!m_client->synchronousForEachRefCmd(m_workingDir, args, &output))
|
if (!GitPlugin::client()->synchronousForEachRefCmd(m_workingDir, args, &output))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const QStringList refs = output.split(QLatin1String("\n"));
|
const QStringList refs = output.split(QLatin1String("\n"));
|
||||||
@@ -113,7 +113,7 @@ void GerritPushDialog::initRemoteBranches()
|
|||||||
BranchDate bd(ref.mid(refBranchIndex + 1), QDateTime::fromTime_t(timeT).date());
|
BranchDate bd(ref.mid(refBranchIndex + 1), QDateTime::fromTime_t(timeT).date());
|
||||||
m_remoteBranches.insertMulti(ref.left(refBranchIndex), bd);
|
m_remoteBranches.insertMulti(ref.left(refBranchIndex), bd);
|
||||||
}
|
}
|
||||||
QStringList remotes = m_client->synchronousRemotesList(m_workingDir).keys();
|
QStringList remotes = GitPlugin::client()->synchronousRemotesList(m_workingDir).keys();
|
||||||
remotes.removeDuplicates();
|
remotes.removeDuplicates();
|
||||||
{
|
{
|
||||||
const QString origin = QLatin1String("origin");
|
const QString origin = QLatin1String("origin");
|
||||||
@@ -130,10 +130,8 @@ void GerritPushDialog::initRemoteBranches()
|
|||||||
GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &reviewerList, QWidget *parent) :
|
GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &reviewerList, QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
m_workingDir(workingDir),
|
m_workingDir(workingDir),
|
||||||
m_ui(new Ui::GerritPushDialog),
|
m_ui(new Ui::GerritPushDialog)
|
||||||
m_isValid(false)
|
|
||||||
{
|
{
|
||||||
m_client = GitPlugin::instance()->client();
|
|
||||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
m_ui->repositoryLabel->setText(QDir::toNativeSeparators(workingDir));
|
m_ui->repositoryLabel->setText(QDir::toNativeSeparators(workingDir));
|
||||||
@@ -189,7 +187,7 @@ QString GerritPushDialog::calculateChangeRange(const QString &branch)
|
|||||||
QString number;
|
QString number;
|
||||||
QString error;
|
QString error;
|
||||||
|
|
||||||
m_client->synchronousRevListCmd(m_workingDir, args, &number, &error);
|
GitPlugin::client()->synchronousRevListCmd(m_workingDir, args, &number, &error);
|
||||||
|
|
||||||
number.chop(1);
|
number.chop(1);
|
||||||
return number;
|
return number;
|
||||||
@@ -228,7 +226,7 @@ void GerritPushDialog::setRemoteBranches(bool includeOld)
|
|||||||
|
|
||||||
const QString remoteName = selectedRemoteName();
|
const QString remoteName = selectedRemoteName();
|
||||||
if (!m_remoteBranches.contains(remoteName)) {
|
if (!m_remoteBranches.contains(remoteName)) {
|
||||||
foreach (const QString &branch, m_client->synchronousRepositoryBranches(remoteName, m_workingDir))
|
foreach (const QString &branch, GitPlugin::client()->synchronousRepositoryBranches(remoteName, m_workingDir))
|
||||||
m_remoteBranches.insertMulti(remoteName, qMakePair(branch, QDate()));
|
m_remoteBranches.insertMulti(remoteName, qMakePair(branch, QDate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,8 +70,7 @@ private:
|
|||||||
QString m_suggestedRemoteBranch;
|
QString m_suggestedRemoteBranch;
|
||||||
Ui::GerritPushDialog *m_ui;
|
Ui::GerritPushDialog *m_ui;
|
||||||
RemoteBranchesMap m_remoteBranches;
|
RemoteBranchesMap m_remoteBranches;
|
||||||
bool m_isValid;
|
bool m_isValid = false;
|
||||||
Git::Internal::GitClient *m_client;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,6 @@ private:
|
|||||||
protected:
|
protected:
|
||||||
void processDiff(const QString &output, const QString &startupFile = QString());
|
void processDiff(const QString &output, const QString &startupFile = QString());
|
||||||
QStringList addConfigurationArguments(const QStringList &args) const;
|
QStringList addConfigurationArguments(const QStringList &args) const;
|
||||||
GitClient *gitClient() const;
|
|
||||||
QStringList addHeadWhenCommandInProgress() const;
|
QStringList addHeadWhenCommandInProgress() const;
|
||||||
|
|
||||||
const QString m_directory;
|
const QString m_directory;
|
||||||
@@ -151,7 +150,7 @@ void BaseController::runCommand(const QList<QStringList> &args, QTextCodec *code
|
|||||||
m_command->cancel();
|
m_command->cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_command = new VcsCommand(m_directory, gitClient()->processEnvironment());
|
m_command = new VcsCommand(m_directory, GitPlugin::client()->processEnvironment());
|
||||||
m_command->setCodec(codec ? codec : EditorManager::defaultTextCodec());
|
m_command->setCodec(codec ? codec : EditorManager::defaultTextCodec());
|
||||||
connect(m_command.data(), &VcsCommand::stdOutText, this, &BaseController::processOutput);
|
connect(m_command.data(), &VcsCommand::stdOutText, this, &BaseController::processOutput);
|
||||||
connect(m_command.data(), &VcsCommand::finished, this, &BaseController::reloadFinished);
|
connect(m_command.data(), &VcsCommand::finished, this, &BaseController::reloadFinished);
|
||||||
@@ -160,7 +159,7 @@ void BaseController::runCommand(const QList<QStringList> &args, QTextCodec *code
|
|||||||
foreach (const QStringList &arg, args) {
|
foreach (const QStringList &arg, args) {
|
||||||
QTC_ASSERT(!arg.isEmpty(), continue);
|
QTC_ASSERT(!arg.isEmpty(), continue);
|
||||||
|
|
||||||
m_command->addJob(gitClient()->vcsBinary(), arg, gitClient()->vcsTimeoutS());
|
m_command->addJob(GitPlugin::client()->vcsBinary(), arg, GitPlugin::client()->vcsTimeoutS());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_command->execute();
|
m_command->execute();
|
||||||
@@ -198,18 +197,13 @@ void BaseController::processOutput(const QString &output)
|
|||||||
processDiff(output);
|
processDiff(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
GitClient *BaseController::gitClient() const
|
|
||||||
{
|
|
||||||
return GitPlugin::instance()->client();
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList BaseController::addHeadWhenCommandInProgress() const
|
QStringList BaseController::addHeadWhenCommandInProgress() const
|
||||||
{
|
{
|
||||||
QStringList args;
|
QStringList args;
|
||||||
// This is workaround for lack of support for merge commits and resolving conflicts,
|
// This is workaround for lack of support for merge commits and resolving conflicts,
|
||||||
// we compare the current state of working tree to the HEAD of current branch
|
// we compare the current state of working tree to the HEAD of current branch
|
||||||
// instead of showing unsupported combined diff format.
|
// instead of showing unsupported combined diff format.
|
||||||
GitClient::CommandInProgress commandInProgress = gitClient()->checkCommandInProgress(m_directory);
|
GitClient::CommandInProgress commandInProgress = GitPlugin::client()->checkCommandInProgress(m_directory);
|
||||||
if (commandInProgress != GitClient::NoCommand)
|
if (commandInProgress != GitClient::NoCommand)
|
||||||
args << QLatin1String(HEAD);
|
args << QLatin1String(HEAD);
|
||||||
return args;
|
return args;
|
||||||
@@ -370,14 +364,14 @@ void ShowController::reload()
|
|||||||
args << QLatin1String("show") << QLatin1String("-s") << QLatin1String(noColorOption)
|
args << QLatin1String("show") << QLatin1String("-s") << QLatin1String(noColorOption)
|
||||||
<< QLatin1String(decorateOption) << QLatin1String(showFormatC) << m_id;
|
<< QLatin1String(decorateOption) << QLatin1String(showFormatC) << m_id;
|
||||||
m_state = GettingDescription;
|
m_state = GettingDescription;
|
||||||
runCommand(QList<QStringList>() << args, gitClient()->encoding(m_directory, "i18n.commitEncoding"));
|
runCommand(QList<QStringList>() << args, GitPlugin::client()->encoding(m_directory, "i18n.commitEncoding"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShowController::processOutput(const QString &output)
|
void ShowController::processOutput(const QString &output)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_state != Idle, return);
|
QTC_ASSERT(m_state != Idle, return);
|
||||||
if (m_state == GettingDescription)
|
if (m_state == GettingDescription)
|
||||||
setDescription(gitClient()->extendedShowDescription(m_directory, output));
|
setDescription(GitPlugin::client()->extendedShowDescription(m_directory, output));
|
||||||
else if (m_state == GettingDiff)
|
else if (m_state == GettingDiff)
|
||||||
processDiff(output, VcsBasePlugin::source(document()));
|
processDiff(output, VcsBasePlugin::source(document()));
|
||||||
}
|
}
|
||||||
@@ -3232,12 +3226,6 @@ unsigned GitClient::synchronousGitVersion(QString *errorMessage) const
|
|||||||
return version(majorV, minorV, patchV);
|
return version(majorV, minorV, patchV);
|
||||||
}
|
}
|
||||||
|
|
||||||
GitClient::StashInfo::StashInfo() :
|
|
||||||
m_client(GitPlugin::instance()->client()),
|
|
||||||
m_pushAction(NoPush)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GitClient::StashInfo::init(const QString &workingDirectory, const QString &command,
|
bool GitClient::StashInfo::init(const QString &workingDirectory, const QString &command,
|
||||||
StashFlag flag, PushAction pushAction)
|
StashFlag flag, PushAction pushAction)
|
||||||
{
|
{
|
||||||
@@ -3246,8 +3234,8 @@ bool GitClient::StashInfo::init(const QString &workingDirectory, const QString &
|
|||||||
m_pushAction = pushAction;
|
m_pushAction = pushAction;
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
QString statusOutput;
|
QString statusOutput;
|
||||||
switch (m_client->gitStatus(m_workingDir, StatusMode(NoUntracked | NoSubmodules),
|
switch (GitPlugin::client()->gitStatus(m_workingDir, StatusMode(NoUntracked | NoSubmodules),
|
||||||
&statusOutput, &errorMessage)) {
|
&statusOutput, &errorMessage)) {
|
||||||
case GitClient::StatusChanged:
|
case GitClient::StatusChanged:
|
||||||
if (m_flags & NoPrompt)
|
if (m_flags & NoPrompt)
|
||||||
executeStash(command, &errorMessage);
|
executeStash(command, &errorMessage);
|
||||||
@@ -3300,14 +3288,14 @@ void GitClient::StashInfo::stashPrompt(const QString &command, const QString &st
|
|||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
|
|
||||||
if (msgBox.clickedButton() == discardButton) {
|
if (msgBox.clickedButton() == discardButton) {
|
||||||
m_stashResult = m_client->synchronousReset(m_workingDir, QStringList(), errorMessage) ?
|
m_stashResult = GitPlugin::client()->synchronousReset(m_workingDir, QStringList(), errorMessage) ?
|
||||||
StashUnchanged : StashFailed;
|
StashUnchanged : StashFailed;
|
||||||
} else if (msgBox.clickedButton() == ignoreButton) { // At your own risk, so.
|
} else if (msgBox.clickedButton() == ignoreButton) { // At your own risk, so.
|
||||||
m_stashResult = NotStashed;
|
m_stashResult = NotStashed;
|
||||||
} else if (msgBox.clickedButton() == cancelButton) {
|
} else if (msgBox.clickedButton() == cancelButton) {
|
||||||
m_stashResult = StashCanceled;
|
m_stashResult = StashCanceled;
|
||||||
} else if (msgBox.clickedButton() == stashButton) {
|
} else if (msgBox.clickedButton() == stashButton) {
|
||||||
const bool result = m_client->executeSynchronousStash(
|
const bool result = GitPlugin::client()->executeSynchronousStash(
|
||||||
m_workingDir, creatorStashMessage(command), false, errorMessage);
|
m_workingDir, creatorStashMessage(command), false, errorMessage);
|
||||||
m_stashResult = result ? StashUnchanged : StashFailed;
|
m_stashResult = result ? StashUnchanged : StashFailed;
|
||||||
} else if (msgBox.clickedButton() == stashAndPopButton) {
|
} else if (msgBox.clickedButton() == stashAndPopButton) {
|
||||||
@@ -3318,7 +3306,7 @@ void GitClient::StashInfo::stashPrompt(const QString &command, const QString &st
|
|||||||
void GitClient::StashInfo::executeStash(const QString &command, QString *errorMessage)
|
void GitClient::StashInfo::executeStash(const QString &command, QString *errorMessage)
|
||||||
{
|
{
|
||||||
m_message = creatorStashMessage(command);
|
m_message = creatorStashMessage(command);
|
||||||
if (!m_client->executeSynchronousStash(m_workingDir, m_message, false, errorMessage))
|
if (!GitPlugin::client()->executeSynchronousStash(m_workingDir, m_message, false, errorMessage))
|
||||||
m_stashResult = StashFailed;
|
m_stashResult = StashFailed;
|
||||||
else
|
else
|
||||||
m_stashResult = Stashed;
|
m_stashResult = Stashed;
|
||||||
@@ -3341,12 +3329,12 @@ void GitClient::StashInfo::end()
|
|||||||
{
|
{
|
||||||
if (m_stashResult == Stashed) {
|
if (m_stashResult == Stashed) {
|
||||||
QString stashName;
|
QString stashName;
|
||||||
if (m_client->stashNameFromMessage(m_workingDir, m_message, &stashName))
|
if (GitPlugin::client()->stashNameFromMessage(m_workingDir, m_message, &stashName))
|
||||||
m_client->stashPop(m_workingDir, stashName);
|
GitPlugin::client()->stashPop(m_workingDir, stashName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_pushAction == NormalPush)
|
if (m_pushAction == NormalPush)
|
||||||
m_client->push(m_workingDir);
|
GitPlugin::client()->push(m_workingDir);
|
||||||
else if (m_pushAction == PushToGerrit)
|
else if (m_pushAction == PushToGerrit)
|
||||||
GitPlugin::instance()->gerritPlugin()->push(m_workingDir);
|
GitPlugin::instance()->gerritPlugin()->push(m_workingDir);
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef GITCLIENT_H
|
#pragma once
|
||||||
#define GITCLIENT_H
|
|
||||||
|
|
||||||
#include "gitsettings.h"
|
#include "gitsettings.h"
|
||||||
#include "commitdata.h"
|
#include "commitdata.h"
|
||||||
@@ -71,7 +70,7 @@ namespace Git {
|
|||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class CommitData;
|
class CommitData;
|
||||||
struct GitSubmitEditorPanelData;
|
class GitSubmitEditorPanelData;
|
||||||
class Stash;
|
class Stash;
|
||||||
|
|
||||||
enum StatusMode
|
enum StatusMode
|
||||||
@@ -108,7 +107,7 @@ public:
|
|||||||
class StashInfo
|
class StashInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
StashInfo();
|
StashInfo() = default;
|
||||||
enum StashResult { StashUnchanged, StashCanceled, StashFailed,
|
enum StashResult { StashUnchanged, StashCanceled, StashFailed,
|
||||||
Stashed, NotStashed /* User did not want it */ };
|
Stashed, NotStashed /* User did not want it */ };
|
||||||
|
|
||||||
@@ -126,9 +125,8 @@ public:
|
|||||||
StashResult m_stashResult;
|
StashResult m_stashResult;
|
||||||
QString m_message;
|
QString m_message;
|
||||||
QString m_workingDir;
|
QString m_workingDir;
|
||||||
GitClient *m_client;
|
|
||||||
StashFlag m_flags;
|
StashFlag m_flags;
|
||||||
PushAction m_pushAction;
|
PushAction m_pushAction = NoPush;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *stashNamePrefix;
|
static const char *stashNamePrefix;
|
||||||
@@ -340,7 +338,6 @@ public:
|
|||||||
static QString msgNoChangedFiles();
|
static QString msgNoChangedFiles();
|
||||||
static QString msgNoCommits(bool includeRemote);
|
static QString msgNoCommits(bool includeRemote);
|
||||||
|
|
||||||
public slots:
|
|
||||||
void show(const QString &source, const QString &id, const QString &name = QString());
|
void show(const QString &source, const QString &id, const QString &name = QString());
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -401,5 +398,3 @@ private:
|
|||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
#endif // GITCLIENT_H
|
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef GIT_CONSTANTS_H
|
#pragma once
|
||||||
#define GIT_CONSTANTS_H
|
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
|
||||||
@@ -52,5 +51,3 @@ const char C_GITEDITORID[] = "Git Editor";
|
|||||||
|
|
||||||
} // namespace Constants
|
} // namespace Constants
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
#endif // GIT_CONSTANTS_H
|
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ static QString sanitizeBlameOutput(const QString &b)
|
|||||||
if (b.isEmpty())
|
if (b.isEmpty())
|
||||||
return b;
|
return b;
|
||||||
|
|
||||||
const bool omitDate = GitPlugin::instance()->client()->settings().boolValue(
|
const bool omitDate = GitPlugin::client()->settings().boolValue(
|
||||||
GitSettings::omitAnnotationDateKey);
|
GitSettings::omitAnnotationDateKey);
|
||||||
const QChar space(QLatin1Char(' '));
|
const QChar space(QLatin1Char(' '));
|
||||||
const int parenPos = b.indexOf(QLatin1Char(')'));
|
const int parenPos = b.indexOf(QLatin1Char(')'));
|
||||||
@@ -190,31 +190,31 @@ void GitEditorWidget::setPlainText(const QString &text)
|
|||||||
|
|
||||||
void GitEditorWidget::checkoutChange()
|
void GitEditorWidget::checkoutChange()
|
||||||
{
|
{
|
||||||
GitPlugin::instance()->client()->stashAndCheckout(
|
GitPlugin::client()->stashAndCheckout(
|
||||||
sourceWorkingDirectory(), m_currentChange);
|
sourceWorkingDirectory(), m_currentChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitEditorWidget::resetChange(const QByteArray &resetType)
|
void GitEditorWidget::resetChange(const QByteArray &resetType)
|
||||||
{
|
{
|
||||||
GitPlugin::instance()->client()->reset(
|
GitPlugin::client()->reset(
|
||||||
sourceWorkingDirectory(), QLatin1String("--" + resetType), m_currentChange);
|
sourceWorkingDirectory(), QLatin1String("--" + resetType), m_currentChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitEditorWidget::cherryPickChange()
|
void GitEditorWidget::cherryPickChange()
|
||||||
{
|
{
|
||||||
GitPlugin::instance()->client()->synchronousCherryPick(
|
GitPlugin::client()->synchronousCherryPick(
|
||||||
sourceWorkingDirectory(), m_currentChange);
|
sourceWorkingDirectory(), m_currentChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitEditorWidget::revertChange()
|
void GitEditorWidget::revertChange()
|
||||||
{
|
{
|
||||||
GitPlugin::instance()->client()->synchronousRevert(
|
GitPlugin::client()->synchronousRevert(
|
||||||
sourceWorkingDirectory(), m_currentChange);
|
sourceWorkingDirectory(), m_currentChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitEditorWidget::logChange()
|
void GitEditorWidget::logChange()
|
||||||
{
|
{
|
||||||
GitPlugin::instance()->client()->log(
|
GitPlugin::client()->log(
|
||||||
sourceWorkingDirectory(), QString(), false, QStringList(m_currentChange));
|
sourceWorkingDirectory(), QString(), false, QStringList(m_currentChange));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,12 +229,11 @@ void GitEditorWidget::applyDiffChunk(const DiffChunk& chunk, bool revert)
|
|||||||
patchFile.write(chunk.chunk);
|
patchFile.write(chunk.chunk);
|
||||||
patchFile.close();
|
patchFile.close();
|
||||||
|
|
||||||
GitClient *client = GitPlugin::instance()->client();
|
|
||||||
QStringList args = QStringList() << QLatin1String("--cached");
|
QStringList args = QStringList() << QLatin1String("--cached");
|
||||||
if (revert)
|
if (revert)
|
||||||
args << QLatin1String("--reverse");
|
args << QLatin1String("--reverse");
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
if (client->synchronousApplyPatch(baseDir, patchFile.fileName(), &errorMessage, args)) {
|
if (GitPlugin::client()->synchronousApplyPatch(baseDir, patchFile.fileName(), &errorMessage, args)) {
|
||||||
if (errorMessage.isEmpty())
|
if (errorMessage.isEmpty())
|
||||||
VcsOutputWindow::append(tr("Chunk successfully staged"));
|
VcsOutputWindow::append(tr("Chunk successfully staged"));
|
||||||
else
|
else
|
||||||
@@ -283,7 +282,7 @@ void GitEditorWidget::aboutToOpen(const QString &fileName, const QString &realFi
|
|||||||
const QString gitPath = fi.absolutePath();
|
const QString gitPath = fi.absolutePath();
|
||||||
setSource(gitPath);
|
setSource(gitPath);
|
||||||
textDocument()->setCodec(
|
textDocument()->setCodec(
|
||||||
GitPlugin::instance()->client()->encoding(gitPath, "i18n.commitEncoding"));
|
GitPlugin::client()->encoding(gitPath, "i18n.commitEncoding"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,18 +292,17 @@ QString GitEditorWidget::decorateVersion(const QString &revision) const
|
|||||||
const QString workingDirectory = fi.absolutePath();
|
const QString workingDirectory = fi.absolutePath();
|
||||||
|
|
||||||
// Format verbose, SHA1 being first token
|
// Format verbose, SHA1 being first token
|
||||||
return GitPlugin::instance()->client()->synchronousShortDescription(workingDirectory, revision);
|
return GitPlugin::client()->synchronousShortDescription(workingDirectory, revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList GitEditorWidget::annotationPreviousVersions(const QString &revision) const
|
QStringList GitEditorWidget::annotationPreviousVersions(const QString &revision) const
|
||||||
{
|
{
|
||||||
QStringList revisions;
|
QStringList revisions;
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
GitClient *client = GitPlugin::instance()->client();
|
|
||||||
const QFileInfo fi(source());
|
const QFileInfo fi(source());
|
||||||
const QString workingDirectory = fi.absolutePath();
|
const QString workingDirectory = fi.absolutePath();
|
||||||
// Get the SHA1's of the file.
|
// Get the SHA1's of the file.
|
||||||
if (!client->synchronousParentRevisions(workingDirectory, revision, &revisions, &errorMessage)) {
|
if (!GitPlugin::client()->synchronousParentRevisions(workingDirectory, revision, &revisions, &errorMessage)) {
|
||||||
VcsOutputWindow::appendSilently(errorMessage);
|
VcsOutputWindow::appendSilently(errorMessage);
|
||||||
return QStringList();
|
return QStringList();
|
||||||
}
|
}
|
||||||
@@ -313,7 +311,7 @@ QStringList GitEditorWidget::annotationPreviousVersions(const QString &revision)
|
|||||||
|
|
||||||
bool GitEditorWidget::isValidRevision(const QString &revision) const
|
bool GitEditorWidget::isValidRevision(const QString &revision) const
|
||||||
{
|
{
|
||||||
return GitPlugin::instance()->client()->isValidRevision(revision);
|
return GitPlugin::client()->isValidRevision(revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitEditorWidget::addChangeActions(QMenu *menu, const QString &change)
|
void GitEditorWidget::addChangeActions(QMenu *menu, const QString &change)
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef GITEDITOR_H
|
#pragma once
|
||||||
#define GITEDITOR_H
|
|
||||||
|
|
||||||
#include <vcsbase/vcsbaseeditor.h>
|
#include <vcsbase/vcsbaseeditor.h>
|
||||||
|
|
||||||
@@ -75,5 +74,3 @@ private:
|
|||||||
|
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|
||||||
#endif // GITEDITOR_H
|
|
||||||
|
|||||||
@@ -151,8 +151,7 @@ public:
|
|||||||
m_ref = params.ref + QLatin1Char(':');
|
m_ref = params.ref + QLatin1Char(':');
|
||||||
}
|
}
|
||||||
arguments << QLatin1String("--") << m_parameters.nameFilters;
|
arguments << QLatin1String("--") << m_parameters.nameFilters;
|
||||||
GitClient *client = GitPlugin::instance()->client();
|
QScopedPointer<VcsCommand> command(GitPlugin::client()->createCommand(m_directory));
|
||||||
QScopedPointer<VcsCommand> command(client->createCommand(m_directory));
|
|
||||||
command->addFlags(VcsCommand::SilentOutput);
|
command->addFlags(VcsCommand::SilentOutput);
|
||||||
command->setProgressiveOutput(true);
|
command->setProgressiveOutput(true);
|
||||||
QFutureWatcher<FileSearchResultList> watcher;
|
QFutureWatcher<FileSearchResultList> watcher;
|
||||||
@@ -160,7 +159,7 @@ public:
|
|||||||
connect(&watcher, &QFutureWatcher<FileSearchResultList>::canceled,
|
connect(&watcher, &QFutureWatcher<FileSearchResultList>::canceled,
|
||||||
command.data(), &VcsCommand::cancel);
|
command.data(), &VcsCommand::cancel);
|
||||||
connect(command.data(), &VcsCommand::stdOutText, this, &GitGrepRunner::read);
|
connect(command.data(), &VcsCommand::stdOutText, this, &GitGrepRunner::read);
|
||||||
SynchronousProcessResponse resp = command->runCommand(client->vcsBinary(), arguments, 0);
|
SynchronousProcessResponse resp = command->runCommand(GitPlugin::client()->vcsBinary(), arguments, 0);
|
||||||
switch (resp.result) {
|
switch (resp.result) {
|
||||||
case SynchronousProcessResponse::TerminatedAbnormally:
|
case SynchronousProcessResponse::TerminatedAbnormally:
|
||||||
case SynchronousProcessResponse::StartFailed:
|
case SynchronousProcessResponse::StartFailed:
|
||||||
@@ -292,11 +291,10 @@ IEditor *GitGrep::openEditor(const SearchResultItem &item,
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
const QString path = QDir::fromNativeSeparators(item.path.first());
|
const QString path = QDir::fromNativeSeparators(item.path.first());
|
||||||
QByteArray content;
|
QByteArray content;
|
||||||
GitClient *client = GitPlugin::instance()->client();
|
|
||||||
const QString topLevel = parameters.additionalParameters.toString();
|
const QString topLevel = parameters.additionalParameters.toString();
|
||||||
const QString relativePath = QDir(topLevel).relativeFilePath(path);
|
const QString relativePath = QDir(topLevel).relativeFilePath(path);
|
||||||
if (!client->synchronousShow(topLevel, params.ref + QLatin1String(":./") + relativePath,
|
if (!GitPlugin::client()->synchronousShow(topLevel, params.ref + QLatin1String(":./") + relativePath,
|
||||||
&content, nullptr)) {
|
&content, nullptr)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
if (content.isEmpty())
|
if (content.isEmpty())
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef GITGREP_H
|
#pragma once
|
||||||
#define GITGREP_H
|
|
||||||
|
|
||||||
#include <texteditor/basefilefind.h>
|
#include <texteditor/basefilefind.h>
|
||||||
|
|
||||||
@@ -65,5 +64,3 @@ private:
|
|||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
#endif // FINDINFILES_H
|
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef GITHIGHLIGHTERS_H
|
#pragma once
|
||||||
#define GITHIGHLIGHTERS_H
|
|
||||||
|
|
||||||
#include <texteditor/syntaxhighlighter.h>
|
#include <texteditor/syntaxhighlighter.h>
|
||||||
|
|
||||||
@@ -81,5 +80,3 @@ private:
|
|||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
#endif // GITHIGHLIGHTERS_H
|
|
||||||
|
|||||||
@@ -127,16 +127,7 @@ const VcsBaseEditorParameters editorParameters[] = {
|
|||||||
|
|
||||||
static GitPlugin *m_instance = 0;
|
static GitPlugin *m_instance = 0;
|
||||||
|
|
||||||
GitPlugin::GitPlugin() :
|
GitPlugin::GitPlugin()
|
||||||
m_commandLocator(0),
|
|
||||||
m_submitCurrentAction(0),
|
|
||||||
m_diffSelectedFilesAction(0),
|
|
||||||
m_undoAction(0),
|
|
||||||
m_redoAction(0),
|
|
||||||
m_menuAction(0),
|
|
||||||
m_applyCurrentFilePatchAction(0),
|
|
||||||
m_gitClient(0),
|
|
||||||
m_submitActionTriggered(false)
|
|
||||||
{
|
{
|
||||||
m_instance = this;
|
m_instance = this;
|
||||||
m_fileActions.reserve(10);
|
m_fileActions.reserve(10);
|
||||||
@@ -169,6 +160,11 @@ GitPlugin *GitPlugin::instance()
|
|||||||
return m_instance;
|
return m_instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GitClient *GitPlugin::client()
|
||||||
|
{
|
||||||
|
return m_instance->m_gitClient;
|
||||||
|
}
|
||||||
|
|
||||||
const VcsBaseSubmitEditorParameters submitParameters = {
|
const VcsBaseSubmitEditorParameters submitParameters = {
|
||||||
Git::Constants::SUBMIT_MIMETYPE,
|
Git::Constants::SUBMIT_MIMETYPE,
|
||||||
Git::Constants::GITSUBMITEDITOR_ID,
|
Git::Constants::GITSUBMITEDITOR_ID,
|
||||||
@@ -1353,11 +1349,6 @@ void GitPlugin::updateRepositoryBrowserAction()
|
|||||||
m_repositoryBrowserAction->setEnabled(repositoryEnabled && hasRepositoryBrowserCmd);
|
m_repositoryBrowserAction->setEnabled(repositoryEnabled && hasRepositoryBrowserCmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
GitClient *GitPlugin::client() const
|
|
||||||
{
|
|
||||||
return m_gitClient;
|
|
||||||
}
|
|
||||||
|
|
||||||
Gerrit::Internal::GerritPlugin *GitPlugin::gerritPlugin() const
|
Gerrit::Internal::GerritPlugin *GitPlugin::gerritPlugin() const
|
||||||
{
|
{
|
||||||
return m_gerritPlugin;
|
return m_gerritPlugin;
|
||||||
|
|||||||
+27
-29
@@ -23,8 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef GITPLUGIN_H
|
#pragma once
|
||||||
#define GITPLUGIN_H
|
|
||||||
|
|
||||||
#include "gitsettings.h"
|
#include "gitsettings.h"
|
||||||
|
|
||||||
@@ -51,11 +50,12 @@ class Command;
|
|||||||
class CommandLocator;
|
class CommandLocator;
|
||||||
class Context;
|
class Context;
|
||||||
class ActionContainer;
|
class ActionContainer;
|
||||||
}
|
} // namespace Core
|
||||||
namespace Utils { class ParameterAction; }
|
namespace Utils { class ParameterAction; }
|
||||||
namespace Gerrit {
|
namespace Gerrit {
|
||||||
namespace Internal { class GerritPlugin; }
|
namespace Internal { class GerritPlugin; }
|
||||||
}
|
} // namespace Gerrit
|
||||||
|
|
||||||
namespace Git {
|
namespace Git {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -79,12 +79,12 @@ public:
|
|||||||
~GitPlugin();
|
~GitPlugin();
|
||||||
|
|
||||||
static GitPlugin *instance();
|
static GitPlugin *instance();
|
||||||
|
static GitClient *client();
|
||||||
|
|
||||||
bool initialize(const QStringList &arguments, QString *errorMessage) override;
|
bool initialize(const QStringList &arguments, QString *errorMessage) override;
|
||||||
|
|
||||||
GitVersionControl *gitVersionControl() const;
|
GitVersionControl *gitVersionControl() const;
|
||||||
|
|
||||||
GitClient *client() const;
|
|
||||||
Gerrit::Internal::GerritPlugin *gerritPlugin() const;
|
Gerrit::Internal::GerritPlugin *gerritPlugin() const;
|
||||||
bool isCommitEditorOpen() const;
|
bool isCommitEditorOpen() const;
|
||||||
|
|
||||||
@@ -191,42 +191,40 @@ private:
|
|||||||
void startCommit(CommitType commitType);
|
void startCommit(CommitType commitType);
|
||||||
void updateVersionWarning();
|
void updateVersionWarning();
|
||||||
|
|
||||||
Core::CommandLocator *m_commandLocator;
|
Core::CommandLocator *m_commandLocator = nullptr;
|
||||||
|
|
||||||
QAction *m_submitCurrentAction;
|
QAction *m_submitCurrentAction = nullptr;
|
||||||
QAction *m_diffSelectedFilesAction;
|
QAction *m_diffSelectedFilesAction = nullptr;
|
||||||
QAction *m_undoAction;
|
QAction *m_undoAction = nullptr;
|
||||||
QAction *m_redoAction;
|
QAction *m_redoAction = nullptr;
|
||||||
QAction *m_menuAction;
|
QAction *m_menuAction = nullptr;
|
||||||
QAction *m_repositoryBrowserAction;
|
QAction *m_repositoryBrowserAction = nullptr;
|
||||||
QAction *m_mergeToolAction;
|
QAction *m_mergeToolAction = nullptr;
|
||||||
QAction *m_submoduleUpdateAction;
|
QAction *m_submoduleUpdateAction = nullptr;
|
||||||
QAction *m_abortMergeAction;
|
QAction *m_abortMergeAction = nullptr;
|
||||||
QAction *m_abortRebaseAction;
|
QAction *m_abortRebaseAction = nullptr;
|
||||||
QAction *m_abortCherryPickAction;
|
QAction *m_abortCherryPickAction = nullptr;
|
||||||
QAction *m_abortRevertAction;
|
QAction *m_abortRevertAction = nullptr;
|
||||||
QAction *m_continueRebaseAction;
|
QAction *m_continueRebaseAction = nullptr;
|
||||||
QAction *m_continueCherryPickAction;
|
QAction *m_continueCherryPickAction = nullptr;
|
||||||
QAction *m_continueRevertAction;
|
QAction *m_continueRevertAction = nullptr;
|
||||||
QAction *m_fixupCommitAction;
|
QAction *m_fixupCommitAction = nullptr;
|
||||||
QAction *m_interactiveRebaseAction;
|
QAction *m_interactiveRebaseAction = nullptr;
|
||||||
|
|
||||||
QVector<Utils::ParameterAction *> m_fileActions;
|
QVector<Utils::ParameterAction *> m_fileActions;
|
||||||
QVector<Utils::ParameterAction *> m_projectActions;
|
QVector<Utils::ParameterAction *> m_projectActions;
|
||||||
QVector<QAction *> m_repositoryActions;
|
QVector<QAction *> m_repositoryActions;
|
||||||
Utils::ParameterAction *m_applyCurrentFilePatchAction;
|
Utils::ParameterAction *m_applyCurrentFilePatchAction = nullptr;
|
||||||
Gerrit::Internal::GerritPlugin *m_gerritPlugin;
|
Gerrit::Internal::GerritPlugin *m_gerritPlugin = nullptr;
|
||||||
|
|
||||||
GitClient *m_gitClient;
|
GitClient *m_gitClient = nullptr;
|
||||||
QPointer<StashDialog> m_stashDialog;
|
QPointer<StashDialog> m_stashDialog;
|
||||||
QPointer<BranchDialog> m_branchDialog;
|
QPointer<BranchDialog> m_branchDialog;
|
||||||
QPointer<RemoteDialog> m_remoteDialog;
|
QPointer<RemoteDialog> m_remoteDialog;
|
||||||
QString m_submitRepository;
|
QString m_submitRepository;
|
||||||
QString m_commitMessageFileName;
|
QString m_commitMessageFileName;
|
||||||
bool m_submitActionTriggered;
|
bool m_submitActionTriggered = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
#endif // GITPLUGIN_H
|
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef GITSETTINGS_H
|
#pragma once
|
||||||
#define GITSETTINGS_H
|
|
||||||
|
|
||||||
#include <vcsbase/vcsbaseclientsettings.h>
|
#include <vcsbase/vcsbaseclientsettings.h>
|
||||||
|
|
||||||
@@ -65,5 +64,3 @@ public:
|
|||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
#endif // GITSETTINGS_H
|
|
||||||
|
|||||||
@@ -97,10 +97,9 @@ public:
|
|||||||
|
|
||||||
void start()
|
void start()
|
||||||
{
|
{
|
||||||
GitClient *client = GitPlugin::instance()->client();
|
|
||||||
QString commitTemplate;
|
QString commitTemplate;
|
||||||
bool success = client->getCommitData(m_workingDirectory, &commitTemplate,
|
bool success = GitPlugin::client()->getCommitData(m_workingDirectory, &commitTemplate,
|
||||||
m_commitData, &m_errorMessage);
|
m_commitData, &m_errorMessage);
|
||||||
emit finished(success);
|
emit finished(success);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,13 +121,7 @@ private:
|
|||||||
* according to a type flag we add to the model. */
|
* according to a type flag we add to the model. */
|
||||||
|
|
||||||
GitSubmitEditor::GitSubmitEditor(const VcsBaseSubmitEditorParameters *parameters) :
|
GitSubmitEditor::GitSubmitEditor(const VcsBaseSubmitEditorParameters *parameters) :
|
||||||
VcsBaseSubmitEditor(parameters, new GitSubmitEditorWidget),
|
VcsBaseSubmitEditor(parameters, new GitSubmitEditorWidget)
|
||||||
m_model(0),
|
|
||||||
m_commitEncoding(0),
|
|
||||||
m_commitType(SimpleCommit),
|
|
||||||
m_firstUpdate(true),
|
|
||||||
m_commitDataFetcher(0),
|
|
||||||
m_gitClient(GitPlugin::instance()->client())
|
|
||||||
{
|
{
|
||||||
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);
|
||||||
@@ -238,15 +231,15 @@ void GitSubmitEditor::slotDiffSelected(const QList<int> &rows)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!unstagedFiles.empty() || !stagedFiles.empty())
|
if (!unstagedFiles.empty() || !stagedFiles.empty())
|
||||||
m_gitClient->diffFiles(m_workingDirectory, unstagedFiles, stagedFiles);
|
GitPlugin::client()->diffFiles(m_workingDirectory, unstagedFiles, stagedFiles);
|
||||||
if (!unmergedFiles.empty())
|
if (!unmergedFiles.empty())
|
||||||
m_gitClient->merge(m_workingDirectory, unmergedFiles);
|
GitPlugin::client()->merge(m_workingDirectory, unmergedFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitSubmitEditor::showCommit(const QString &commit)
|
void GitSubmitEditor::showCommit(const QString &commit)
|
||||||
{
|
{
|
||||||
if (!m_workingDirectory.isEmpty())
|
if (!m_workingDirectory.isEmpty())
|
||||||
m_gitClient->show(m_workingDirectory, commit);
|
GitPlugin::client()->show(m_workingDirectory, commit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitSubmitEditor::updateFileModel()
|
void GitSubmitEditor::updateFileModel()
|
||||||
@@ -267,7 +260,7 @@ void GitSubmitEditor::updateFileModel()
|
|||||||
QFuture<void> future = QtConcurrent::run(m_commitDataFetcher, &CommitDataFetcher::start);
|
QFuture<void> future = QtConcurrent::run(m_commitDataFetcher, &CommitDataFetcher::start);
|
||||||
Core::ProgressManager::addTask(future, tr("Refreshing Commit Data"), TASK_UPDATE_COMMIT);
|
Core::ProgressManager::addTask(future, tr("Refreshing Commit Data"), TASK_UPDATE_COMMIT);
|
||||||
|
|
||||||
m_gitClient->addFuture(future);
|
GitPlugin::client()->addFuture(future);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitSubmitEditor::forceUpdateFileModel()
|
void GitSubmitEditor::forceUpdateFileModel()
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef GITSUBMITEDITOR_H
|
#pragma once
|
||||||
#define GITSUBMITEDITOR_H
|
|
||||||
|
|
||||||
#include "gitsettings.h" // CommitType
|
#include "gitsettings.h" // CommitType
|
||||||
|
|
||||||
@@ -41,11 +40,12 @@ class GitClient;
|
|||||||
class GitSubmitEditorWidget;
|
class GitSubmitEditorWidget;
|
||||||
class CommitData;
|
class CommitData;
|
||||||
class CommitDataFetcher;
|
class CommitDataFetcher;
|
||||||
struct GitSubmitEditorPanelData;
|
class GitSubmitEditorPanelData;
|
||||||
|
|
||||||
class GitSubmitEditor : public VcsBase::VcsBaseSubmitEditor
|
class GitSubmitEditor : public VcsBase::VcsBaseSubmitEditor
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GitSubmitEditor(const VcsBase::VcsBaseSubmitEditorParameters *parameters);
|
explicit GitSubmitEditor(const VcsBase::VcsBaseSubmitEditorParameters *parameters);
|
||||||
~GitSubmitEditor() override;
|
~GitSubmitEditor() override;
|
||||||
@@ -69,17 +69,14 @@ private:
|
|||||||
inline const GitSubmitEditorWidget *submitEditorWidget() const;
|
inline const GitSubmitEditorWidget *submitEditorWidget() const;
|
||||||
void resetCommitDataFetcher();
|
void resetCommitDataFetcher();
|
||||||
|
|
||||||
VcsBase::SubmitFileModel *m_model;
|
VcsBase::SubmitFileModel *m_model = nullptr;
|
||||||
QTextCodec *m_commitEncoding;
|
QTextCodec *m_commitEncoding = nullptr;
|
||||||
CommitType m_commitType;
|
CommitType m_commitType = SimpleCommit;
|
||||||
QString m_amendSHA1;
|
QString m_amendSHA1;
|
||||||
QString m_workingDirectory;
|
QString m_workingDirectory;
|
||||||
bool m_firstUpdate;
|
bool m_firstUpdate = true;
|
||||||
CommitDataFetcher *m_commitDataFetcher;
|
CommitDataFetcher *m_commitDataFetcher = nullptr;
|
||||||
GitClient *m_gitClient;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
#endif // GITSUBMITEDITOR_H
|
|
||||||
|
|||||||
@@ -46,11 +46,7 @@ namespace Internal {
|
|||||||
|
|
||||||
// ------------------
|
// ------------------
|
||||||
GitSubmitEditorWidget::GitSubmitEditorWidget() :
|
GitSubmitEditorWidget::GitSubmitEditorWidget() :
|
||||||
m_pushAction(NoPush),
|
m_gitSubmitPanel(new QWidget)
|
||||||
m_gitSubmitPanel(new QWidget),
|
|
||||||
m_logChangeWidget(0),
|
|
||||||
m_hasUnmerged(false),
|
|
||||||
m_isInitialized(false)
|
|
||||||
{
|
{
|
||||||
m_gitSubmitPanelUi.setupUi(m_gitSubmitPanel);
|
m_gitSubmitPanelUi.setupUi(m_gitSubmitPanel);
|
||||||
new GitSubmitHighlighter(descriptionEdit());
|
new GitSubmitHighlighter(descriptionEdit());
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef GITSUBMITEDITORWIDGET_H
|
#pragma once
|
||||||
#define GITSUBMITEDITORWIDGET_H
|
|
||||||
|
|
||||||
#include "ui_gitsubmitpanel.h"
|
#include "ui_gitsubmitpanel.h"
|
||||||
#include "gitsettings.h"
|
#include "gitsettings.h"
|
||||||
@@ -43,8 +42,8 @@ QT_END_NAMESPACE
|
|||||||
namespace Git {
|
namespace Git {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
struct GitSubmitEditorPanelInfo;
|
class GitSubmitEditorPanelInfo;
|
||||||
struct GitSubmitEditorPanelData;
|
class GitSubmitEditorPanelData;
|
||||||
class LogChangeWidget;
|
class LogChangeWidget;
|
||||||
|
|
||||||
/* Submit editor widget with 2 additional panes:
|
/* Submit editor widget with 2 additional panes:
|
||||||
@@ -90,18 +89,16 @@ private:
|
|||||||
void setPanelData(const GitSubmitEditorPanelData &data);
|
void setPanelData(const GitSubmitEditorPanelData &data);
|
||||||
void setPanelInfo(const GitSubmitEditorPanelInfo &info);
|
void setPanelInfo(const GitSubmitEditorPanelInfo &info);
|
||||||
|
|
||||||
PushAction m_pushAction;
|
PushAction m_pushAction = NoPush;
|
||||||
QWidget *m_gitSubmitPanel;
|
QWidget *m_gitSubmitPanel;
|
||||||
LogChangeWidget *m_logChangeWidget;
|
LogChangeWidget *m_logChangeWidget = nullptr;
|
||||||
Ui::GitSubmitPanel m_gitSubmitPanelUi;
|
Ui::GitSubmitPanel m_gitSubmitPanelUi;
|
||||||
QValidator *m_emailValidator;
|
QValidator *m_emailValidator;
|
||||||
QString m_originalAuthor;
|
QString m_originalAuthor;
|
||||||
QString m_originalEmail;
|
QString m_originalEmail;
|
||||||
bool m_hasUnmerged;
|
bool m_hasUnmerged = false;
|
||||||
bool m_isInitialized;
|
bool m_isInitialized = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
#endif // GITSUBMITEDITORWIDGET_H
|
|
||||||
|
|||||||
@@ -25,20 +25,12 @@
|
|||||||
|
|
||||||
#include "gitutils.h"
|
#include "gitutils.h"
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
|
|
||||||
namespace Git {
|
namespace Git {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
QDebug operator<<(QDebug d, const Stash &s)
|
|
||||||
{
|
|
||||||
QDebug nospace = d.nospace();
|
|
||||||
nospace << "name=" << s.name << " branch=" << s.branch << " message=" << s.message;
|
|
||||||
return d;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Stash::clear()
|
void Stash::clear()
|
||||||
{
|
{
|
||||||
name.clear();
|
name.clear();
|
||||||
|
|||||||
@@ -23,13 +23,11 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef GITUTILS_H
|
#pragma once
|
||||||
#define GITUTILS_H
|
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QDebug;
|
|
||||||
class QWidget;
|
class QWidget;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
@@ -46,8 +44,6 @@ public:
|
|||||||
QString message;
|
QString message;
|
||||||
};
|
};
|
||||||
|
|
||||||
QDebug operator<<(QDebug d, const Stash &);
|
|
||||||
|
|
||||||
// Make QInputDialog play nicely
|
// Make QInputDialog play nicely
|
||||||
bool inputText(QWidget *parent, const QString &title, const QString &prompt, QString *s);
|
bool inputText(QWidget *parent, const QString &title, const QString &prompt, QString *s);
|
||||||
|
|
||||||
@@ -61,5 +57,3 @@ QString versionString(unsigned ver);
|
|||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
#endif // GITUTILS_H
|
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef GITVERSIONCONTROL_H
|
#pragma once
|
||||||
#define GITVERSIONCONTROL_H
|
|
||||||
|
|
||||||
#include <coreplugin/iversioncontrol.h>
|
#include <coreplugin/iversioncontrol.h>
|
||||||
|
|
||||||
@@ -73,5 +72,3 @@ private:
|
|||||||
|
|
||||||
} // Internal
|
} // Internal
|
||||||
} // Git
|
} // Git
|
||||||
|
|
||||||
#endif // GITVERSIONCONTROL_H
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ bool LogChangeWidget::init(const QString &repository, const QString &commit, Log
|
|||||||
return true;
|
return true;
|
||||||
if (!(flags & Silent)) {
|
if (!(flags & Silent)) {
|
||||||
VcsOutputWindow::appendError(
|
VcsOutputWindow::appendError(
|
||||||
GitPlugin::instance()->client()->msgNoCommits(flags & IncludeRemotes));
|
GitPlugin::client()->msgNoCommits(flags & IncludeRemotes));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -152,14 +152,13 @@ bool LogChangeWidget::populateLog(const QString &repository, const QString &comm
|
|||||||
m_model->removeRows(0, rowCount);
|
m_model->removeRows(0, rowCount);
|
||||||
|
|
||||||
// Retrieve log using a custom format "Sha1:Subject [(refs)]"
|
// Retrieve log using a custom format "Sha1:Subject [(refs)]"
|
||||||
GitClient *client = GitPlugin::instance()->client();
|
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
arguments << QLatin1String("--max-count=1000") << QLatin1String("--format=%h:%s %d");
|
arguments << QLatin1String("--max-count=1000") << QLatin1String("--format=%h:%s %d");
|
||||||
arguments << (commit.isEmpty() ? QLatin1String("HEAD") : commit);
|
arguments << (commit.isEmpty() ? QLatin1String("HEAD") : commit);
|
||||||
if (!(flags & IncludeRemotes))
|
if (!(flags & IncludeRemotes))
|
||||||
arguments << QLatin1String("--not") << QLatin1String("--remotes");
|
arguments << QLatin1String("--not") << QLatin1String("--remotes");
|
||||||
QString output;
|
QString output;
|
||||||
if (!client->synchronousLog(repository, arguments, &output, 0, VcsCommand::NoOutput))
|
if (!GitPlugin::client()->synchronousLog(repository, arguments, &output, 0, VcsCommand::NoOutput))
|
||||||
return false;
|
return false;
|
||||||
foreach (const QString &line, output.split(QLatin1Char('\n'))) {
|
foreach (const QString &line, output.split(QLatin1Char('\n'))) {
|
||||||
const int colonPos = line.indexOf(QLatin1Char(':'));
|
const int colonPos = line.indexOf(QLatin1Char(':'));
|
||||||
@@ -211,8 +210,7 @@ LogChangeDialog::LogChangeDialog(bool isReset, QWidget *parent) :
|
|||||||
m_resetTypeComboBox->addItem(tr("Hard"), QLatin1String("--hard"));
|
m_resetTypeComboBox->addItem(tr("Hard"), QLatin1String("--hard"));
|
||||||
m_resetTypeComboBox->addItem(tr("Mixed"), QLatin1String("--mixed"));
|
m_resetTypeComboBox->addItem(tr("Mixed"), QLatin1String("--mixed"));
|
||||||
m_resetTypeComboBox->addItem(tr("Soft"), QLatin1String("--soft"));
|
m_resetTypeComboBox->addItem(tr("Soft"), QLatin1String("--soft"));
|
||||||
GitClient *client = GitPlugin::instance()->client();
|
m_resetTypeComboBox->setCurrentIndex(GitPlugin::client()->settings().intValue(
|
||||||
m_resetTypeComboBox->setCurrentIndex(client->settings().intValue(
|
|
||||||
GitSettings::lastResetIndexKey));
|
GitSettings::lastResetIndexKey));
|
||||||
popUpLayout->addWidget(m_resetTypeComboBox);
|
popUpLayout->addWidget(m_resetTypeComboBox);
|
||||||
popUpLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored));
|
popUpLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Ignored));
|
||||||
@@ -241,9 +239,8 @@ bool LogChangeDialog::runDialog(const QString &repository,
|
|||||||
|
|
||||||
if (QDialog::exec() == QDialog::Accepted) {
|
if (QDialog::exec() == QDialog::Accepted) {
|
||||||
if (m_resetTypeComboBox) {
|
if (m_resetTypeComboBox) {
|
||||||
GitClient *client = GitPlugin::instance()->client();
|
GitPlugin::client()->settings().setValue(GitSettings::lastResetIndexKey,
|
||||||
client->settings().setValue(GitSettings::lastResetIndexKey,
|
m_resetTypeComboBox->currentIndex());
|
||||||
m_resetTypeComboBox->currentIndex());
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef LOGCHANGEDDIALOG_H
|
#pragma once
|
||||||
#define LOGCHANGEDDIALOG_H
|
|
||||||
|
|
||||||
#include <utils/itemviews.h>
|
#include <utils/itemviews.h>
|
||||||
|
|
||||||
@@ -128,5 +127,3 @@ private:
|
|||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
#endif // LOGCHANGEDDIALOG_H
|
|
||||||
|
|||||||
@@ -45,38 +45,28 @@ namespace Internal {
|
|||||||
class MergeToolProcess : public QProcess
|
class MergeToolProcess : public QProcess
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MergeToolProcess(QObject *parent = 0) :
|
MergeToolProcess(QObject *parent = 0) : QProcess(parent)
|
||||||
QProcess(parent)
|
{ }
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
qint64 readData(char *data, qint64 maxlen) override
|
qint64 readData(char *data, qint64 maxlen) override
|
||||||
{
|
{
|
||||||
qint64 res = QProcess::readData(data, maxlen);
|
qint64 res = QProcess::readData(data, maxlen);
|
||||||
if (res > 0)
|
if (res > 0)
|
||||||
VcsOutputWindow::append(QString::fromLocal8Bit(data, res));
|
VcsOutputWindow::append(QString::fromLocal8Bit(data, int(res)));
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
qint64 writeData(const char *data, qint64 len) override
|
qint64 writeData(const char *data, qint64 len) override
|
||||||
{
|
{
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
VcsOutputWindow::append(QString::fromLocal8Bit(data, len));
|
VcsOutputWindow::append(QString::fromLocal8Bit(data, int(len)));
|
||||||
return QProcess::writeData(data, len);
|
return QProcess::writeData(data, len);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
MergeTool::MergeTool(QObject *parent) :
|
MergeTool::MergeTool(QObject *parent) : QObject(parent)
|
||||||
QObject(parent),
|
{ }
|
||||||
m_process(0),
|
|
||||||
m_mergeType(NormalMerge),
|
|
||||||
m_localState(UnknownState),
|
|
||||||
m_remoteState(UnknownState),
|
|
||||||
m_client(GitPlugin::instance()->client()),
|
|
||||||
m_merging(false)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
MergeTool::~MergeTool()
|
MergeTool::~MergeTool()
|
||||||
{
|
{
|
||||||
@@ -89,7 +79,7 @@ bool MergeTool::start(const QString &workingDirectory, const QStringList &files)
|
|||||||
arguments << QLatin1String("mergetool") << QLatin1String("-y") << files;
|
arguments << QLatin1String("mergetool") << QLatin1String("-y") << files;
|
||||||
m_process = new MergeToolProcess(this);
|
m_process = new MergeToolProcess(this);
|
||||||
m_process->setWorkingDirectory(workingDirectory);
|
m_process->setWorkingDirectory(workingDirectory);
|
||||||
const Utils::FileName binary = m_client->vcsBinary();
|
const Utils::FileName binary = GitPlugin::client()->vcsBinary();
|
||||||
VcsOutputWindow::appendCommand(workingDirectory, binary, arguments);
|
VcsOutputWindow::appendCommand(workingDirectory, binary, arguments);
|
||||||
m_process->start(binary.toString(), arguments);
|
m_process->start(binary.toString(), arguments);
|
||||||
if (m_process->waitForStarted()) {
|
if (m_process->waitForStarted()) {
|
||||||
@@ -265,7 +255,7 @@ void MergeTool::done()
|
|||||||
VcsOutputWindow::appendError(tr("Merge tool process terminated with exit code %1")
|
VcsOutputWindow::appendError(tr("Merge tool process terminated with exit code %1")
|
||||||
.arg(exitCode));
|
.arg(exitCode));
|
||||||
}
|
}
|
||||||
m_client->continueCommandIfNeeded(workingDirectory, exitCode == 0);
|
GitPlugin::client()->continueCommandIfNeeded(workingDirectory, exitCode == 0);
|
||||||
GitPlugin::instance()->gitVersionControl()->emitRepositoryChanged(workingDirectory);
|
GitPlugin::instance()->gitVersionControl()->emitRepositoryChanged(workingDirectory);
|
||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef MERGETOOL_H
|
#pragma once
|
||||||
#define MERGETOOL_H
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
@@ -74,18 +73,15 @@ private:
|
|||||||
void chooseAction();
|
void chooseAction();
|
||||||
void addButton(QMessageBox *msgBox, const QString &text, char key);
|
void addButton(QMessageBox *msgBox, const QString &text, char key);
|
||||||
|
|
||||||
MergeToolProcess *m_process;
|
MergeToolProcess *m_process = nullptr;
|
||||||
MergeType m_mergeType;
|
MergeType m_mergeType = NormalMerge;
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
FileState m_localState;
|
FileState m_localState = UnknownState;
|
||||||
QString m_localInfo;
|
QString m_localInfo;
|
||||||
FileState m_remoteState;
|
FileState m_remoteState = UnknownState;
|
||||||
QString m_remoteInfo;
|
QString m_remoteInfo;
|
||||||
GitClient *m_client;
|
bool m_merging = false;
|
||||||
bool m_merging;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
#endif // MERGETOOL_H
|
|
||||||
|
|||||||
@@ -81,8 +81,7 @@ void RemoteAdditionDialog::clear()
|
|||||||
RemoteDialog::RemoteDialog(QWidget *parent) :
|
RemoteDialog::RemoteDialog(QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
m_ui(new Ui::RemoteDialog),
|
m_ui(new Ui::RemoteDialog),
|
||||||
m_remoteModel(new RemoteModel(GitPlugin::instance()->client(), this)),
|
m_remoteModel(new RemoteModel(this))
|
||||||
m_addDialog(0)
|
|
||||||
{
|
{
|
||||||
setModal(false);
|
setModal(false);
|
||||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||||
@@ -166,7 +165,7 @@ void RemoteDialog::pushToRemote()
|
|||||||
|
|
||||||
const int row = indexList.at(0).row();
|
const int row = indexList.at(0).row();
|
||||||
const QString remoteName = m_remoteModel->remoteName(row);
|
const QString remoteName = m_remoteModel->remoteName(row);
|
||||||
m_remoteModel->client()->push(m_remoteModel->workingDirectory(),
|
GitPlugin::client()->push(m_remoteModel->workingDirectory(),
|
||||||
QStringList() << remoteName);
|
QStringList() << remoteName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,7 +177,7 @@ void RemoteDialog::fetchFromRemote()
|
|||||||
|
|
||||||
int row = indexList.at(0).row();
|
int row = indexList.at(0).row();
|
||||||
const QString remoteName = m_remoteModel->remoteName(row);
|
const QString remoteName = m_remoteModel->remoteName(row);
|
||||||
m_remoteModel->client()->fetch(m_remoteModel->workingDirectory(), remoteName);
|
GitPlugin::client()->fetch(m_remoteModel->workingDirectory(), remoteName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemoteDialog::updateButtonState()
|
void RemoteDialog::updateButtonState()
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef REMOTEDIALOG_H
|
#pragma once
|
||||||
#define REMOTEDIALOG_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
@@ -34,7 +33,7 @@ namespace Internal {
|
|||||||
namespace Ui {
|
namespace Ui {
|
||||||
class RemoteDialog;
|
class RemoteDialog;
|
||||||
class RemoteAdditionDialog;
|
class RemoteAdditionDialog;
|
||||||
}
|
} // namespace Ui
|
||||||
|
|
||||||
class GitClient;
|
class GitClient;
|
||||||
class RemoteModel;
|
class RemoteModel;
|
||||||
@@ -49,7 +48,7 @@ class RemoteAdditionDialog : public QDialog
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit RemoteAdditionDialog(QWidget *parent = 0);
|
explicit RemoteAdditionDialog(QWidget *parent = 0);
|
||||||
~RemoteAdditionDialog();
|
~RemoteAdditionDialog() override;
|
||||||
|
|
||||||
QString remoteName() const;
|
QString remoteName() const;
|
||||||
QString remoteUrl() const;
|
QString remoteUrl() const;
|
||||||
@@ -70,9 +69,8 @@ class RemoteDialog : public QDialog
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit RemoteDialog(QWidget *parent = 0);
|
explicit RemoteDialog(QWidget *parent = 0);
|
||||||
~RemoteDialog();
|
~RemoteDialog() override;
|
||||||
|
|
||||||
public slots:
|
|
||||||
void refresh(const QString &repository, bool force);
|
void refresh(const QString &repository, bool force);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -87,10 +85,8 @@ private:
|
|||||||
Ui::RemoteDialog *m_ui;
|
Ui::RemoteDialog *m_ui;
|
||||||
|
|
||||||
RemoteModel *m_remoteModel;
|
RemoteModel *m_remoteModel;
|
||||||
RemoteAdditionDialog *m_addDialog;
|
RemoteAdditionDialog *m_addDialog = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
#endif // REMOTEDIALOG_H
|
|
||||||
|
|||||||
@@ -24,16 +24,14 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "remotemodel.h"
|
#include "remotemodel.h"
|
||||||
|
#include "gitplugin.h"
|
||||||
#include "gitclient.h"
|
#include "gitclient.h"
|
||||||
|
|
||||||
namespace Git {
|
namespace Git {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
// ------ RemoteModel
|
// ------ RemoteModel
|
||||||
RemoteModel::RemoteModel(GitClient *client, QObject *parent) :
|
RemoteModel::RemoteModel(QObject *parent) : QAbstractTableModel(parent)
|
||||||
QAbstractTableModel(parent),
|
|
||||||
m_flags(Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable),
|
|
||||||
m_client(client)
|
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
QString RemoteModel::remoteName(int row) const
|
QString RemoteModel::remoteName(int row) const
|
||||||
@@ -50,9 +48,9 @@ bool RemoteModel::removeRemote(int row)
|
|||||||
{
|
{
|
||||||
QString output;
|
QString output;
|
||||||
QString error;
|
QString error;
|
||||||
bool success = m_client->synchronousRemoteCmd(m_workingDirectory,
|
bool success = GitPlugin::client()->synchronousRemoteCmd(m_workingDirectory,
|
||||||
QStringList() << QLatin1String("rm") << remoteName(row),
|
QStringList() << QLatin1String("rm") << remoteName(row),
|
||||||
&output, &error);
|
&output, &error);
|
||||||
if (success)
|
if (success)
|
||||||
success = refresh(m_workingDirectory, &error);
|
success = refresh(m_workingDirectory, &error);
|
||||||
return success;
|
return success;
|
||||||
@@ -65,9 +63,9 @@ bool RemoteModel::addRemote(const QString &name, const QString &url)
|
|||||||
if (name.isEmpty() || url.isEmpty())
|
if (name.isEmpty() || url.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
bool success = m_client->synchronousRemoteCmd(m_workingDirectory,
|
bool success = GitPlugin::client()->synchronousRemoteCmd(m_workingDirectory,
|
||||||
QStringList() << QLatin1String("add") << name << url,
|
QStringList() << QLatin1String("add") << name << url,
|
||||||
&output, &error);
|
&output, &error);
|
||||||
if (success)
|
if (success)
|
||||||
success = refresh(m_workingDirectory, &error);
|
success = refresh(m_workingDirectory, &error);
|
||||||
return success;
|
return success;
|
||||||
@@ -77,9 +75,9 @@ bool RemoteModel::renameRemote(const QString &oldName, const QString &newName)
|
|||||||
{
|
{
|
||||||
QString output;
|
QString output;
|
||||||
QString error;
|
QString error;
|
||||||
bool success = m_client->synchronousRemoteCmd(m_workingDirectory,
|
bool success = GitPlugin::client()->synchronousRemoteCmd(m_workingDirectory,
|
||||||
QStringList() << QLatin1String("rename") << oldName << newName,
|
QStringList() << QLatin1String("rename") << oldName << newName,
|
||||||
&output, &error);
|
&output, &error);
|
||||||
if (success)
|
if (success)
|
||||||
success = refresh(m_workingDirectory, &error);
|
success = refresh(m_workingDirectory, &error);
|
||||||
return success;
|
return success;
|
||||||
@@ -89,9 +87,9 @@ bool RemoteModel::updateUrl(const QString &name, const QString &newUrl)
|
|||||||
{
|
{
|
||||||
QString output;
|
QString output;
|
||||||
QString error;
|
QString error;
|
||||||
bool success = m_client->synchronousRemoteCmd(m_workingDirectory,
|
bool success = GitPlugin::client()->synchronousRemoteCmd(m_workingDirectory,
|
||||||
QStringList() << QLatin1String("set-url") << name << newUrl,
|
QStringList() << QLatin1String("set-url") << name << newUrl,
|
||||||
&output, &error);
|
&output, &error);
|
||||||
if (success)
|
if (success)
|
||||||
success = refresh(m_workingDirectory, &error);
|
success = refresh(m_workingDirectory, &error);
|
||||||
return success;
|
return success;
|
||||||
@@ -184,8 +182,8 @@ bool RemoteModel::refresh(const QString &workingDirectory, QString *errorMessage
|
|||||||
m_workingDirectory = workingDirectory;
|
m_workingDirectory = workingDirectory;
|
||||||
|
|
||||||
// get list of remotes.
|
// get list of remotes.
|
||||||
QMap<QString,QString> remotesList =
|
QMap<QString,QString> remotesList
|
||||||
m_client->synchronousRemotesList(workingDirectory, errorMessage);
|
= GitPlugin::client()->synchronousRemotesList(workingDirectory, errorMessage);
|
||||||
|
|
||||||
if (remotesList.isEmpty())
|
if (remotesList.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
@@ -211,11 +209,6 @@ int RemoteModel::findRemoteByName(const QString &name) const
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
GitClient *RemoteModel::client() const
|
|
||||||
{
|
|
||||||
return m_client;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef REMOTEMODEL_H
|
#pragma once
|
||||||
#define REMOTEMODEL_H
|
|
||||||
|
|
||||||
#include <QAbstractTableModel>
|
#include <QAbstractTableModel>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
@@ -38,7 +37,7 @@ class GitClient;
|
|||||||
class RemoteModel : public QAbstractTableModel {
|
class RemoteModel : public QAbstractTableModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit RemoteModel(GitClient *client, QObject *parent = 0);
|
explicit RemoteModel(QObject *parent = 0);
|
||||||
|
|
||||||
void clear();
|
void clear();
|
||||||
bool refresh(const QString &workingDirectory, QString *errorMessage);
|
bool refresh(const QString &workingDirectory, QString *errorMessage);
|
||||||
@@ -64,24 +63,21 @@ public:
|
|||||||
|
|
||||||
QString workingDirectory() const;
|
QString workingDirectory() const;
|
||||||
int findRemoteByName(const QString &name) const;
|
int findRemoteByName(const QString &name) const;
|
||||||
GitClient *client() const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
struct Remote {
|
class Remote {
|
||||||
|
public:
|
||||||
QString name;
|
QString name;
|
||||||
QString url;
|
QString url;
|
||||||
};
|
};
|
||||||
typedef QList<Remote> RemoteList;
|
typedef QList<Remote> RemoteList;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Qt::ItemFlags m_flags;
|
const Qt::ItemFlags m_flags = Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable;
|
||||||
|
|
||||||
GitClient *m_client;
|
|
||||||
QString m_workingDirectory;
|
QString m_workingDirectory;
|
||||||
RemoteList m_remotes;
|
RemoteList m_remotes;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
#endif // REMOTEMODEL_H
|
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ void SettingsPageWidget::setSettings(const VcsBaseClientSettings &s)
|
|||||||
|
|
||||||
// -------- SettingsPage
|
// -------- SettingsPage
|
||||||
SettingsPage::SettingsPage(Core::IVersionControl *control) :
|
SettingsPage::SettingsPage(Core::IVersionControl *control) :
|
||||||
VcsClientOptionsPage(control, GitPlugin::instance()->client())
|
VcsClientOptionsPage(control, GitPlugin::client())
|
||||||
{
|
{
|
||||||
setId(VcsBase::Constants::VCS_ID_GIT);
|
setId(VcsBase::Constants::VCS_ID_GIT);
|
||||||
setDisplayName(tr("Git"));
|
setDisplayName(tr("Git"));
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef SETTINGSPAGE_H
|
#pragma once
|
||||||
#define SETTINGSPAGE_H
|
|
||||||
|
|
||||||
#include <vcsbase/vcsbaseoptionspage.h>
|
#include <vcsbase/vcsbaseoptionspage.h>
|
||||||
|
|
||||||
@@ -46,6 +45,7 @@ namespace Internal {
|
|||||||
|
|
||||||
class SettingsPageWidget : public VcsBase::VcsClientOptionsPageWidget {
|
class SettingsPageWidget : public VcsBase::VcsClientOptionsPageWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit SettingsPageWidget(QWidget *parent = 0);
|
explicit SettingsPageWidget(QWidget *parent = 0);
|
||||||
|
|
||||||
@@ -67,5 +67,3 @@ public:
|
|||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
#endif // SETTINGSPAGE_H
|
|
||||||
|
|||||||
@@ -46,11 +46,6 @@ enum { NameColumn, BranchColumn, MessageColumn, ColumnCount };
|
|||||||
namespace Git {
|
namespace Git {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
static inline GitClient *gitClient()
|
|
||||||
{
|
|
||||||
return GitPlugin::instance()->client();
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline QList<QStandardItem*> stashModelRowItems(const Stash &s)
|
static inline QList<QStandardItem*> stashModelRowItems(const Stash &s)
|
||||||
{
|
{
|
||||||
Qt::ItemFlags itemFlags = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
|
Qt::ItemFlags itemFlags = Qt::ItemIsSelectable | Qt::ItemIsEnabled;
|
||||||
@@ -95,8 +90,7 @@ void StashModel::setStashes(const QList<Stash> &stashes)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ---------- StashDialog
|
// ---------- StashDialog
|
||||||
StashDialog::StashDialog(QWidget *parent) :
|
StashDialog::StashDialog(QWidget *parent) : QDialog(parent),
|
||||||
QDialog(parent),
|
|
||||||
ui(new Ui::StashDialog),
|
ui(new Ui::StashDialog),
|
||||||
m_model(new StashModel),
|
m_model(new StashModel),
|
||||||
m_proxyModel(new QSortFilterProxyModel),
|
m_proxyModel(new QSortFilterProxyModel),
|
||||||
@@ -175,7 +169,7 @@ void StashDialog::refresh(const QString &repository, bool force)
|
|||||||
m_model->setStashes(QList<Stash>());
|
m_model->setStashes(QList<Stash>());
|
||||||
} else {
|
} else {
|
||||||
QList<Stash> stashes;
|
QList<Stash> stashes;
|
||||||
gitClient()->synchronousStashList(m_repository, &stashes);
|
GitPlugin::client()->synchronousStashList(m_repository, &stashes);
|
||||||
m_model->setStashes(stashes);
|
m_model->setStashes(stashes);
|
||||||
if (!stashes.isEmpty()) {
|
if (!stashes.isEmpty()) {
|
||||||
for (int c = 0; c < ColumnCount; c++)
|
for (int c = 0; c < ColumnCount; c++)
|
||||||
@@ -191,7 +185,7 @@ void StashDialog::deleteAll()
|
|||||||
if (!ask(title, tr("Do you want to delete all stashes?")))
|
if (!ask(title, tr("Do you want to delete all stashes?")))
|
||||||
return;
|
return;
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
if (gitClient()->synchronousStashRemove(m_repository, QString(), &errorMessage))
|
if (GitPlugin::client()->synchronousStashRemove(m_repository, QString(), &errorMessage))
|
||||||
refresh(m_repository, true);
|
refresh(m_repository, true);
|
||||||
else
|
else
|
||||||
warning(title, errorMessage);
|
warning(title, errorMessage);
|
||||||
@@ -208,7 +202,7 @@ void StashDialog::deleteSelection()
|
|||||||
QStringList errors;
|
QStringList errors;
|
||||||
// Delete in reverse order as stashes rotate
|
// Delete in reverse order as stashes rotate
|
||||||
for (int r = rows.size() - 1; r >= 0; r--)
|
for (int r = rows.size() - 1; r >= 0; r--)
|
||||||
if (!gitClient()->synchronousStashRemove(m_repository, m_model->at(rows.at(r)).name, &errorMessage))
|
if (!GitPlugin::client()->synchronousStashRemove(m_repository, m_model->at(rows.at(r)).name, &errorMessage))
|
||||||
errors.push_back(errorMessage);
|
errors.push_back(errorMessage);
|
||||||
refresh(m_repository, true);
|
refresh(m_repository, true);
|
||||||
if (!errors.isEmpty())
|
if (!errors.isEmpty())
|
||||||
@@ -219,7 +213,7 @@ void StashDialog::showCurrent()
|
|||||||
{
|
{
|
||||||
const int index = currentRow();
|
const int index = currentRow();
|
||||||
QTC_ASSERT(index >= 0, return);
|
QTC_ASSERT(index >= 0, return);
|
||||||
gitClient()->show(m_repository, QString(m_model->at(index).name));
|
GitPlugin::client()->show(m_repository, QString(m_model->at(index).name));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Suggest Branch name to restore 'stash@{0}' -> 'stash0-date'
|
// Suggest Branch name to restore 'stash@{0}' -> 'stash0-date'
|
||||||
@@ -280,7 +274,7 @@ bool StashDialog::promptForRestore(QString *stash,
|
|||||||
{
|
{
|
||||||
const QString stashIn = *stash;
|
const QString stashIn = *stash;
|
||||||
bool modifiedPromptShown = false;
|
bool modifiedPromptShown = false;
|
||||||
switch (gitClient()->gitStatus(m_repository, StatusMode(NoUntracked | NoSubmodules), 0, errorMessage)) {
|
switch (GitPlugin::client()->gitStatus(m_repository, StatusMode(NoUntracked | NoSubmodules), 0, errorMessage)) {
|
||||||
case GitClient::StatusFailed:
|
case GitClient::StatusFailed:
|
||||||
return false;
|
return false;
|
||||||
case GitClient::StatusChanged: {
|
case GitClient::StatusChanged: {
|
||||||
@@ -288,13 +282,13 @@ bool StashDialog::promptForRestore(QString *stash,
|
|||||||
case ModifiedRepositoryCancel:
|
case ModifiedRepositoryCancel:
|
||||||
return false;
|
return false;
|
||||||
case ModifiedRepositoryStash:
|
case ModifiedRepositoryStash:
|
||||||
if (gitClient()->synchronousStash(m_repository, QString(), GitClient::StashPromptDescription).isEmpty())
|
if (GitPlugin::client()->synchronousStash(m_repository, QString(), GitClient::StashPromptDescription).isEmpty())
|
||||||
return false;
|
return false;
|
||||||
*stash = nextStash(*stash); // Our stash id to be restored changed
|
*stash = nextStash(*stash); // Our stash id to be restored changed
|
||||||
QTC_ASSERT(!stash->isEmpty(), return false);
|
QTC_ASSERT(!stash->isEmpty(), return false);
|
||||||
break;
|
break;
|
||||||
case ModifiedRepositoryDiscard:
|
case ModifiedRepositoryDiscard:
|
||||||
if (!gitClient()->synchronousReset(m_repository))
|
if (!GitPlugin::client()->synchronousReset(m_repository))
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -331,7 +325,7 @@ void StashDialog::restoreCurrent()
|
|||||||
// Make sure repository is not modified, restore. The command will
|
// Make sure repository is not modified, restore. The command will
|
||||||
// output to window on success.
|
// output to window on success.
|
||||||
if (promptForRestore(&name, 0, &errorMessage)
|
if (promptForRestore(&name, 0, &errorMessage)
|
||||||
&& gitClient()->synchronousStashRestore(m_repository, name)) {
|
&& GitPlugin::client()->synchronousStashRestore(m_repository, name)) {
|
||||||
refresh(m_repository, true); // Might have stashed away local changes.
|
refresh(m_repository, true); // Might have stashed away local changes.
|
||||||
} else if (!errorMessage.isEmpty()) {
|
} else if (!errorMessage.isEmpty()) {
|
||||||
warning(msgRestoreFailedTitle(name), errorMessage);
|
warning(msgRestoreFailedTitle(name), errorMessage);
|
||||||
@@ -346,7 +340,7 @@ void StashDialog::restoreCurrentInBranch()
|
|||||||
QString branch;
|
QString branch;
|
||||||
QString name = m_model->at(index).name;
|
QString name = m_model->at(index).name;
|
||||||
if (promptForRestore(&name, &branch, &errorMessage)
|
if (promptForRestore(&name, &branch, &errorMessage)
|
||||||
&& gitClient()->synchronousStashRestore(m_repository, name, false, branch)) {
|
&& GitPlugin::client()->synchronousStashRestore(m_repository, name, false, branch)) {
|
||||||
refresh(m_repository, true); // git deletes the stash, unfortunately.
|
refresh(m_repository, true); // git deletes the stash, unfortunately.
|
||||||
} else if (!errorMessage.isEmpty()) {
|
} else if (!errorMessage.isEmpty()) {
|
||||||
warning(msgRestoreFailedTitle(name), errorMessage);
|
warning(msgRestoreFailedTitle(name), errorMessage);
|
||||||
|
|||||||
@@ -23,8 +23,7 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef STASHDIALOG_H
|
#pragma once
|
||||||
#define STASHDIALOG_H
|
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
@@ -51,11 +50,10 @@ class StashDialog : public QDialog
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
explicit StashDialog(QWidget *parent = 0);
|
explicit StashDialog(QWidget *parent = 0);
|
||||||
~StashDialog();
|
~StashDialog() override;
|
||||||
|
|
||||||
static QString msgRepositoryLabel(const QString &repository);
|
static QString msgRepositoryLabel(const QString &repository);
|
||||||
|
|
||||||
public slots:
|
|
||||||
void refresh(const QString &repository, bool force);
|
void refresh(const QString &repository, bool force);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -95,5 +93,3 @@ private:
|
|||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
#endif // STASHDIALOG_H
|
|
||||||
|
|||||||
Reference in New Issue
Block a user