diff --git a/src/plugins/git/branchmodel.cpp b/src/plugins/git/branchmodel.cpp index 3bae1a991f6..b7b1355cf4e 100644 --- a/src/plugins/git/branchmodel.cpp +++ b/src/plugins/git/branchmodel.cpp @@ -416,7 +416,7 @@ void BranchModel::refresh(const FilePath &workingDirectory, ShowError showError) d->currentDateTime = dateTime; }); - const auto setupForEachRef = [this, workingDirectory](Process &process) { + const auto onForEachRefSetup = [this, workingDirectory](Process &process) { d->workingDirectory = workingDirectory; QStringList args = {"for-each-ref", "--format=%(objectname)\t%(refname)\t%(upstream:short)\t" @@ -428,7 +428,18 @@ void BranchModel::refresh(const FilePath &workingDirectory, ShowError showError) gitClient().setupCommand(process, workingDirectory, args); }; - const auto forEachRefDone = [this](const Process &process) { + const auto onForEachRefDone = [this, workingDirectory, showError](const Process &process, + bool success) { + if (!success) { + if (showError == ShowError::No) + return; + const QString message = Tr::tr("Cannot run \"%1\" in \"%2\": %3") + .arg("git for-each-ref") + .arg(workingDirectory.toUserOutput()) + .arg(process.cleanedStdErr()); + VcsBase::VcsOutputWindow::appendError(message); + return; + } const QString output = process.stdOut(); const QStringList lines = output.split('\n'); for (const QString &l : lines) @@ -449,16 +460,6 @@ void BranchModel::refresh(const FilePath &workingDirectory, ShowError showError) } }; - const auto forEachRefError = [workingDirectory, showError](const Process &process) { - if (showError == ShowError::No) - return; - const QString message = Tr::tr("Cannot run \"%1\" in \"%2\": %3") - .arg("git for-each-ref") - .arg(workingDirectory.toUserOutput()) - .arg(process.cleanedStdErr()); - VcsBase::VcsOutputWindow::appendError(message); - }; - const auto finalize = [this] { endResetModel(); d->refreshTask.release()->deleteLater(); @@ -466,7 +467,7 @@ void BranchModel::refresh(const FilePath &workingDirectory, ShowError showError) const Group root { topRevisionProc, - ProcessTask(setupForEachRef, forEachRefDone, forEachRefError), + ProcessTask(onForEachRefSetup, onForEachRefDone), onGroupDone(finalize), onGroupError(finalize) }; diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index f05b66cfc10..91adbfad075 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -391,7 +391,7 @@ ShowController::ShowController(IDocument *document, const QString &id) setDescription(desc); }; - const auto setupDescription = [this, id](Process &process) { + const auto onDescriptionSetup = [this, id](Process &process) { process.setCodec(gitClient().encoding(GitClient::EncodingCommit, workingDirectory())); setupCommand(process, {"show", "-s", noColorOption, showFormatC, id}); VcsOutputWindow::appendCommand(process.workingDirectory(), process.commandLine()); @@ -418,72 +418,68 @@ ShowController::ShowController(IDocument *document, const QString &id) return SetupResult::Continue; }; - const auto setupBranches = [this, storage](Process &process) { + const auto onBranchesSetup = [this, storage](Process &process) { storage->m_branches = busyMessage; setupCommand(process, {"branch", noColorOption, "-a", "--contains", storage->m_commit}); VcsOutputWindow::appendCommand(process.workingDirectory(), process.commandLine()); }; - const auto onBranchesDone = [storage, updateDescription](const Process &process) { + const auto onBranchesDone = [storage, updateDescription](const Process &process, bool success) { ReloadStorage *data = storage.activeStorage(); data->m_branches.clear(); - const QString remotePrefix = "remotes/"; - const QString localPrefix = ""; - const int prefixLength = remotePrefix.length(); - QStringList branches; - QString previousRemote = localPrefix; - bool first = true; - const QStringList branchList = process.cleanedStdOut().split('\n'); - for (const QString &branch : branchList) { - const QString b = branch.mid(2).trimmed(); - if (b.isEmpty()) - continue; - if (b.startsWith(remotePrefix)) { - const int nextSlash = b.indexOf('/', prefixLength); - if (nextSlash < 0) + if (success) { + const QString remotePrefix = "remotes/"; + const QString localPrefix = ""; + const int prefixLength = remotePrefix.length(); + QStringList branches; + QString previousRemote = localPrefix; + bool first = true; + const QStringList branchList = process.cleanedStdOut().split('\n'); + for (const QString &branch : branchList) { + const QString b = branch.mid(2).trimmed(); + if (b.isEmpty()) continue; - const QString remote = b.mid(prefixLength, nextSlash - prefixLength); - if (remote != previousRemote) { - data->m_branches += branchesDisplay(previousRemote, &branches, &first) + '\n'; - branches.clear(); - previousRemote = remote; + if (b.startsWith(remotePrefix)) { + const int nextSlash = b.indexOf('/', prefixLength); + if (nextSlash < 0) + continue; + const QString remote = b.mid(prefixLength, nextSlash - prefixLength); + if (remote != previousRemote) { + data->m_branches += branchesDisplay(previousRemote, &branches, &first) + + '\n'; + branches.clear(); + previousRemote = remote; + } + branches << b.mid(nextSlash + 1); + } else { + branches << b; } - branches << b.mid(nextSlash + 1); - } else { - branches << b; } + if (branches.isEmpty()) { + if (previousRemote == localPrefix) + data->m_branches += Tr::tr(""); + } else { + data->m_branches += branchesDisplay(previousRemote, &branches, &first); + } + data->m_branches = data->m_branches.trimmed(); } - if (branches.isEmpty()) { - if (previousRemote == localPrefix) - data->m_branches += Tr::tr(""); - } else { - data->m_branches += branchesDisplay(previousRemote, &branches, &first); - } - data->m_branches = data->m_branches.trimmed(); - updateDescription(*data); - }; - const auto onBranchesError = [storage, updateDescription](const Process &) { - ReloadStorage *data = storage.activeStorage(); - data->m_branches.clear(); updateDescription(*data); }; - const auto setupPrecedes = [this, storage](Process &process) { + const auto onPrecedesSetup = [this, storage](Process &process) { storage->m_precedes = busyMessage; setupCommand(process, {"describe", "--contains", storage->m_commit}); }; - const auto onPrecedesDone = [storage, updateDescription](const Process &process) { - ReloadStorage *data = storage.activeStorage(); - data->m_precedes = process.cleanedStdOut().trimmed(); - const int tilde = data->m_precedes.indexOf('~'); - if (tilde != -1) - data->m_precedes.truncate(tilde); - if (data->m_precedes.endsWith("^0")) - data->m_precedes.chop(2); - updateDescription(*data); - }; - const auto onPrecedesError = [storage, updateDescription](const Process &) { + const auto onPrecedesDone = [storage, updateDescription](const Process &process, bool success) { ReloadStorage *data = storage.activeStorage(); data->m_precedes.clear(); + if (success) { + data->m_precedes = process.cleanedStdOut().trimmed(); + const int tilde = data->m_precedes.indexOf('~'); + if (tilde != -1) + data->m_precedes.truncate(tilde); + if (data->m_precedes.endsWith("^0")) + data->m_precedes.chop(2); + } updateDescription(*data); }; @@ -516,7 +512,7 @@ ShowController::ShowController(IDocument *document, const QString &id) taskTree.setRecipe(tasks); }; - const auto setupDiff = [this, id](Process &process) { + const auto onDiffSetup = [this, id](Process &process) { setupCommand(process, addConfigurationArguments( {"show", "--format=format:", // omit header, already generated noColorOption, decorateOption, id})); @@ -533,18 +529,18 @@ ShowController::ShowController(IDocument *document, const QString &id) onGroupSetup([this] { setStartupFile(VcsBase::source(this->document()).toString()); }), Group { finishAllAndDone, - ProcessTask(setupDescription, onDescriptionDone), + ProcessTask(onDescriptionSetup, onDescriptionDone), Group { parallel, finishAllAndDone, onGroupSetup(desciptionDetailsSetup), - ProcessTask(setupBranches, onBranchesDone, onBranchesError), - ProcessTask(setupPrecedes, onPrecedesDone, onPrecedesError), + ProcessTask(onBranchesSetup, onBranchesDone), + ProcessTask(onPrecedesSetup, onPrecedesDone), TaskTreeTask(setupFollows) } }, Group { - ProcessTask(setupDiff, onDiffDone), + ProcessTask(onDiffSetup, onDiffDone), postProcessTask(diffInputStorage) } }; diff --git a/src/plugins/subversion/subversionclient.cpp b/src/plugins/subversion/subversionclient.cpp index 98f0cfdde90..75231c21e51 100644 --- a/src/plugins/subversion/subversionclient.cpp +++ b/src/plugins/subversion/subversionclient.cpp @@ -165,7 +165,7 @@ SubversionDiffEditorController::SubversionDiffEditorController(IDocument *docume const TreeStorage diffInputStorage; - const auto setupDescription = [this](Process &process) { + const auto onDescriptionSetup = [this](Process &process) { if (m_changeNumber == 0) return SetupResult::StopWithDone; setupCommand(process, {"log", "-r", QString::number(m_changeNumber)}); @@ -175,14 +175,11 @@ SubversionDiffEditorController::SubversionDiffEditorController(IDocument *docume setDescription(Tr::tr("Waiting for data...")); return SetupResult::Continue; }; - const auto onDescriptionDone = [this](const Process &process) { - setDescription(process.cleanedStdOut()); - }; - const auto onDescriptionError = [this](const Process &) { - setDescription({}); + const auto onDescriptionDone = [this](const Process &process, bool success) { + setDescription(success ? process.cleanedStdOut() : QString()); }; - const auto setupDiff = [this](Process &process) { + const auto onDiffSetup = [this](Process &process) { QStringList args = QStringList{"diff"} << "--internal-diff"; if (ignoreWhitespace()) args << "-x" << "-uw"; @@ -205,10 +202,10 @@ SubversionDiffEditorController::SubversionDiffEditorController(IDocument *docume parallel, Group { finishAllAndDone, - ProcessTask(setupDescription, onDescriptionDone, onDescriptionError) + ProcessTask(onDescriptionSetup, onDescriptionDone) }, Group { - ProcessTask(setupDiff, onDiffDone), + ProcessTask(onDiffSetup, onDiffDone), postProcessTask(diffInputStorage) } }; diff --git a/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp b/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp index f7372fcd074..0a4c915608f 100644 --- a/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp +++ b/src/plugins/vcsbase/vcsbasediffeditorcontroller.cpp @@ -40,18 +40,15 @@ VcsBaseDiffEditorController::~VcsBaseDiffEditorController() GroupItem VcsBaseDiffEditorController::postProcessTask(const TreeStorage &inputStorage) { - const auto setupDiffProcessor = [inputStorage](Async> &async) { + const auto onSetup = [inputStorage](Async> &async) { async.setFutureSynchronizer(ExtensionSystem::PluginManager::futureSynchronizer()); async.setConcurrentCallData(&DiffUtils::readPatchWithPromise, *inputStorage); }; - const auto onDiffProcessorDone = [this](const Async> &async) { - setDiffFiles(async.isResultAvailable() ? async.result() : QList()); + const auto onDone = [this](const Async> &async, bool success) { + setDiffFiles(success && async.isResultAvailable() ? async.result() : QList()); // TODO: We should set the right starting line here }; - const auto onDiffProcessorError = [this](const Async> &) { - setDiffFiles({}); - }; - return AsyncTask>(setupDiffProcessor, onDiffProcessorDone, onDiffProcessorError); + return AsyncTask>(onSetup, onDone); } void VcsBaseDiffEditorController::setupCommand(Process &process, const QStringList &args) const