Git: Support Log for selected commit in git editors

Change-Id: I5081471b3be65de1948d9bfdd52fd812df5e6a7a
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
Orgad Shaneh
2015-03-10 12:26:01 +02:00
committed by Orgad Shaneh
parent 690a545f8e
commit 478a2e86f9
3 changed files with 17 additions and 3 deletions

View File

@@ -892,16 +892,22 @@ void GitClient::status(const QString &workingDirectory)
void GitClient::log(const QString &workingDirectory, const QString &fileName, void GitClient::log(const QString &workingDirectory, const QString &fileName,
bool enableAnnotationContextMenu, const QStringList &args) bool enableAnnotationContextMenu, const QStringList &args)
{ {
const QString msgArg = fileName.isEmpty() ? workingDirectory : fileName; QString msgArg;
if (!fileName.isEmpty())
msgArg = fileName;
else if (!args.isEmpty())
msgArg = args.first();
else
msgArg = workingDirectory;
const QString title = tr("Git Log \"%1\"").arg(msgArg); const QString title = tr("Git Log \"%1\"").arg(msgArg);
const Id editorId = Git::Constants::GIT_LOG_EDITOR_ID; const Id editorId = Git::Constants::GIT_LOG_EDITOR_ID;
const QString sourceFile = VcsBaseEditor::getSource(workingDirectory, fileName); const QString sourceFile = VcsBaseEditor::getSource(workingDirectory, fileName);
VcsBaseEditorWidget *editor = findExistingVCSEditor("logFileName", sourceFile); VcsBaseEditorWidget *editor = findExistingVCSEditor("logTitle", msgArg);
if (!editor) { if (!editor) {
auto *argWidget = new GitLogArgumentsWidget(settings()); auto *argWidget = new GitLogArgumentsWidget(settings());
connect(argWidget, &VcsBaseEditorParameterWidget::commandExecutionRequested, connect(argWidget, &VcsBaseEditorParameterWidget::commandExecutionRequested,
[=]() { this->log(workingDirectory, fileName, enableAnnotationContextMenu, args); }); [=]() { this->log(workingDirectory, fileName, enableAnnotationContextMenu, args); });
editor = createVcsEditor(editorId, title, sourceFile, CodecLogOutput, "logFileName", sourceFile, editor = createVcsEditor(editorId, title, sourceFile, CodecLogOutput, "logTitle", msgArg,
argWidget); argWidget);
} }
editor->setFileLogAnnotateEnabled(enableAnnotationContextMenu); editor->setFileLogAnnotateEnabled(enableAnnotationContextMenu);

View File

@@ -243,6 +243,12 @@ void GitEditorWidget::revertChange()
sourceWorkingDirectory(), m_currentChange); sourceWorkingDirectory(), m_currentChange);
} }
void GitEditorWidget::logChange()
{
GitPlugin::instance()->gitClient()->log(
sourceWorkingDirectory(), QString(), false, QStringList(m_currentChange));
}
void GitEditorWidget::applyDiffChunk(const DiffChunk& chunk, bool revert) void GitEditorWidget::applyDiffChunk(const DiffChunk& chunk, bool revert)
{ {
QTemporaryFile patchFile; QTemporaryFile patchFile;
@@ -349,6 +355,7 @@ void GitEditorWidget::addChangeActions(QMenu *menu, const QString &change)
menu->addAction(tr("Cherr&y-Pick Change %1").arg(change), this, SLOT(cherryPickChange())); menu->addAction(tr("Cherr&y-Pick Change %1").arg(change), this, SLOT(cherryPickChange()));
menu->addAction(tr("Re&vert Change %1").arg(change), this, SLOT(revertChange())); menu->addAction(tr("Re&vert Change %1").arg(change), this, SLOT(revertChange()));
menu->addAction(tr("C&heckout Change %1").arg(change), this, SLOT(checkoutChange())); menu->addAction(tr("C&heckout Change %1").arg(change), this, SLOT(checkoutChange()));
menu->addAction(tr("&Log for Change %1").arg(change), this, SLOT(logChange()));
QMenu *resetMenu = new QMenu(tr("&Reset to Change %1").arg(change), menu); QMenu *resetMenu = new QMenu(tr("&Reset to Change %1").arg(change), menu);
connect(resetMenu->addAction(tr("&Hard")), &QAction::triggered, connect(resetMenu->addAction(tr("&Hard")), &QAction::triggered,
this, [this]() { resetChange("hard"); }); this, [this]() { resetChange("hard"); });

View File

@@ -58,6 +58,7 @@ private slots:
void checkoutChange(); void checkoutChange();
void cherryPickChange(); void cherryPickChange();
void revertChange(); void revertChange();
void logChange();
void applyDiffChunk(const VcsBase::DiffChunk& chunk, bool revert); void applyDiffChunk(const VcsBase::DiffChunk& chunk, bool revert);
private: private: