ClearCasePlugin: Replace timeout with timeout multiplier

Give it default value of 1. Move this arg as the last one
(only 2 non-default usages).

Change-Id: I8c0bee7988436b899c8ae5cb7b96b7fe534d265f
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Jarek Kobus
2022-10-05 16:21:22 +02:00
parent 7591b2f56d
commit 4bcdfa6b19
2 changed files with 32 additions and 45 deletions

View File

@@ -256,8 +256,8 @@ private:
const QString &source, QTextCodec *codec) const; const QString &source, QTextCodec *codec) const;
QString runCleartoolSync(const FilePath &workingDir, const QStringList &arguments) const; QString runCleartoolSync(const FilePath &workingDir, const QStringList &arguments) const;
CommandResult runCleartool(const FilePath &workingDir, const QStringList &arguments, CommandResult runCleartool(const FilePath &workingDir, const QStringList &arguments,
int timeOutS, unsigned flags = 0, unsigned flags = 0, QTextCodec *codec = nullptr,
QTextCodec *codec = nullptr) const; int timeoutMultiplier = 1) const;
static void sync(QFutureInterface<void> &future, QStringList files); static void sync(QFutureInterface<void> &future, QStringList files);
void history(const FilePath &workingDir, void history(const FilePath &workingDir,
@@ -377,7 +377,7 @@ QStringList ClearCasePluginPrivate::getVobList() const
{ {
QStringList args(QLatin1String("lsvob")); QStringList args(QLatin1String("lsvob"));
args << QLatin1String("-s"); args << QLatin1String("-s");
const CommandResult result = runCleartool(currentState().topLevel(), args, m_settings.timeOutS, const CommandResult result = runCleartool(currentState().topLevel(), args,
VcsCommand::NoOutput); VcsCommand::NoOutput);
return result.cleanedStdOut().split(QLatin1Char('\n'), Qt::SkipEmptyParts); return result.cleanedStdOut().split(QLatin1Char('\n'), Qt::SkipEmptyParts);
} }
@@ -500,8 +500,7 @@ FileStatus::Status ClearCasePluginPrivate::getFileStatus(const QString &fileName
QString ClearCasePluginPrivate::ccManagesDirectory(const FilePath &directory) const QString ClearCasePluginPrivate::ccManagesDirectory(const FilePath &directory) const
{ {
QStringList args(QLatin1String("pwv")); QStringList args(QLatin1String("pwv"));
const CommandResult result = runCleartool(directory, args, m_settings.timeOutS, const CommandResult result = runCleartool(directory, args, VcsCommand::NoOutput);
VcsCommand::NoOutput);
if (result.result() != ProcessResult::FinishedWithSuccess) if (result.result() != ProcessResult::FinishedWithSuccess)
return {}; return {};
@@ -546,8 +545,7 @@ QString ClearCasePluginPrivate::ccViewRoot(const FilePath &directory) const
{ {
QStringList args(QLatin1String("pwv")); QStringList args(QLatin1String("pwv"));
args << QLatin1String("-root"); args << QLatin1String("-root");
const CommandResult result = runCleartool(directory, args, m_settings.timeOutS, const CommandResult result = runCleartool(directory, args, VcsCommand::NoOutput);
VcsCommand::NoOutput);
QString root = result.cleanedStdOut().trimmed(); QString root = result.cleanedStdOut().trimmed();
if (root.isEmpty()) { if (root.isEmpty()) {
if (HostOsInfo::isWindowsHost()) if (HostOsInfo::isWindowsHost())
@@ -821,7 +819,7 @@ QString ClearCasePluginPrivate::ccGetPredecessor(const QString &version) const
{ {
QStringList args(QLatin1String("describe")); QStringList args(QLatin1String("describe"));
args << QLatin1String("-fmt") << QLatin1String("%En@@%PSn") << version; args << QLatin1String("-fmt") << QLatin1String("%En@@%PSn") << version;
const CommandResult result = runCleartool(currentState().topLevel(), args, m_settings.timeOutS, const CommandResult result = runCleartool(currentState().topLevel(), args,
VcsCommand::NoOutput); VcsCommand::NoOutput);
if (result.result() != ProcessResult::FinishedWithSuccess if (result.result() != ProcessResult::FinishedWithSuccess
|| result.cleanedStdOut().endsWith(QLatin1Char('@'))) {// <name-unknown>@@ || result.cleanedStdOut().endsWith(QLatin1Char('@'))) {// <name-unknown>@@
@@ -838,7 +836,7 @@ QStringList ClearCasePluginPrivate::ccGetActiveVobs() const
const QString theViewRoot = viewRoot(); const QString theViewRoot = viewRoot();
const CommandResult result = runCleartool(FilePath::fromString(theViewRoot), args, const CommandResult result = runCleartool(FilePath::fromString(theViewRoot), args,
m_settings.timeOutS, VcsCommand::NoOutput); VcsCommand::NoOutput);
if (result.result() != ProcessResult::FinishedWithSuccess) if (result.result() != ProcessResult::FinishedWithSuccess)
return {}; return {};
@@ -891,7 +889,7 @@ QString ClearCasePluginPrivate::ccGetFileActivity(const FilePath &workingDir, co
QStringList args(QLatin1String("lscheckout")); QStringList args(QLatin1String("lscheckout"));
args << QLatin1String("-fmt") << QLatin1String("%[activity]p"); args << QLatin1String("-fmt") << QLatin1String("%[activity]p");
args << file; args << file;
return runCleartool(workingDir, args, m_settings.timeOutS, VcsCommand::NoOutput).cleanedStdOut(); return runCleartool(workingDir, args, VcsCommand::NoOutput).cleanedStdOut();
} }
ClearCaseSubmitEditor *ClearCasePluginPrivate::openClearCaseSubmitEditor(const FilePath &filePath, bool isUcm) ClearCaseSubmitEditor *ClearCasePluginPrivate::openClearCaseSubmitEditor(const FilePath &filePath, bool isUcm)
@@ -1075,9 +1073,7 @@ void ClearCasePluginPrivate::undoCheckOutCurrent()
args << QLatin1String("-diff_format") << QLatin1String("-predecessor"); args << QLatin1String("-diff_format") << QLatin1String("-predecessor");
args << fileName; args << fileName;
const CommandResult result = const CommandResult result = runCleartool(state.currentFileTopLevel(), args);
runCleartool(state.currentFileTopLevel(), args, m_settings.timeOutS);
bool keep = false; bool keep = false;
if (result.exitCode()) { // return value is 1 if there is any difference if (result.exitCode()) { // return value is 1 if there is any difference
UndoCheckOutDialog dialog; UndoCheckOutDialog dialog;
@@ -1106,8 +1102,7 @@ bool ClearCasePluginPrivate::vcsUndoCheckOut(const FilePath &workingDir, const Q
args << QLatin1String(keep ? "-keep" : "-rm"); args << QLatin1String(keep ? "-keep" : "-rm");
args << QDir::toNativeSeparators(fileName); args << QDir::toNativeSeparators(fileName);
const CommandResult result = runCleartool(workingDir, args, m_settings.timeOutS, const CommandResult result = runCleartool(workingDir, args, VcsCommand::ShowStdOut);
VcsCommand::ShowStdOut);
if (result.result() != ProcessResult::FinishedWithSuccess) if (result.result() != ProcessResult::FinishedWithSuccess)
return false; return false;
@@ -1137,8 +1132,7 @@ bool ClearCasePluginPrivate::vcsUndoHijack(const FilePath &workingDir, const QSt
args << QLatin1String("/dev/null"); args << QLatin1String("/dev/null");
args << QDir::toNativeSeparators(fileName); args << QDir::toNativeSeparators(fileName);
const CommandResult result = runCleartool(workingDir, args, m_settings.timeOutS, const CommandResult result = runCleartool(workingDir, args, VcsCommand::ShowStdOut);
VcsCommand::ShowStdOut);
if (result.result() == ProcessResult::FinishedWithSuccess) if (result.result() == ProcessResult::FinishedWithSuccess)
return false; return false;
@@ -1246,8 +1240,7 @@ QStringList ClearCasePluginPrivate::ccGetActivityVersions(const FilePath &workin
{ {
QStringList args(QLatin1String("lsactivity")); QStringList args(QLatin1String("lsactivity"));
args << QLatin1String("-fmt") << QLatin1String("%[versions]Cp") << activity; args << QLatin1String("-fmt") << QLatin1String("%[versions]Cp") << activity;
const CommandResult result = runCleartool(workingDir, args, m_settings.timeOutS, const CommandResult result = runCleartool(workingDir, args, VcsCommand::NoOutput);
VcsCommand::NoOutput);
if (result.result() != ProcessResult::FinishedWithSuccess) if (result.result() != ProcessResult::FinishedWithSuccess)
return {}; return {};
QStringList versions = result.cleanedStdOut().split(QLatin1String(", ")); QStringList versions = result.cleanedStdOut().split(QLatin1String(", "));
@@ -1477,7 +1470,7 @@ void ClearCasePluginPrivate::history(const FilePath &workingDir,
for (const QString &file : files) for (const QString &file : files)
args.append(QDir::toNativeSeparators(file)); args.append(QDir::toNativeSeparators(file));
const CommandResult result = runCleartool(workingDir, args, m_settings.timeOutS, 0, codec); const CommandResult result = runCleartool(workingDir, args, 0, codec);
if (result.result() != ProcessResult::FinishedWithSuccess) if (result.result() != ProcessResult::FinishedWithSuccess)
return; return;
@@ -1537,8 +1530,8 @@ void ClearCasePluginPrivate::ccUpdate(const FilePath &workingDir, const QStringL
args << QLatin1String("-noverwrite"); args << QLatin1String("-noverwrite");
if (!relativePaths.isEmpty()) if (!relativePaths.isEmpty())
args.append(relativePaths); args.append(relativePaths);
const CommandResult result = const CommandResult result = runCleartool(workingDir, args, VcsCommand::ShowStdOut, nullptr,
runCleartool(workingDir, args, m_settings.longTimeOutS(), VcsCommand::ShowStdOut); 10);
if (result.result() == ProcessResult::FinishedWithSuccess) if (result.result() == ProcessResult::FinishedWithSuccess)
emit repositoryChanged(workingDir); emit repositoryChanged(workingDir);
} }
@@ -1570,7 +1563,7 @@ void ClearCasePluginPrivate::vcsAnnotateHelper(const FilePath &workingDir, const
args << QLatin1String("-out") << QLatin1String("-"); args << QLatin1String("-out") << QLatin1String("-");
args.append(QDir::toNativeSeparators(id)); args.append(QDir::toNativeSeparators(id));
const CommandResult result = runCleartool(workingDir, args, m_settings.timeOutS, 0, codec); const CommandResult result = runCleartool(workingDir, args, 0, codec);
if (result.result() != ProcessResult::FinishedWithSuccess) if (result.result() != ProcessResult::FinishedWithSuccess)
return; return;
@@ -1619,7 +1612,7 @@ void ClearCasePluginPrivate::vcsDescribe(const FilePath &source, const QString &
QStringList args(QLatin1String("describe")); QStringList args(QLatin1String("describe"));
args.push_back(id); args.push_back(id);
QTextCodec *codec = VcsBaseEditor::getCodec(source.toString()); QTextCodec *codec = VcsBaseEditor::getCodec(source.toString());
const CommandResult result = runCleartool(topLevel, args, m_settings.timeOutS, 0, codec); const CommandResult result = runCleartool(topLevel, args, 0, codec);
description = result.cleanedStdOut(); description = result.cleanedStdOut();
if (m_settings.extDiffAvailable) if (m_settings.extDiffAvailable)
description += diffExternal(id); description += diffExternal(id);
@@ -1647,20 +1640,21 @@ void ClearCasePluginPrivate::commitFromEditor()
QString ClearCasePluginPrivate::runCleartoolSync(const FilePath &workingDir, QString ClearCasePluginPrivate::runCleartoolSync(const FilePath &workingDir,
const QStringList &arguments) const const QStringList &arguments) const
{ {
return runCleartool(workingDir, arguments, m_settings.timeOutS, VcsCommand::NoOutput).cleanedStdOut(); return runCleartool(workingDir, arguments, VcsCommand::NoOutput).cleanedStdOut();
} }
CommandResult ClearCasePluginPrivate::runCleartool(const FilePath &workingDir, CommandResult ClearCasePluginPrivate::runCleartool(const FilePath &workingDir,
const QStringList &arguments, const QStringList &arguments,
int timeOutS,
unsigned flags, unsigned flags,
QTextCodec *codec) const QTextCodec *codec,
int timeoutMultiplier) const
{ {
if (m_settings.ccBinaryPath.isEmpty()) if (m_settings.ccBinaryPath.isEmpty())
return CommandResult(ProcessResult::StartFailed, Tr::tr("No ClearCase executable specified.")); return CommandResult(ProcessResult::StartFailed, Tr::tr("No ClearCase executable specified."));
const int timeoutS = m_settings.timeOutS * timeoutMultiplier;
return VcsCommand::runBlocking(workingDir, Environment::systemEnvironment(), return VcsCommand::runBlocking(workingDir, Environment::systemEnvironment(),
{m_settings.ccBinaryPath, arguments}, flags, timeOutS, codec); {m_settings.ccBinaryPath, arguments}, flags, timeoutS, codec);
} }
IEditor *ClearCasePluginPrivate::showOutputInEditor(const QString& title, const QString &output, IEditor *ClearCasePluginPrivate::showOutputInEditor(const QString& title, const QString &output,
@@ -1776,7 +1770,7 @@ bool ClearCasePluginPrivate::vcsOpen(const FilePath &workingDir, const QString &
vcsUndoHijack(topLevel, relFile, false); // don't keep, we've already kept a copy vcsUndoHijack(topLevel, relFile, false); // don't keep, we've already kept a copy
} }
args << file; args << file;
CommandResult result = runCleartool(topLevel, args, m_settings.timeOutS, CommandResult result = runCleartool(topLevel, args,
VcsCommand::ShowStdOut | VcsCommand::SuppressStdErr); VcsCommand::ShowStdOut | VcsCommand::SuppressStdErr);
if (result.result() != ProcessResult::FinishedWithSuccess) { if (result.result() != ProcessResult::FinishedWithSuccess) {
if (result.cleanedStdErr().contains(QLatin1String("Versions other than the selected version"))) { if (result.cleanedStdErr().contains(QLatin1String("Versions other than the selected version"))) {
@@ -1786,7 +1780,7 @@ bool ClearCasePluginPrivate::vcsOpen(const FilePath &workingDir, const QString &
ccUpdate(workingDir, QStringList(file)); ccUpdate(workingDir, QStringList(file));
else else
args.removeOne(QLatin1String("-query")); args.removeOne(QLatin1String("-query"));
result = runCleartool(topLevel, args, m_settings.timeOutS, VcsCommand::ShowStdOut); result = runCleartool(topLevel, args, VcsCommand::ShowStdOut);
} }
} else { } else {
VcsOutputWindow::append(result.cleanedStdOut()); VcsOutputWindow::append(result.cleanedStdOut());
@@ -1815,8 +1809,7 @@ bool ClearCasePluginPrivate::vcsSetActivity(const FilePath &workingDir, const QS
{ {
QStringList args; QStringList args;
args << QLatin1String("setactivity") << activity; args << QLatin1String("setactivity") << activity;
const CommandResult result = const CommandResult result = runCleartool(workingDir, args, VcsCommand::ShowStdOut);
runCleartool(workingDir, args, m_settings.timeOutS, VcsCommand::ShowStdOut);
if (result.result() != ProcessResult::FinishedWithSuccess) { if (result.result() != ProcessResult::FinishedWithSuccess) {
QMessageBox::warning(ICore::dialogParent(), title, Tr::tr("Set current activity failed: %1") QMessageBox::warning(ICore::dialogParent(), title, Tr::tr("Set current activity failed: %1")
.arg(result.exitMessage()), QMessageBox::Ok); .arg(result.exitMessage()), QMessageBox::Ok);
@@ -1862,8 +1855,8 @@ bool ClearCasePluginPrivate::vcsCheckIn(const FilePath &messageFile, const QStri
FilePath::fromString(QFileInfo(m_checkInView.toString(), fileName).canonicalFilePath()))); FilePath::fromString(QFileInfo(m_checkInView.toString(), fileName).canonicalFilePath())));
blockers.append(fcb); blockers.append(fcb);
} }
const CommandResult result = const CommandResult result = runCleartool(m_checkInView, args, VcsCommand::ShowStdOut, nullptr,
runCleartool(m_checkInView, args, m_settings.longTimeOutS(), VcsCommand::ShowStdOut); 10);
const QRegularExpression checkedIn("Checked in \\\"([^\"]*)\\\""); const QRegularExpression checkedIn("Checked in \\\"([^\"]*)\\\"");
QRegularExpressionMatch match = checkedIn.match(result.cleanedStdOut()); QRegularExpressionMatch match = checkedIn.match(result.cleanedStdOut());
bool anySucceeded = false; bool anySucceeded = false;
@@ -1930,8 +1923,7 @@ bool ClearCasePluginPrivate::ccFileOp(const FilePath &workingDir, const QString
// check out directory // check out directory
QStringList args; QStringList args;
args << QLatin1String("checkout") << commentArg << dirName; args << QLatin1String("checkout") << commentArg << dirName;
const CommandResult coResult = runCleartool(workingDir, args, m_settings.timeOutS, const CommandResult coResult = runCleartool(workingDir, args, VcsCommand::ShowStdOut);
VcsCommand::ShowStdOut);
if (coResult.result() != ProcessResult::FinishedWithSuccess) { if (coResult.result() != ProcessResult::FinishedWithSuccess) {
if (coResult.cleanedStdErr().contains(QLatin1String("already checked out"))) if (coResult.cleanedStdErr().contains(QLatin1String("already checked out")))
noCheckout = true; noCheckout = true;
@@ -1944,8 +1936,7 @@ bool ClearCasePluginPrivate::ccFileOp(const FilePath &workingDir, const QString
args << opArgs << commentArg << file; args << opArgs << commentArg << file;
if (!file2.isEmpty()) if (!file2.isEmpty())
args << QDir::toNativeSeparators(file2); args << QDir::toNativeSeparators(file2);
const CommandResult opResult = runCleartool(workingDir, args, m_settings.timeOutS, const CommandResult opResult = runCleartool(workingDir, args, VcsCommand::ShowStdOut);
VcsCommand::ShowStdOut);
if (opResult.result() != ProcessResult::FinishedWithSuccess) { if (opResult.result() != ProcessResult::FinishedWithSuccess) {
// on failure - undo checkout for the directory // on failure - undo checkout for the directory
if (!noCheckout) if (!noCheckout)
@@ -1959,8 +1950,7 @@ bool ClearCasePluginPrivate::ccFileOp(const FilePath &workingDir, const QString
// check in the directory // check in the directory
args.clear(); args.clear();
args << QLatin1String("checkin") << commentArg << dirName; args << QLatin1String("checkin") << commentArg << dirName;
const CommandResult ciResult = runCleartool(workingDir, args, m_settings.timeOutS, const CommandResult ciResult = runCleartool(workingDir, args, VcsCommand::ShowStdOut);
VcsCommand::ShowStdOut);
return ciResult.result() == ProcessResult::FinishedWithSuccess; return ciResult.result() == ProcessResult::FinishedWithSuccess;
} }
@@ -2096,7 +2086,7 @@ bool ClearCasePluginPrivate::newActivity()
args << QLatin1String("-headline") << headline; args << QLatin1String("-headline") << headline;
} }
const CommandResult result = runCleartool(workingDir, args, m_settings.timeOutS); const CommandResult result = runCleartool(workingDir, args);
if (result.result() != ProcessResult::FinishedWithSuccess) if (result.result() != ProcessResult::FinishedWithSuccess)
return false; return false;
@@ -2240,8 +2230,7 @@ QString ClearCasePluginPrivate::getFile(const QString &nativeFile, const QString
} }
QStringList args(QLatin1String("get")); QStringList args(QLatin1String("get"));
args << QLatin1String("-to") << tempFile << nativeFile; args << QLatin1String("-to") << tempFile << nativeFile;
const CommandResult result = runCleartool(m_topLevel, args, m_settings.timeOutS, const CommandResult result = runCleartool(m_topLevel, args, VcsCommand::NoOutput);
VcsCommand::NoOutput);
if (result.result() != ProcessResult::FinishedWithSuccess) if (result.result() != ProcessResult::FinishedWithSuccess)
return {}; return {};
QFile::setPermissions(tempFile, QFile::ReadOwner | QFile::ReadUser | QFile::setPermissions(tempFile, QFile::ReadOwner | QFile::ReadUser |

View File

@@ -28,8 +28,6 @@ public:
void fromSettings(QSettings *); void fromSettings(QSettings *);
void toSettings(QSettings *) const; void toSettings(QSettings *) const;
inline int longTimeOutS() const { return timeOutS * 10; }
bool equals(const ClearCaseSettings &s) const; bool equals(const ClearCaseSettings &s) const;
friend bool operator==(const ClearCaseSettings &p1, const ClearCaseSettings &p2) friend bool operator==(const ClearCaseSettings &p1, const ClearCaseSettings &p2)