Commit a55fb4a3 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Vcs: Move annotate and annotateRevisionRequested into VcsBaseClientImpl



... and use that in the Git client.

Change-Id: Ie70ec0d5908776d11eb69613d45f565d4f0ce32b
Reviewed-by: default avatarOrgad Shaneh <orgads@gmail.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent ed513689
......@@ -955,51 +955,37 @@ void GitClient::show(const QString &source, const QString &id, const QString &na
});
}
void GitClient::annotateRevisionRequested(const QString &workingDirectory, const QString &file,
const QString &change, int lineNumber)
{
QString sha1 = change;
// This might be invoked with a verbose revision description
// "SHA1 author subject" from the annotation context menu. Strip the rest.
const int blankPos = sha1.indexOf(QLatin1Char(' '));
if (blankPos != -1)
sha1.truncate(blankPos);
blame(workingDirectory, QStringList(), file, sha1, lineNumber);
}
void GitClient::blame(const QString &workingDirectory,
const QStringList &args,
const QString &fileName,
const QString &revision,
int lineNumber)
void GitClient::annotate(const QString &workingDir, const QString &file, const QString &revision,
int lineNumber, const QStringList &extraOptions)
{
const Id editorId = Git::Constants::GIT_BLAME_EDITOR_ID;
const QString id = VcsBaseEditor::getTitleId(workingDirectory, QStringList(fileName), revision);
const QString id = VcsBaseEditor::getTitleId(workingDir, QStringList(file), revision);
const QString title = tr("Git Blame \"%1\"").arg(id);
const QString sourceFile = VcsBaseEditor::getSource(workingDirectory, fileName);
const QString sourceFile = VcsBaseEditor::getSource(workingDir, file);
VcsBaseEditorWidget *editor = findExistingVCSEditor("blameFileName", id);
if (!editor) {
auto *argWidget = new GitBlameArgumentsWidget(settings());
argWidget->setBaseArguments(args);
argWidget->setBaseArguments(extraOptions);
connect(argWidget, &VcsBaseEditorParameterWidget::commandExecutionRequested,
[=] {
const int line = VcsBaseEditor::lineNumberOfCurrentEditor();
blame(workingDirectory, args, fileName, revision, line);
annotate(workingDir, file, revision, line, extraOptions);
} );
editor = createVcsEditor(editorId, title, sourceFile, codecFor(CodecSource, sourceFile),
"blameFileName", id);
editor->setConfigurationWidget(argWidget);
}
editor->setWorkingDirectory(workingDirectory);
editor->setWorkingDirectory(workingDir);
QStringList arguments(QLatin1String("blame"));
arguments << QLatin1String("--root");
arguments.append(editor->configurationWidget()->arguments());
arguments << QLatin1String("--") << fileName;
arguments.append(extraOptions);
arguments << QLatin1String("--") << file;
if (!revision.isEmpty())
arguments << revision;
executeGit(workingDirectory, arguments, editor, false, 0, lineNumber);
executeGit(workingDir, arguments, editor, false, 0, lineNumber);
}
bool GitClient::synchronousCheckout(const QString &workingDirectory,
......
......@@ -162,8 +162,9 @@ public:
void log(const QString &workingDirectory, const QString &fileName = QString(),
bool enableAnnotationContextMenu = false, const QStringList &args = QStringList());
void reflog(const QString &workingDirectory);
void blame(const QString &workingDirectory, const QStringList &args, const QString &fileName,
const QString &revision = QString(), int lineNumber = -1);
void annotate(const QString &workingDir, const QString &file,
const QString &revision = QString(), int lineNumber = -1,
const QStringList &extraOptions = QStringList()) override;
void reset(const QString &workingDirectory, const QString &argument, const QString &commit = QString());
void addFile(const QString &workingDirectory, const QString &fileName);
bool synchronousLog(const QString &workingDirectory,
......@@ -357,9 +358,6 @@ private slots:
void branchesForCommit(const QString &revision);
private:
void annotateRevisionRequested(const QString &workingDirectory, const QString &file,
const QString &change, int lineNumber) override;
void stage(const QString &patch, bool revert);
VcsBase::VcsBaseEditorWidget *findExistingVCSEditor(const char *registerDynamicProperty,
const QString &dynamicPropertyValue) const;
......
......@@ -715,7 +715,7 @@ void GitPlugin::blameFile()
const VcsBasePluginState state = currentState();
QTC_ASSERT(state.hasFile(), return);
const int lineNumber = VcsBaseEditor::lineNumberOfCurrentEditor(state.currentFile());
m_gitClient->blame(state.currentFileTopLevel(), QStringList(), state.relativeCurrentFile(), QString(), lineNumber);
m_gitClient->annotate(state.currentFileTopLevel(), state.relativeCurrentFile(), QString(), lineNumber);
}
void GitPlugin::logProject()
......
......@@ -164,7 +164,7 @@ bool GitVersionControl::managesFile(const QString &workingDirectory, const QStri
bool GitVersionControl::vcsAnnotate(const QString &file, int line)
{
const QFileInfo fi(file);
m_client->blame(fi.absolutePath(), QStringList(), fi.fileName(), QString(), line);
m_client->annotate(fi.absolutePath(), fi.fileName(), QString(), line);
return true;
}
......
......@@ -175,6 +175,19 @@ void VcsBaseClientImpl::resetCachedVcsInfo(const QString &workingDir)
Core::VcsManager::resetVersionControlForDirectory(workingDir);
}
void VcsBaseClientImpl::annotateRevisionRequested(const QString &workingDirectory,
const QString &file, const QString &change,
int line)
{
QString changeCopy = change;
// This might be invoked with a verbose revision description
// "SHA1 author subject" from the annotation context menu. Strip the rest.
const int blankPos = changeCopy.indexOf(QLatin1Char(' '));
if (blankPos != -1)
changeCopy.truncate(blankPos);
annotate(workingDirectory, file, changeCopy, line);
}
int VcsBaseClientImpl::vcsTimeout() const
{
return settings().intValue(VcsBaseClientSettings::timeoutKey);
......@@ -650,19 +663,6 @@ void VcsBaseClient::statusParser(const QString &text)
emit parsedStatus(lineInfoList);
}
void VcsBaseClient::annotateRevisionRequested(const QString &workingDirectory,
const QString &file, const QString &change,
int line)
{
QString changeCopy = change;
// This might be invoked with a verbose revision description
// "SHA1 author subject" from the annotation context menu. Strip the rest.
const int blankPos = changeCopy.indexOf(QLatin1Char(' '));
if (blankPos != -1)
changeCopy.truncate(blankPos);
annotate(workingDirectory, file, changeCopy, line);
}
} // namespace VcsBase
#include "moc_vcsbaseclient.cpp"
......@@ -95,10 +95,15 @@ public:
virtual QProcessEnvironment processEnvironment() const;
// VCS functionality:
virtual void annotate(const QString &workingDir, const QString &file,
const QString &revision = QString(), int lineNumber = -1,
const QStringList &extraOptions = QStringList()) = 0;
protected:
void resetCachedVcsInfo(const QString &workingDir);
virtual void annotateRevisionRequested(const QString &workingDirectory, const QString &file,
const QString &change, int line) = 0;
const QString &change, int line);
private:
void saveSettings();
......@@ -179,9 +184,6 @@ public slots:
const QStringList &extraOptions = QStringList());
protected:
void annotateRevisionRequested(const QString &workingDirectory, const QString &file,
const QString &change, int line);
enum VcsCommandTag
{
CreateRepositoryCommand,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment