forked from qt-creator/qt-creator
Git: Fetch completion refs asynchronously
For repositories with many refs the dialog takes a few seconds to open. Change-Id: I82154ad8a77cc304db941f9d41e36e32aa7043cd Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
05966ab153
commit
61d94c5ccd
@@ -33,6 +33,7 @@
|
||||
|
||||
#include <utils/pathchooser.h>
|
||||
#include <utils/theme/theme.h>
|
||||
#include <vcsbase/vcscommand.h>
|
||||
|
||||
#include <QProcess>
|
||||
#include <QFormLayout>
|
||||
@@ -212,18 +213,19 @@ void ChangeSelectionDialog::recalculateCompletion()
|
||||
if (workingDir == m_oldWorkingDir)
|
||||
return;
|
||||
m_oldWorkingDir = workingDir;
|
||||
|
||||
if (!workingDir.isEmpty()) {
|
||||
GitClient *client = GitPlugin::client();
|
||||
QStringList args;
|
||||
args << QLatin1String("--format=%(refname:short)");
|
||||
QString output;
|
||||
if (client->synchronousForEachRefCmd(workingDir, args, &output)) {
|
||||
m_changeModel->setStringList(output.split(QLatin1Char('\n')));
|
||||
return;
|
||||
}
|
||||
}
|
||||
m_changeModel->setStringList(QStringList());
|
||||
|
||||
if (workingDir.isEmpty())
|
||||
return;
|
||||
|
||||
GitClient *client = GitPlugin::client();
|
||||
QStringList args;
|
||||
args << QLatin1String("--format=%(refname:short)");
|
||||
VcsBase::VcsCommand *command = client->asyncForEachRefCmd(workingDir, args);
|
||||
connect(this, &QObject::destroyed, command, &VcsBase::VcsCommand::abort);
|
||||
connect(command, &VcsBase::VcsCommand::stdOutText, [this](const QString &output) {
|
||||
m_changeModel->setStringList(output.split(QLatin1Char('\n')));
|
||||
});
|
||||
}
|
||||
|
||||
void ChangeSelectionDialog::recalculateDetails()
|
||||
|
@@ -1681,6 +1681,12 @@ bool GitClient::synchronousForEachRefCmd(const QString &workingDirectory, QStrin
|
||||
return rc;
|
||||
}
|
||||
|
||||
VcsCommand *GitClient::asyncForEachRefCmd(const QString &workingDirectory, QStringList args) const
|
||||
{
|
||||
args.push_front(QLatin1String("for-each-ref"));
|
||||
return vcsExec(workingDirectory, args, 0, false, silentFlags);
|
||||
}
|
||||
|
||||
bool GitClient::synchronousRemoteCmd(const QString &workingDirectory, QStringList remoteArgs,
|
||||
QString *output, QString *errorMessage, bool silent) const
|
||||
{
|
||||
|
@@ -207,6 +207,7 @@ public:
|
||||
QString *output, QString *errorMessage) const;
|
||||
bool synchronousForEachRefCmd(const QString &workingDirectory, QStringList args,
|
||||
QString *output, QString *errorMessage = 0) const;
|
||||
VcsBase::VcsCommand *asyncForEachRefCmd(const QString &workingDirectory, QStringList args) const;
|
||||
bool synchronousRemoteCmd(const QString &workingDirectory, QStringList remoteArgs,
|
||||
QString *output = 0, QString *errorMessage = 0, bool silent = false) const;
|
||||
|
||||
|
Reference in New Issue
Block a user