forked from qt-creator/qt-creator
GitClient: Replace describe command with QtcProcess
There is no need to use VcsCommand when NoOutput is passed. Get rid of execBgCommand(). Change-Id: I58354e99ddc0c4049325560022ba6e755092b817 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -455,7 +455,7 @@ private:
|
|||||||
QString m_body;
|
QString m_body;
|
||||||
QString m_precedes;
|
QString m_precedes;
|
||||||
std::vector<QString> m_follows;
|
std::vector<QString> m_follows;
|
||||||
QList<QPointer<VcsCommand>> m_commands;
|
QList<QtcProcess *> m_commands;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ShowController::processCommandOutput(const QString &output)
|
void ShowController::processCommandOutput(const QString &output)
|
||||||
@@ -489,28 +489,42 @@ void ShowController::processDescription(const QString &output)
|
|||||||
m_follows.push_back(m_precedes);
|
m_follows.push_back(m_precedes);
|
||||||
updateDescription();
|
updateDescription();
|
||||||
const QString commit = modText.mid(7, 8);
|
const QString commit = modText.mid(7, 8);
|
||||||
m_commands.append(m_instance->execBgCommand(
|
|
||||||
workingDirectory(), {"describe", "--contains", commit},
|
QtcProcess *precedesProcess = new QtcProcess(this);
|
||||||
[this](const QString &text) {
|
m_commands.append(precedesProcess);
|
||||||
m_precedes = text.trimmed();
|
precedesProcess->setEnvironment(m_instance->processEnvironment());
|
||||||
|
precedesProcess->setCommand({m_instance->vcsBinary(), {"describe", "--contains", commit}});
|
||||||
|
precedesProcess->setWorkingDirectory(workingDirectory());
|
||||||
|
connect(precedesProcess, &QtcProcess::done, this, [this, precedesProcess] {
|
||||||
|
m_precedes = precedesProcess->result() == ProcessResult::FinishedWithSuccess
|
||||||
|
? precedesProcess->cleanedStdOut().trimmed() : QString();
|
||||||
const int tilde = m_precedes.indexOf('~');
|
const int tilde = m_precedes.indexOf('~');
|
||||||
if (tilde != -1)
|
if (tilde != -1)
|
||||||
m_precedes.truncate(tilde);
|
m_precedes.truncate(tilde);
|
||||||
if (m_precedes.endsWith("^0"))
|
if (m_precedes.endsWith("^0"))
|
||||||
m_precedes.chop(2);
|
m_precedes.chop(2);
|
||||||
updateDescription();
|
updateDescription();
|
||||||
}));
|
});
|
||||||
|
precedesProcess->start();
|
||||||
|
|
||||||
QStringList parents;
|
QStringList parents;
|
||||||
QString errorMessage;
|
QString errorMessage;
|
||||||
m_instance->synchronousParentRevisions(workingDirectory(), commit, &parents, &errorMessage);
|
m_instance->synchronousParentRevisions(workingDirectory(), commit, &parents, &errorMessage);
|
||||||
m_follows.resize(parents.size());
|
m_follows.resize(parents.size());
|
||||||
for (int i = 0, total = parents.size(); i < total; ++i) {
|
for (int i = 0, total = parents.size(); i < total; ++i) {
|
||||||
m_commands.append(m_instance->execBgCommand(
|
QtcProcess *followsProcess = new QtcProcess(this);
|
||||||
workingDirectory(), {"describe", "--tags", "--abbrev=0", parents[i]},
|
m_commands.append(followsProcess);
|
||||||
[this, i](const QString &text) {
|
followsProcess->setEnvironment(m_instance->processEnvironment());
|
||||||
m_follows[i] = text.trimmed();
|
followsProcess->setCommand({m_instance->vcsBinary(),
|
||||||
|
{"describe", "--tags", "--abbrev=0", parents[i]}});
|
||||||
|
followsProcess->setWorkingDirectory(workingDirectory());
|
||||||
|
connect(followsProcess, &QtcProcess::done, this, [this, followsProcess, i] {
|
||||||
|
if (followsProcess->result() != ProcessResult::FinishedWithSuccess)
|
||||||
|
return;
|
||||||
|
m_follows[i] = followsProcess->cleanedStdOut().trimmed();
|
||||||
updateDescription();
|
updateDescription();
|
||||||
}));
|
});
|
||||||
|
followsProcess->start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -533,10 +547,7 @@ void ShowController::updateDescription()
|
|||||||
|
|
||||||
void ShowController::abortCommands()
|
void ShowController::abortCommands()
|
||||||
{
|
{
|
||||||
for (QPointer<VcsCommand> command : m_commands) {
|
qDeleteAll(m_commands);
|
||||||
if (command)
|
|
||||||
command->abort();
|
|
||||||
}
|
|
||||||
m_commands.clear();
|
m_commands.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -87,19 +87,6 @@ VcsCommand *VcsBaseClientImpl::createCommand(const FilePath &workingDirectory,
|
|||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
VcsCommand *VcsBaseClientImpl::execBgCommand(const FilePath &workingDirectory,
|
|
||||||
const QStringList &args,
|
|
||||||
const std::function<void (const QString &)> &outputCallback,
|
|
||||||
unsigned flags) const
|
|
||||||
{
|
|
||||||
VcsCommand *cmd = createCommand(workingDirectory);
|
|
||||||
cmd->addFlags(flags | VcsCommand::NoOutput);
|
|
||||||
cmd->addJob({vcsBinary(), args}, vcsTimeoutS());
|
|
||||||
connect(cmd, &VcsCommand::stdOutText, this, outputCallback);
|
|
||||||
cmd->execute();
|
|
||||||
return cmd;
|
|
||||||
}
|
|
||||||
|
|
||||||
void VcsBaseClientImpl::enqueueJob(VcsCommand *cmd, const QStringList &args,
|
void VcsBaseClientImpl::enqueueJob(VcsCommand *cmd, const QStringList &args,
|
||||||
const ExitCodeInterpreter &interpreter) const
|
const ExitCodeInterpreter &interpreter) const
|
||||||
{
|
{
|
||||||
|
@@ -59,11 +59,6 @@ public:
|
|||||||
VcsBaseEditorWidget *editor = nullptr,
|
VcsBaseEditorWidget *editor = nullptr,
|
||||||
JobOutputBindMode mode = NoOutputBind) const;
|
JobOutputBindMode mode = NoOutputBind) const;
|
||||||
|
|
||||||
VcsCommand *execBgCommand(const Utils::FilePath &workingDirectory,
|
|
||||||
const QStringList &args,
|
|
||||||
const std::function<void (const QString &)> &outputCallback,
|
|
||||||
unsigned flags = 0) const;
|
|
||||||
|
|
||||||
void enqueueJob(VcsCommand *cmd, const QStringList &args,
|
void enqueueJob(VcsCommand *cmd, const QStringList &args,
|
||||||
const Utils::ExitCodeInterpreter &interpreter = {}) const;
|
const Utils::ExitCodeInterpreter &interpreter = {}) const;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user