forked from qt-creator/qt-creator
VcsBase: Don't return editor from annotate()
Take int firstLine as last arg instead. Switch the order of 3rd and 4th args as most callers provide lineNumber and don't provide revision. Change-Id: Iab60c1068a4d9829d10219af39bf3dcbf51e37bb Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -1291,27 +1291,24 @@ void GitClient::archive(const FilePath &workingDirectory, QString commit)
|
||||
RunFlags::ShowStdOut);
|
||||
}
|
||||
|
||||
VcsBaseEditorWidget *GitClient::annotate(
|
||||
const FilePath &workingDir, const QString &file, const QString &revision,
|
||||
int lineNumber, const QStringList &extraOptions)
|
||||
void GitClient::annotate(const Utils::FilePath &workingDir, const QString &file, int lineNumber,
|
||||
const QString &revision, const QStringList &extraOptions, int firstLine)
|
||||
{
|
||||
const Id editorId = Git::Constants::GIT_BLAME_EDITOR_ID;
|
||||
const QString id = VcsBaseEditor::getTitleId(workingDir, {file}, revision);
|
||||
const QString title = Tr::tr("Git Blame \"%1\"").arg(id);
|
||||
const QString sourceFile = VcsBaseEditor::getSource(workingDir, file);
|
||||
|
||||
VcsBaseEditorWidget *editor
|
||||
= createVcsEditor(editorId, title, sourceFile, codecFor(CodecSource, FilePath::fromString(sourceFile)),
|
||||
"blameFileName", id);
|
||||
VcsBaseEditorWidget *editor = createVcsEditor(editorId, title, sourceFile,
|
||||
codecFor(CodecSource, FilePath::fromString(sourceFile)), "blameFileName", id);
|
||||
VcsBaseEditorConfig *argWidget = editor->editorConfig();
|
||||
if (!argWidget) {
|
||||
argWidget = new GitBlameArgumentsWidget(settings(), editor->toolBar());
|
||||
argWidget->setBaseArguments(extraOptions);
|
||||
connect(argWidget, &VcsBaseEditorConfig::commandExecutionRequested, this,
|
||||
[=] {
|
||||
const int line = VcsBaseEditor::lineNumberOfCurrentEditor();
|
||||
annotate(workingDir, file, revision, line, extraOptions);
|
||||
} );
|
||||
connect(argWidget, &VcsBaseEditorConfig::commandExecutionRequested, this, [=] {
|
||||
const int line = VcsBaseEditor::lineNumberOfCurrentEditor();
|
||||
annotate(workingDir, file, line, revision, extraOptions);
|
||||
});
|
||||
editor->setEditorConfig(argWidget);
|
||||
}
|
||||
|
||||
@@ -1322,8 +1319,9 @@ VcsBaseEditorWidget *GitClient::annotate(
|
||||
arguments << revision;
|
||||
arguments << "--" << file;
|
||||
editor->setDefaultLineNumber(lineNumber);
|
||||
if (firstLine > 0)
|
||||
editor->setFirstLineNumber(firstLine);
|
||||
vcsExecWithEditor(workingDir, arguments, editor);
|
||||
return editor;
|
||||
}
|
||||
|
||||
void GitClient::checkout(const FilePath &workingDirectory, const QString &ref, StashMode stashMode,
|
||||
|
||||
@@ -152,9 +152,9 @@ public:
|
||||
void log(const Utils::FilePath &workingDirectory, const QString &fileName = {},
|
||||
bool enableAnnotationContextMenu = false, const QStringList &args = {});
|
||||
void reflog(const Utils::FilePath &workingDirectory, const QString &branch = {});
|
||||
VcsBase::VcsBaseEditorWidget *annotate(const Utils::FilePath &workingDir, const QString &file,
|
||||
const QString &revision = {}, int lineNumber = -1,
|
||||
const QStringList &extraOptions = {}) override;
|
||||
void annotate(const Utils::FilePath &workingDir, const QString &file,
|
||||
int lineNumber = -1, const QString &revision = {},
|
||||
const QStringList &extraOptions = {}, int firstLine = -1) override;
|
||||
void reset(const Utils::FilePath &workingDirectory, const QString &argument, const QString &commit = {});
|
||||
void removeStaleRemoteBranches(const Utils::FilePath &workingDirectory, const QString &remote);
|
||||
void recoverDeletedFiles(const Utils::FilePath &workingDirectory);
|
||||
|
||||
@@ -1133,11 +1133,8 @@ void GitPluginPrivate::blameFile()
|
||||
const FilePath fileName = FilePath::fromString(state.currentFile()).canonicalPath();
|
||||
FilePath topLevel;
|
||||
VcsManager::findVersionControlForDirectory(fileName.parentDir(), &topLevel);
|
||||
VcsBaseEditorWidget *editor = m_gitClient.annotate(
|
||||
topLevel, fileName.relativeChildPath(topLevel).toString(),
|
||||
{}, lineNumber, extraOptions);
|
||||
if (firstLine > 0)
|
||||
editor->setFirstLineNumber(firstLine);
|
||||
m_gitClient.annotate(topLevel, fileName.relativeChildPath(topLevel).toString(),
|
||||
lineNumber, {}, extraOptions, firstLine);
|
||||
}
|
||||
|
||||
void GitPluginPrivate::logProject()
|
||||
@@ -2126,7 +2123,7 @@ FilePaths GitPluginPrivate::unmanagedFiles(const FilePaths &filePaths) const
|
||||
|
||||
void GitPluginPrivate::vcsAnnotate(const FilePath &filePath, int line)
|
||||
{
|
||||
m_gitClient.annotate(filePath.absolutePath(), filePath.fileName(), {}, line);
|
||||
m_gitClient.annotate(filePath.absolutePath(), filePath.fileName(), line);
|
||||
}
|
||||
|
||||
void GitPlugin::emitFilesChanged(const QStringList &l)
|
||||
|
||||
Reference in New Issue
Block a user