bool BranchUtils::rename() { const QModelIndex selected = selectedIndex(); QTC_CHECK(selected != m_model->currentBranch()); const bool isTag = m_model->isTag(selected); QTC_CHECK(m_model->isLocal(selected) || isTag); QString oldName = m_model->fullName(selected); QStringList localNames; if (!isTag) localNames = m_model->localBranchNames(); BranchAddDialog branchAddDialog(localNames, false, m_widget); if (isTag) branchAddDialog.setWindowTitle(tr("Rename Tag")); branchAddDialog.setBranchName(oldName); branchAddDialog.setTrackedBranchName(QString(), false); branchAddDialog.exec(); if (branchAddDialog.result() == QDialog::Accepted) { if (branchAddDialog.branchName() == oldName) return false; if (isTag) m_model->renameTag(oldName, branchAddDialog.branchName()); else m_model->renameBranch(oldName, branchAddDialog.branchName()); return true; } if (QTC_GUARD(m_branchView)) m_branchView->selectionModel()->clear(); return false; }
void ClangCompilerOptionsBuilder::addPredefinedMacrosAndHeaderPathsOptionsForNonMsvc() { static const QString resourceDir = clangIncludeDirectory(); if (QTC_GUARD(!resourceDir.isEmpty())) { add("-nostdlibinc"); add("-I" + QDir::toNativeSeparators(resourceDir)); add("-undef"); } }
void ResumeDocumentJob::finalizeAsyncRun() { if (context().isDocumentOpen()) { if (QTC_GUARD(asyncResult().updateResult.hasReparsed())) m_pinnedDocument.setIsSuspended(false); } UpdateAnnotationsJob::finalizeAsyncRun(); }
// For e.g. creation of profile-guided optimization builds. void ClangCodeModelPlugin::maybeHandleBatchFileAndExit() const { #ifdef WITH_TESTS const QString batchFilePath = QString::fromLocal8Bit(qgetenv("QTC_CLANG_BATCH")); if (!batchFilePath.isEmpty() && QTC_GUARD(QFileInfo::exists(batchFilePath))) { const bool runSucceeded = runClangBatchFile(batchFilePath); QCoreApplication::exit(!runSucceeded); } #endif }
bool BranchUtils::checkout() { if (!Core::DocumentManager::saveAllModifiedDocuments()) return false; const QModelIndex selected = selectedIndex(); const QString currentBranch = m_model->fullName(m_model->currentBranch()); const QString nextBranch = m_model->fullName(selected); const QString popMessageStart = QCoreApplication::applicationName() + ' ' + nextBranch + "-AutoStash "; BranchCheckoutDialog branchCheckoutDialog(m_widget, currentBranch, nextBranch); GitClient *client = GitPlugin::client(); if (client->gitStatus(m_repository, StatusMode(NoUntracked | NoSubmodules)) != GitClient::StatusChanged) branchCheckoutDialog.foundNoLocalChanges(); QList<Stash> stashes; client->synchronousStashList(m_repository, &stashes); for (const Stash &stash : qAsConst(stashes)) { if (stash.message.startsWith(popMessageStart)) { branchCheckoutDialog.foundStashForNextBranch(); break; } } if (!branchCheckoutDialog.hasLocalChanges() && !branchCheckoutDialog.hasStashForNextBranch()) { // No local changes and no Auto Stash - no need to open dialog m_model->checkoutBranch(selected); } else if (branchCheckoutDialog.exec() == QDialog::Accepted) { if (branchCheckoutDialog.makeStashOfCurrentBranch()) { if (client->synchronousStash(m_repository, currentBranch + "-AutoStash").isEmpty()) return false; } else if (branchCheckoutDialog.moveLocalChangesToNextBranch()) { if (!client->beginStashScope(m_repository, "Checkout", NoPrompt)) return false; } else if (branchCheckoutDialog.discardLocalChanges()) { if (!client->synchronousReset(m_repository)) return false; } m_model->checkoutBranch(selected); QString stashName; client->synchronousStashList(m_repository, &stashes); for (const Stash &stash : qAsConst(stashes)) { if (stash.message.startsWith(popMessageStart)) { stashName = stash.name; break; } } if (branchCheckoutDialog.moveLocalChangesToNextBranch()) client->endStashScope(m_repository); else if (branchCheckoutDialog.popStashOfNextBranch()) client->synchronousStashRestore(m_repository, stashName, true); } if (QTC_GUARD(m_branchView)) m_branchView->selectionModel()->clear(); return true; }