diff --git a/src/plugins/clearcase/clearcaseplugin.cpp b/src/plugins/clearcase/clearcaseplugin.cpp index 3de8dcca259..aac5fc457b5 100644 --- a/src/plugins/clearcase/clearcaseplugin.cpp +++ b/src/plugins/clearcase/clearcaseplugin.cpp @@ -103,9 +103,6 @@ const char CMD_ID_UPDATE_VIEW[] = "ClearCase.UpdateView"; const char CMD_ID_CHECKIN_ALL[] = "ClearCase.CheckInAll"; const char CMD_ID_STATUS[] = "ClearCase.Status"; -const int s_silentRun = VcsCommand::NoOutput | VcsCommand::FullySynchronously; -const int s_verboseRun = VcsCommand::ShowStdOut | VcsCommand::FullySynchronously; - const VcsBaseEditorParameters logEditorParameters { LogOutput, "ClearCase File Log Editor", // id @@ -381,8 +378,8 @@ QStringList ClearCasePluginPrivate::getVobList() const { QStringList args(QLatin1String("lsvob")); args << QLatin1String("-s"); - const CommandResult result = - runCleartool(currentState().topLevel(), args, m_settings.timeOutS, s_silentRun); + const CommandResult result = runCleartool(currentState().topLevel(), args, m_settings.timeOutS, + VcsCommand::NoOutput); return result.cleanedStdOut().split(QLatin1Char('\n'), Qt::SkipEmptyParts); } @@ -504,7 +501,8 @@ FileStatus::Status ClearCasePluginPrivate::getFileStatus(const QString &fileName QString ClearCasePluginPrivate::ccManagesDirectory(const FilePath &directory) const { QStringList args(QLatin1String("pwv")); - const CommandResult result = runCleartool(directory, args, m_settings.timeOutS, s_silentRun); + const CommandResult result = runCleartool(directory, args, m_settings.timeOutS, + VcsCommand::NoOutput); if (result.result() != ProcessResult::FinishedWithSuccess) return {}; @@ -549,10 +547,9 @@ QString ClearCasePluginPrivate::ccViewRoot(const FilePath &directory) const { QStringList args(QLatin1String("pwv")); args << QLatin1String("-root"); - const CommandResult result = runCleartool(directory, args, m_settings.timeOutS, s_silentRun); - + const CommandResult result = runCleartool(directory, args, m_settings.timeOutS, + VcsCommand::NoOutput); QString root = result.cleanedStdOut().trimmed(); - if (root.isEmpty()) { if (HostOsInfo::isWindowsHost()) root = getDriveLetterOfPath(directory.toString()); @@ -825,8 +822,8 @@ QString ClearCasePluginPrivate::ccGetPredecessor(const QString &version) const { QStringList args(QLatin1String("describe")); args << QLatin1String("-fmt") << QLatin1String("%En@@%PSn") << version; - const CommandResult result = - runCleartool(currentState().topLevel(), args, m_settings.timeOutS, s_silentRun); + const CommandResult result = runCleartool(currentState().topLevel(), args, m_settings.timeOutS, + VcsCommand::NoOutput); if (result.result() != ProcessResult::FinishedWithSuccess || result.cleanedStdOut().endsWith(QLatin1Char('@'))) {// @@ return {}; @@ -841,8 +838,8 @@ QStringList ClearCasePluginPrivate::ccGetActiveVobs() const QStringList args(QLatin1String("lsvob")); const QString theViewRoot = viewRoot(); - const CommandResult result = - runCleartool(FilePath::fromString(theViewRoot), args, m_settings.timeOutS, s_silentRun); + const CommandResult result = runCleartool(FilePath::fromString(theViewRoot), args, + m_settings.timeOutS, VcsCommand::NoOutput); if (result.result() != ProcessResult::FinishedWithSuccess) return {}; @@ -895,7 +892,7 @@ QString ClearCasePluginPrivate::ccGetFileActivity(const FilePath &workingDir, co QStringList args(QLatin1String("lscheckout")); args << QLatin1String("-fmt") << QLatin1String("%[activity]p"); args << file; - return runCleartool(workingDir, args, m_settings.timeOutS, s_silentRun).cleanedStdOut(); + return runCleartool(workingDir, args, m_settings.timeOutS, VcsCommand::NoOutput).cleanedStdOut(); } ClearCaseSubmitEditor *ClearCasePluginPrivate::openClearCaseSubmitEditor(const FilePath &filePath, bool isUcm) @@ -1110,7 +1107,8 @@ bool ClearCasePluginPrivate::vcsUndoCheckOut(const FilePath &workingDir, const Q args << QLatin1String(keep ? "-keep" : "-rm"); args << QDir::toNativeSeparators(fileName); - const CommandResult result = runCleartool(workingDir, args, m_settings.timeOutS, s_verboseRun); + const CommandResult result = runCleartool(workingDir, args, m_settings.timeOutS, + VcsCommand::ShowStdOut); if (result.result() != ProcessResult::FinishedWithSuccess) return false; @@ -1140,7 +1138,8 @@ bool ClearCasePluginPrivate::vcsUndoHijack(const FilePath &workingDir, const QSt args << QLatin1String("/dev/null"); args << QDir::toNativeSeparators(fileName); - const CommandResult result = runCleartool(workingDir, args, m_settings.timeOutS, s_verboseRun); + const CommandResult result = runCleartool(workingDir, args, m_settings.timeOutS, + VcsCommand::ShowStdOut); if (result.result() == ProcessResult::FinishedWithSuccess) return false; @@ -1248,7 +1247,8 @@ QStringList ClearCasePluginPrivate::ccGetActivityVersions(const FilePath &workin { QStringList args(QLatin1String("lsactivity")); args << QLatin1String("-fmt") << QLatin1String("%[versions]Cp") << activity; - const CommandResult result = runCleartool(workingDir, args, m_settings.timeOutS, s_silentRun); + const CommandResult result = runCleartool(workingDir, args, m_settings.timeOutS, + VcsCommand::NoOutput); if (result.result() != ProcessResult::FinishedWithSuccess) return {}; QStringList versions = result.cleanedStdOut().split(QLatin1String(", ")); @@ -1648,7 +1648,7 @@ void ClearCasePluginPrivate::commitFromEditor() QString ClearCasePluginPrivate::runCleartoolSync(const FilePath &workingDir, const QStringList &arguments) const { - return runCleartool(workingDir, arguments, m_settings.timeOutS, s_silentRun).cleanedStdOut(); + return runCleartool(workingDir, arguments, m_settings.timeOutS, VcsCommand::NoOutput).cleanedStdOut(); } CommandResult ClearCasePluginPrivate::runCleartool(const FilePath &workingDir, @@ -1781,7 +1781,7 @@ bool ClearCasePluginPrivate::vcsOpen(const FilePath &workingDir, const QString & } args << file; CommandResult result = runCleartool(topLevel, args, m_settings.timeOutS, - s_verboseRun | VcsCommand::SuppressStdErr); + VcsCommand::ShowStdOut | VcsCommand::SuppressStdErr); if (result.result() != ProcessResult::FinishedWithSuccess) { if (result.cleanedStdErr().contains(QLatin1String("Versions other than the selected version"))) { VersionSelector selector(file, result.cleanedStdErr()); @@ -1790,7 +1790,7 @@ bool ClearCasePluginPrivate::vcsOpen(const FilePath &workingDir, const QString & ccUpdate(workingDir, QStringList(file)); else args.removeOne(QLatin1String("-query")); - result = runCleartool(topLevel, args, m_settings.timeOutS, s_verboseRun); + result = runCleartool(topLevel, args, m_settings.timeOutS, VcsCommand::ShowStdOut); } } else { VcsOutputWindow::append(result.cleanedStdOut()); @@ -1935,7 +1935,7 @@ bool ClearCasePluginPrivate::ccFileOp(const FilePath &workingDir, const QString QStringList args; args << QLatin1String("checkout") << commentArg << dirName; const CommandResult coResult = runCleartool(workingDir, args, m_settings.timeOutS, - s_verboseRun); + VcsCommand::ShowStdOut); if (coResult.result() != ProcessResult::FinishedWithSuccess) { if (coResult.cleanedStdErr().contains(QLatin1String("already checked out"))) noCheckout = true; @@ -1949,7 +1949,7 @@ bool ClearCasePluginPrivate::ccFileOp(const FilePath &workingDir, const QString if (!file2.isEmpty()) args << QDir::toNativeSeparators(file2); const CommandResult opResult = runCleartool(workingDir, args, m_settings.timeOutS, - s_verboseRun); + VcsCommand::ShowStdOut); if (opResult.result() != ProcessResult::FinishedWithSuccess) { // on failure - undo checkout for the directory if (!noCheckout) @@ -1964,7 +1964,7 @@ bool ClearCasePluginPrivate::ccFileOp(const FilePath &workingDir, const QString args.clear(); args << QLatin1String("checkin") << commentArg << dirName; const CommandResult ciResult = runCleartool(workingDir, args, m_settings.timeOutS, - s_verboseRun); + VcsCommand::ShowStdOut); return ciResult.result() == ProcessResult::FinishedWithSuccess; } @@ -2244,7 +2244,8 @@ QString ClearCasePluginPrivate::getFile(const QString &nativeFile, const QString } QStringList args(QLatin1String("get")); args << QLatin1String("-to") << tempFile << nativeFile; - const CommandResult result = runCleartool(m_topLevel, args, m_settings.timeOutS, s_silentRun); + const CommandResult result = runCleartool(m_topLevel, args, m_settings.timeOutS, + VcsCommand::NoOutput); if (result.result() != ProcessResult::FinishedWithSuccess) return {}; QFile::setPermissions(tempFile, QFile::ReadOwner | QFile::ReadUser | diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp index d5c3775c93f..88168dc645b 100644 --- a/src/plugins/git/gitclient.cpp +++ b/src/plugins/git/gitclient.cpp @@ -2967,7 +2967,7 @@ bool GitClient::addAndCommit(const FilePath &repositoryDirectory, } const CommandResult result = vcsSynchronousExec(repositoryDirectory, arguments, - VcsCommand::NoFullySync); + VcsCommand::UseEventLoop); if (result.result() == ProcessResult::FinishedWithSuccess) { VcsOutputWindow::appendMessage(msgCommitted(amendSHA1, commitCount)); GitPlugin::updateCurrentBranch(); diff --git a/src/plugins/subversion/subversionclient.cpp b/src/plugins/subversion/subversionclient.cpp index 8e614c0430a..ecdddd354db 100644 --- a/src/plugins/subversion/subversionclient.cpp +++ b/src/plugins/subversion/subversionclient.cpp @@ -69,7 +69,7 @@ bool SubversionClient::doCommit(const FilePath &repositoryRoot, << commitMessageFile << escapeFiles(files); const CommandResult result = vcsSynchronousExec(repositoryRoot, args, - VcsCommand::ShowStdOut | VcsCommand::NoFullySync); + VcsCommand::ShowStdOut | VcsCommand::UseEventLoop); return result.result() == ProcessResult::FinishedWithSuccess; } diff --git a/src/plugins/vcsbase/vcscommand.cpp b/src/plugins/vcsbase/vcscommand.cpp index 671da3c263d..82ae1a4d278 100644 --- a/src/plugins/vcsbase/vcscommand.cpp +++ b/src/plugins/vcsbase/vcscommand.cpp @@ -86,7 +86,7 @@ public: void cleanup(); void setupProcess(QtcProcess *process, const Job &job); void installStdCallbacks(QtcProcess *process); - bool isFullySynchronous() const; + EventLoopMode eventLoopMode() const; void handleDone(QtcProcess *process); void startAll(); void startNextJob(); @@ -214,10 +214,11 @@ void VcsCommandPrivate::installStdCallbacks(QtcProcess *process) // m_process->setTimeOutMessageBoxEnabled(true); } -bool VcsCommandPrivate::isFullySynchronous() const +EventLoopMode VcsCommandPrivate::eventLoopMode() const { - return (m_flags & VcsCommand::FullySynchronously) || (!(m_flags & VcsCommand::NoFullySync) - && QThread::currentThread() == QCoreApplication::instance()->thread()); + if ((m_flags & VcsCommand::UseEventLoop) && QThread::currentThread() == qApp->thread()) + return EventLoopMode::On; + return EventLoopMode::Off; } void VcsCommandPrivate::handleDone(QtcProcess *process) @@ -392,9 +393,8 @@ CommandResult VcsCommand::runCommand(const CommandLine &command, int timeoutS) d->setupProcess(&process, {command, timeoutS, d->m_defaultWorkingDirectory, {}}); - EventLoopMode eventLoopMode = EventLoopMode::Off; - if (!d->isFullySynchronous()) { - eventLoopMode = EventLoopMode::On; + const EventLoopMode eventLoopMode = d->eventLoopMode(); + if (eventLoopMode == EventLoopMode::On) { connect(this, &VcsCommand::terminate, &process, [&process] { process.stop(); process.waitForFinished(); diff --git a/src/plugins/vcsbase/vcscommand.h b/src/plugins/vcsbase/vcscommand.h index bd5816874af..552cd1225aa 100644 --- a/src/plugins/vcsbase/vcscommand.h +++ b/src/plugins/vcsbase/vcscommand.h @@ -90,11 +90,9 @@ public: SuppressCommandLogging = 0x10, // No command log entry. ShowSuccessMessage = 0x20, // Show message about successful completion of command. ForceCLocale = 0x40, // Force C-locale for commands whose output is parsed. - FullySynchronously = 0x80, // Suppress local event loop (in case UI actions are - // triggered by file watchers). - SilentOutput = 0x100, // Suppress user notifications about the output happening. - NoFullySync = 0x200, // Avoid fully synchronous execution even in UI thread. - ExpectRepoChanges = 0x400, // Expect changes in repository by the command + SilentOutput = 0x80, // Suppress user notifications about the output happening. + UseEventLoop = 0x100, // Use event loop when executed in UI thread. + ExpectRepoChanges = 0x200, // Expect changes in repository by the command NoOutput = SuppressStdErr | SuppressFailMessage | SuppressCommandLogging };