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/pathchooser.h>
|
||||||
#include <utils/theme/theme.h>
|
#include <utils/theme/theme.h>
|
||||||
|
#include <vcsbase/vcscommand.h>
|
||||||
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QFormLayout>
|
#include <QFormLayout>
|
||||||
@@ -212,18 +213,19 @@ void ChangeSelectionDialog::recalculateCompletion()
|
|||||||
if (workingDir == m_oldWorkingDir)
|
if (workingDir == m_oldWorkingDir)
|
||||||
return;
|
return;
|
||||||
m_oldWorkingDir = workingDir;
|
m_oldWorkingDir = workingDir;
|
||||||
|
m_changeModel->setStringList(QStringList());
|
||||||
|
|
||||||
|
if (workingDir.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
if (!workingDir.isEmpty()) {
|
|
||||||
GitClient *client = GitPlugin::client();
|
GitClient *client = GitPlugin::client();
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args << QLatin1String("--format=%(refname:short)");
|
args << QLatin1String("--format=%(refname:short)");
|
||||||
QString output;
|
VcsBase::VcsCommand *command = client->asyncForEachRefCmd(workingDir, args);
|
||||||
if (client->synchronousForEachRefCmd(workingDir, args, &output)) {
|
connect(this, &QObject::destroyed, command, &VcsBase::VcsCommand::abort);
|
||||||
|
connect(command, &VcsBase::VcsCommand::stdOutText, [this](const QString &output) {
|
||||||
m_changeModel->setStringList(output.split(QLatin1Char('\n')));
|
m_changeModel->setStringList(output.split(QLatin1Char('\n')));
|
||||||
return;
|
});
|
||||||
}
|
|
||||||
}
|
|
||||||
m_changeModel->setStringList(QStringList());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangeSelectionDialog::recalculateDetails()
|
void ChangeSelectionDialog::recalculateDetails()
|
||||||
|
@@ -1681,6 +1681,12 @@ bool GitClient::synchronousForEachRefCmd(const QString &workingDirectory, QStrin
|
|||||||
return rc;
|
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,
|
bool GitClient::synchronousRemoteCmd(const QString &workingDirectory, QStringList remoteArgs,
|
||||||
QString *output, QString *errorMessage, bool silent) const
|
QString *output, QString *errorMessage, bool silent) const
|
||||||
{
|
{
|
||||||
|
@@ -207,6 +207,7 @@ public:
|
|||||||
QString *output, QString *errorMessage) const;
|
QString *output, QString *errorMessage) const;
|
||||||
bool synchronousForEachRefCmd(const QString &workingDirectory, QStringList args,
|
bool synchronousForEachRefCmd(const QString &workingDirectory, QStringList args,
|
||||||
QString *output, QString *errorMessage = 0) const;
|
QString *output, QString *errorMessage = 0) const;
|
||||||
|
VcsBase::VcsCommand *asyncForEachRefCmd(const QString &workingDirectory, QStringList args) const;
|
||||||
bool synchronousRemoteCmd(const QString &workingDirectory, QStringList remoteArgs,
|
bool synchronousRemoteCmd(const QString &workingDirectory, QStringList remoteArgs,
|
||||||
QString *output = 0, QString *errorMessage = 0, bool silent = false) const;
|
QString *output = 0, QString *errorMessage = 0, bool silent = false) const;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user