Git: Add on-demand branches expanding

Make "branches expanding" on demand and asynchronous.
After "git show" there is clickable text: "Branches: <Expand>" in
description. If user clicks this text then branches for commit is
triggered and done asynchronously.

Task-number: QTCREATORBUG-11293
Done-with: Przemyslaw Gorszkowski <pgorszkowski@gmail.com>
Change-Id: I772cfef823d3f95e2b3060dfb5973157d81fc11a
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
Orgad Shaneh
2014-06-24 10:53:03 +03:00
committed by Orgad Shaneh
parent 281aa9e0d6
commit d6583f0f47
6 changed files with 148 additions and 17 deletions

View File

@@ -1139,6 +1139,10 @@ void GitClient::show(const QString &source, const QString &id, const QString &na
DiffEditor::DiffEditorManager::find(documentId);
if (!diffEditorDocument) {
diffEditorDocument = createDiffEditor(documentId, source, title);
connect(diffEditorDocument->controller(), SIGNAL(expandBranchesRequested(QString)),
this, SLOT(branchesForCommit(QString)));
diffEditorDocument->controller()->setDescriptionEnabled(true);
GitDiffEditorReloader *reloader =
@@ -1738,23 +1742,25 @@ void GitClient::synchronousTagsForCommit(const QString &workingDirectory, const
}
}
QStringList GitClient::synchronousBranchesForCommit(const QString &workingDirectory, const QString &revision)
void GitClient::branchesForCommit(const QString &revision)
{
QByteArray outputData;
QString output;
QStringList arguments;
arguments << QLatin1String("branch") << QLatin1String(noColorOption)
<< QLatin1String("-a") << QLatin1String("--contains") << revision;
fullySynchronousGit(workingDirectory, arguments, &outputData, 0,
VcsBasePlugin::SuppressCommandLogging);
output = commandOutputFromLocal8Bit(outputData);
QStringList res;
foreach (const QString &branch, output.split(QLatin1Char('\n'))) {
const QString b = branch.mid(2).trimmed();
if (!b.isEmpty())
res << b;
}
return res;
DiffEditor::DiffEditorController *editorController
= qobject_cast<DiffEditor::DiffEditorController *>(sender());
QString workingDirectory = editorController->workingDirectory();
VcsBase::Command *command = new VcsBase::Command(gitBinaryPath(), workingDirectory,
processEnvironment());
command->setCodec(getSourceCodec(currentDocumentPath()));
connect(command, SIGNAL(output(QString)), editorController,
SLOT(branchesForCommitReceived(QString)));
command->addJob(arguments, -1);
command->execute();
command->setCookie(workingDirectory);
}
bool GitClient::isRemoteCommit(const QString &workingDirectory, const QString &commit)