forked from qt-creator/qt-creator
Git: Move addChangeActions from GitEditor to GitClient
Change-Id: Id901994ac2909b00ca58a0a8a91d2d3a273c39b3 Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
7c4f0a9b1e
commit
b52ffa2501
@@ -3596,6 +3596,55 @@ GitRemote::GitRemote(const QString &location) : Core::IVersionControl::RepoUrl(l
|
|||||||
isValid = QDir(path).exists() || QDir(path + ".git").exists();
|
isValid = QDir(path).exists() || QDir(path + ".git").exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GitClient::addChangeActions(QMenu *menu, const QString &workingDir, const QString &change)
|
||||||
|
{
|
||||||
|
menu->addAction(tr("Cherr&y-Pick Change %1").arg(change), [workingDir, change] {
|
||||||
|
m_instance->synchronousCherryPick(workingDir, change);
|
||||||
|
});
|
||||||
|
menu->addAction(tr("Re&vert Change %1").arg(change), [workingDir, change] {
|
||||||
|
m_instance->synchronousRevert(workingDir, change);
|
||||||
|
});
|
||||||
|
menu->addAction(tr("C&heckout Change %1").arg(change), [workingDir, change] {
|
||||||
|
m_instance->checkout(workingDir, change);
|
||||||
|
});
|
||||||
|
connect(menu->addAction(tr("&Interactive Rebase from Change %1...").arg(change)),
|
||||||
|
&QAction::triggered, [workingDir, change] {
|
||||||
|
GitPlugin::startRebaseFromCommit(workingDir, change);
|
||||||
|
});
|
||||||
|
menu->addAction(tr("&Log for Change %1").arg(change), [workingDir, change] {
|
||||||
|
m_instance->log(workingDir, QString(), false, {change});
|
||||||
|
});
|
||||||
|
menu->addAction(tr("Add &Tag for Change %1...").arg(change), [workingDir, change] {
|
||||||
|
QString output;
|
||||||
|
QString errorMessage;
|
||||||
|
m_instance->synchronousTagCmd(workingDir, QStringList(),
|
||||||
|
&output, &errorMessage);
|
||||||
|
|
||||||
|
const QStringList tags = output.split('\n');
|
||||||
|
BranchAddDialog dialog(tags, BranchAddDialog::Type::AddTag, Core::ICore::dialogParent());
|
||||||
|
|
||||||
|
if (dialog.exec() == QDialog::Rejected)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_instance->synchronousTagCmd(workingDir,
|
||||||
|
{dialog.branchName(), change},
|
||||||
|
&output, &errorMessage);
|
||||||
|
VcsOutputWindow::append(output);
|
||||||
|
if (!errorMessage.isEmpty())
|
||||||
|
VcsOutputWindow::append(errorMessage, VcsOutputWindow::MessageStyle::Error);
|
||||||
|
});
|
||||||
|
|
||||||
|
auto resetChange = [workingDir, change](const QByteArray &resetType) {
|
||||||
|
m_instance->reset(
|
||||||
|
workingDir, QLatin1String("--" + resetType), change);
|
||||||
|
};
|
||||||
|
auto resetMenu = new QMenu(tr("&Reset to Change %1").arg(change), menu);
|
||||||
|
resetMenu->addAction(tr("&Hard"), std::bind(resetChange, "hard"));
|
||||||
|
resetMenu->addAction(tr("&Mixed"), std::bind(resetChange, "mixed"));
|
||||||
|
resetMenu->addAction(tr("&Soft"), std::bind(resetChange, "soft"));
|
||||||
|
menu->addMenu(resetMenu);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace Git
|
} // namespace Git
|
||||||
|
|
||||||
|
@@ -353,6 +353,9 @@ public:
|
|||||||
|
|
||||||
VcsBase::VcsCommand *asyncUpstreamStatus(const QString &workingDirectory,
|
VcsBase::VcsCommand *asyncUpstreamStatus(const QString &workingDirectory,
|
||||||
const QString &branch, const QString &upstream);
|
const QString &branch, const QString &upstream);
|
||||||
|
|
||||||
|
static void addChangeActions(QMenu *menu, const QString &workingDir, const QString &change);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void finishSubmoduleUpdate();
|
void finishSubmoduleUpdate();
|
||||||
void chunkActionsRequested(QMenu *menu, int fileIndex, int chunkIndex,
|
void chunkActionsRequested(QMenu *menu, int fileIndex, int chunkIndex,
|
||||||
|
@@ -308,59 +308,10 @@ bool GitEditorWidget::isValidRevision(const QString &revision) const
|
|||||||
return GitClient::instance()->isValidRevision(revision);
|
return GitClient::instance()->isValidRevision(revision);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitEditorWidget::addChangeActions(QMenu *menu, const QString &change, const QString &workingDir)
|
|
||||||
{
|
|
||||||
menu->addAction(tr("Cherr&y-Pick Change %1").arg(change), [workingDir, change] {
|
|
||||||
GitClient::instance()->synchronousCherryPick(workingDir, change);
|
|
||||||
});
|
|
||||||
menu->addAction(tr("Re&vert Change %1").arg(change), [workingDir, change] {
|
|
||||||
GitClient::instance()->synchronousRevert(workingDir, change);
|
|
||||||
});
|
|
||||||
menu->addAction(tr("C&heckout Change %1").arg(change), [workingDir, change] {
|
|
||||||
GitClient::instance()->checkout(workingDir, change);
|
|
||||||
});
|
|
||||||
connect(menu->addAction(tr("&Interactive Rebase from Change %1...").arg(change)),
|
|
||||||
&QAction::triggered, [workingDir, change] {
|
|
||||||
GitPlugin::startRebaseFromCommit(workingDir, change);
|
|
||||||
});
|
|
||||||
menu->addAction(tr("&Log for Change %1").arg(change), [workingDir, change] {
|
|
||||||
GitClient::instance()->log(workingDir, QString(), false, {change});
|
|
||||||
});
|
|
||||||
menu->addAction(tr("Add &Tag for Change %1...").arg(change), [workingDir, change] {
|
|
||||||
QString output;
|
|
||||||
QString errorMessage;
|
|
||||||
GitClient::instance()->synchronousTagCmd(workingDir, QStringList(),
|
|
||||||
&output, &errorMessage);
|
|
||||||
|
|
||||||
const QStringList tags = output.split('\n');
|
|
||||||
BranchAddDialog dialog(tags, BranchAddDialog::Type::AddTag, Core::ICore::dialogParent());
|
|
||||||
|
|
||||||
if (dialog.exec() == QDialog::Rejected)
|
|
||||||
return;
|
|
||||||
|
|
||||||
GitClient::instance()->synchronousTagCmd(workingDir,
|
|
||||||
{dialog.branchName(), change},
|
|
||||||
&output, &errorMessage);
|
|
||||||
VcsOutputWindow::append(output);
|
|
||||||
if (!errorMessage.isEmpty())
|
|
||||||
VcsOutputWindow::append(errorMessage, VcsOutputWindow::MessageStyle::Error);
|
|
||||||
});
|
|
||||||
|
|
||||||
auto resetChange = [workingDir, change](const QByteArray &resetType) {
|
|
||||||
GitClient::instance()->reset(
|
|
||||||
workingDir, QLatin1String("--" + resetType), change);
|
|
||||||
};
|
|
||||||
auto resetMenu = new QMenu(tr("&Reset to Change %1").arg(change), menu);
|
|
||||||
resetMenu->addAction(tr("&Hard"), std::bind(resetChange, "hard"));
|
|
||||||
resetMenu->addAction(tr("&Mixed"), std::bind(resetChange, "mixed"));
|
|
||||||
resetMenu->addAction(tr("&Soft"), std::bind(resetChange, "soft"));
|
|
||||||
menu->addMenu(resetMenu);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GitEditorWidget::addChangeActions(QMenu *menu, const QString &change)
|
void GitEditorWidget::addChangeActions(QMenu *menu, const QString &change)
|
||||||
{
|
{
|
||||||
if (contentType() != OtherContent)
|
if (contentType() != OtherContent)
|
||||||
addChangeActions(menu, change, sourceWorkingDirectory());
|
GitClient::addChangeActions(menu, change, sourceWorkingDirectory());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString GitEditorWidget::revisionSubject(const QTextBlock &inBlock) const
|
QString GitEditorWidget::revisionSubject(const QTextBlock &inBlock) const
|
||||||
|
@@ -66,7 +66,6 @@ private:
|
|||||||
QStringList annotationPreviousVersions(const QString &revision) const override;
|
QStringList annotationPreviousVersions(const QString &revision) const override;
|
||||||
bool isValidRevision(const QString &revision) const override;
|
bool isValidRevision(const QString &revision) const override;
|
||||||
void addChangeActions(QMenu *menu, const QString &change) override;
|
void addChangeActions(QMenu *menu, const QString &change) override;
|
||||||
static void addChangeActions(QMenu *menu, const QString &workingDir, const QString &change);
|
|
||||||
QString revisionSubject(const QTextBlock &inBlock) const override;
|
QString revisionSubject(const QTextBlock &inBlock) const override;
|
||||||
bool supportChangeLinks() const override;
|
bool supportChangeLinks() const override;
|
||||||
QString fileNameForLine(int line) const override;
|
QString fileNameForLine(int line) const override;
|
||||||
|
Reference in New Issue
Block a user