forked from qt-creator/qt-creator
GitClient: Replace rev-list command with QtcProcess
There is no need to use VcsCommand when NoOutput is passed. Get rid of asyncUpstreamStatus(). Change-Id: Iae6869be9640c7662545906d28314ac47cd69e3d Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -8,8 +8,10 @@
|
||||
#include <vcsbase/vcscommand.h>
|
||||
#include <vcsbase/vcsoutputwindow.h>
|
||||
|
||||
#include <utils/environment.h>
|
||||
#include <utils/filesystemwatcher.h>
|
||||
#include <utils/qtcassert.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
#include <utils/stringutils.h>
|
||||
|
||||
#include <QDateTime>
|
||||
@@ -886,9 +888,17 @@ void BranchModel::updateUpstreamStatus(BranchNode *node)
|
||||
{
|
||||
if (node->tracking.isEmpty())
|
||||
return;
|
||||
VcsCommand *command = d->client->asyncUpstreamStatus(
|
||||
d->workingDirectory, node->fullRef(), node->tracking);
|
||||
QObject::connect(command, &VcsCommand::stdOutText, node, [this, node](const QString &text) {
|
||||
|
||||
QtcProcess *process = new QtcProcess(node);
|
||||
process->setEnvironment(d->client->processEnvironment());
|
||||
process->setCommand({d->client->vcsBinary(), {"rev-list", "--no-color", "--left-right",
|
||||
"--count", node->fullRef() + "..." + node->tracking}});
|
||||
process->setWorkingDirectory(d->workingDirectory);
|
||||
connect(process, &QtcProcess::done, this, [this, process, node] {
|
||||
process->deleteLater();
|
||||
if (process->result() != ProcessResult::FinishedWithSuccess)
|
||||
return;
|
||||
const QString text = process->cleanedStdOut();
|
||||
if (text.isEmpty())
|
||||
return;
|
||||
const QStringList split = text.trimmed().split('\t');
|
||||
@@ -898,6 +908,7 @@ void BranchModel::updateUpstreamStatus(BranchNode *node)
|
||||
const QModelIndex idx = nodeToIndex(node, ColumnBranch);
|
||||
emit dataChanged(idx, idx);
|
||||
});
|
||||
process->start();
|
||||
}
|
||||
|
||||
QString BranchModel::toolTip(const QString &sha) const
|
||||
|
@@ -3166,15 +3166,6 @@ bool GitClient::synchronousSetTrackingBranch(const FilePath &workingDirectory,
|
||||
return result.result() == ProcessResult::FinishedWithSuccess;
|
||||
}
|
||||
|
||||
VcsCommand *GitClient::asyncUpstreamStatus(const FilePath &workingDirectory,
|
||||
const QString &branch,
|
||||
const QString &upstream)
|
||||
{
|
||||
const QStringList args {"rev-list", noColorOption, "--left-right", "--count",
|
||||
branch + "..." + upstream};
|
||||
return vcsExec(workingDirectory, args, nullptr, false, VcsCommand::NoOutput);
|
||||
}
|
||||
|
||||
void GitClient::handleMergeConflicts(const FilePath &workingDir, const QString &commit,
|
||||
const QStringList &files, const QString &abortCommand)
|
||||
{
|
||||
|
@@ -332,9 +332,6 @@ public:
|
||||
void show(const QString &source, const QString &id, const QString &name = {});
|
||||
void archive(const Utils::FilePath &workingDirectory, QString commit);
|
||||
|
||||
VcsBase::VcsCommand *asyncUpstreamStatus(const Utils::FilePath &workingDirectory,
|
||||
const QString &branch, const QString &upstream);
|
||||
|
||||
enum class BranchTargetType { Remote, Commit };
|
||||
static QString suggestedLocalBranchName(
|
||||
const Utils::FilePath &workingDirectory, const QStringList &existingLocalNames,
|
||||
|
Reference in New Issue
Block a user