Cvs: Replace timeout with timeout multiplier

Give it default value of 1. Move this arg as the last one.
This is similar change to 4bcdfa6b19.

Change-Id: Idb83d47d2412c495ac227f5663d3256b1870d437
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Jarek Kobus
2022-10-06 10:18:44 +02:00
parent eec0679234
commit 87a32429fe

View File

@@ -284,9 +284,9 @@ private:
CvsResponse runCvs(const FilePath &workingDirectory, CvsResponse runCvs(const FilePath &workingDirectory,
const QStringList &arguments, const QStringList &arguments,
int timeOutS,
RunFlags flags = RunFlags::None, RunFlags flags = RunFlags::None,
QTextCodec *outputCodec = nullptr) const; QTextCodec *outputCodec = nullptr,
int timeoutMultiplier = 1) const;
void annotate(const FilePath &workingDir, const QString &file, void annotate(const FilePath &workingDir, const QString &file,
const QString &revision = QString(), int lineNumber= -1); const QString &revision = QString(), int lineNumber= -1);
@@ -847,8 +847,7 @@ void CvsPluginPrivate::revertAll()
return; return;
QStringList args; QStringList args;
args << QLatin1String("update") << QLatin1String("-C") << state.topLevel().toString(); args << QLatin1String("update") << QLatin1String("-C") << state.topLevel().toString();
const auto revertResponse = runCvs(state.topLevel(), args, m_settings.timeout.value(), const auto revertResponse = runCvs(state.topLevel(), args, RunFlags::ShowStdOut);
RunFlags::ShowStdOut);
if (revertResponse.result == CvsResponse::Ok) if (revertResponse.result == CvsResponse::Ok)
emit repositoryChanged(state.topLevel()); emit repositoryChanged(state.topLevel());
else else
@@ -862,8 +861,7 @@ void CvsPluginPrivate::revertCurrentFile()
QTC_ASSERT(state.hasFile(), return); QTC_ASSERT(state.hasFile(), return);
QStringList args; QStringList args;
args << QLatin1String("diff") << state.relativeCurrentFile(); args << QLatin1String("diff") << state.relativeCurrentFile();
const CvsResponse diffResponse = const CvsResponse diffResponse = runCvs(state.currentFileTopLevel(), args);
runCvs(state.currentFileTopLevel(), args, m_settings.timeout.value());
switch (diffResponse.result) { switch (diffResponse.result) {
case CvsResponse::Ok: case CvsResponse::Ok:
return; // Not modified, diff exit code 0 return; // Not modified, diff exit code 0
@@ -884,8 +882,7 @@ void CvsPluginPrivate::revertCurrentFile()
// revert // revert
args.clear(); args.clear();
args << QLatin1String("update") << QLatin1String("-C") << state.relativeCurrentFile(); args << QLatin1String("update") << QLatin1String("-C") << state.relativeCurrentFile();
const auto revertResponse = runCvs(state.currentFileTopLevel(), args, const auto revertResponse = runCvs(state.currentFileTopLevel(), args, RunFlags::ShowStdOut);
m_settings.timeout.value(), RunFlags::ShowStdOut);
if (revertResponse.result == CvsResponse::Ok) if (revertResponse.result == CvsResponse::Ok)
emit filesChanged(QStringList(state.currentFile())); emit filesChanged(QStringList(state.currentFile()));
} }
@@ -948,8 +945,7 @@ void CvsPluginPrivate::startCommit(const FilePath &workingDir, const QString &fi
// We need the "Examining <subdir>" stderr output to tell // We need the "Examining <subdir>" stderr output to tell
// where we are, so, have stdout/stderr channels merged. // where we are, so, have stdout/stderr channels merged.
QStringList args = QStringList(QLatin1String("status")); QStringList args = QStringList(QLatin1String("status"));
const CvsResponse response = const CvsResponse response = runCvs(workingDir, args, RunFlags::MergeOutputChannels);
runCvs(workingDir, args, m_settings.timeout.value(), RunFlags::MergeOutputChannels);
if (response.result != CvsResponse::Ok) if (response.result != CvsResponse::Ok)
return; return;
// Get list of added/modified/deleted files and purge out undesired ones // Get list of added/modified/deleted files and purge out undesired ones
@@ -994,8 +990,7 @@ bool CvsPluginPrivate::commit(const QString &messageFile,
QStringList args = QStringList(QLatin1String("commit")); QStringList args = QStringList(QLatin1String("commit"));
args << QLatin1String("-F") << messageFile; args << QLatin1String("-F") << messageFile;
args.append(fileList); args.append(fileList);
const auto response = runCvs(m_commitRepository, args, 10 * m_settings.timeout.value(), const auto response = runCvs(m_commitRepository, args, RunFlags::ShowStdOut, nullptr, 10);
RunFlags::ShowStdOut);
return response.result == CvsResponse::Ok ; return response.result == CvsResponse::Ok ;
} }
@@ -1031,8 +1026,7 @@ void CvsPluginPrivate::filelog(const FilePath &workingDir,
QStringList args; QStringList args;
args << QLatin1String("log"); args << QLatin1String("log");
args.append(file); args.append(file);
const CvsResponse response = const CvsResponse response = runCvs(workingDir, args, RunFlags::None, codec);
runCvs(workingDir, args, m_settings.timeout.value(), RunFlags::None, codec);
if (response.result != CvsResponse::Ok) if (response.result != CvsResponse::Ok)
return; return;
@@ -1071,7 +1065,7 @@ bool CvsPluginPrivate::update(const FilePath &topLevel, const QString &file)
args.push_back(QLatin1String("-dR")); args.push_back(QLatin1String("-dR"));
if (!file.isEmpty()) if (!file.isEmpty())
args.append(file); args.append(file);
const auto response = runCvs(topLevel, args, 10 * m_settings.timeout.value(), RunFlags::ShowStdOut); const auto response = runCvs(topLevel, args, RunFlags::ShowStdOut, nullptr, 10);
const bool ok = response.result == CvsResponse::Ok; const bool ok = response.result == CvsResponse::Ok;
if (ok) if (ok)
emit repositoryChanged(topLevel); emit repositoryChanged(topLevel);
@@ -1116,7 +1110,7 @@ bool CvsPluginPrivate::edit(const FilePath &topLevel, const QStringList &files)
{ {
QStringList args(QLatin1String("edit")); QStringList args(QLatin1String("edit"));
args.append(files); args.append(files);
const auto response = runCvs(topLevel, args, m_settings.timeout.value(), RunFlags::ShowStdOut); const auto response = runCvs(topLevel, args, RunFlags::ShowStdOut);
return response.result == CvsResponse::Ok; return response.result == CvsResponse::Ok;
} }
@@ -1127,7 +1121,7 @@ bool CvsPluginPrivate::diffCheckModified(const FilePath &topLevel, const QString
QStringList args(QLatin1String("-q")); QStringList args(QLatin1String("-q"));
args << QLatin1String("diff"); args << QLatin1String("diff");
args.append(files); args.append(files);
const CvsResponse response = runCvs(topLevel, args, m_settings.timeout.value()); const CvsResponse response = runCvs(topLevel, args);
if (response.result == CvsResponse::OtherError) if (response.result == CvsResponse::OtherError)
return false; return false;
*modified = response.result == CvsResponse::NonNullExitCode; *modified = response.result == CvsResponse::NonNullExitCode;
@@ -1154,7 +1148,7 @@ bool CvsPluginPrivate::unedit(const FilePath &topLevel, const QStringList &files
if (modified) if (modified)
args.append(QLatin1String("-y")); args.append(QLatin1String("-y"));
args.append(files); args.append(files);
const auto response = runCvs(topLevel, args, m_settings.timeout.value(), RunFlags::ShowStdOut); const auto response = runCvs(topLevel, args, RunFlags::ShowStdOut);
return response.result == CvsResponse::Ok; return response.result == CvsResponse::Ok;
} }
@@ -1171,8 +1165,7 @@ void CvsPluginPrivate::annotate(const FilePath &workingDir, const QString &file,
if (!revision.isEmpty()) if (!revision.isEmpty())
args << QLatin1String("-r") << revision; args << QLatin1String("-r") << revision;
args << file; args << file;
const CvsResponse response = runCvs(workingDir, args, m_settings.timeout.value(), const CvsResponse response = runCvs(workingDir, args, RunFlags::None, codec);
RunFlags::None, codec);
if (response.result != CvsResponse::Ok) if (response.result != CvsResponse::Ok)
return; return;
@@ -1199,7 +1192,7 @@ bool CvsPluginPrivate::status(const FilePath &topLevel, const QString &file, con
QStringList args(QLatin1String("status")); QStringList args(QLatin1String("status"));
if (!file.isEmpty()) if (!file.isEmpty())
args.append(file); args.append(file);
const CvsResponse response = runCvs(topLevel, args, m_settings.timeout.value()); const CvsResponse response = runCvs(topLevel, args);
const bool ok = response.result == CvsResponse::Ok; const bool ok = response.result == CvsResponse::Ok;
if (ok) if (ok)
showOutputInEditor(title, response.stdOut, commandLogEditorParameters.id, topLevel.toString(), nullptr); showOutputInEditor(title, response.stdOut, commandLogEditorParameters.id, topLevel.toString(), nullptr);
@@ -1272,7 +1265,7 @@ bool CvsPluginPrivate::describe(const FilePath &toplevel, const QString &file, c
// Run log to obtain commit id and details // Run log to obtain commit id and details
QStringList args; QStringList args;
args << QLatin1String("log") << (QLatin1String("-r") + changeNr) << file; args << QLatin1String("log") << (QLatin1String("-r") + changeNr) << file;
const CvsResponse logResponse = runCvs(toplevel, args, m_settings.timeout.value()); const CvsResponse logResponse = runCvs(toplevel, args);
if (logResponse.result != CvsResponse::Ok) { if (logResponse.result != CvsResponse::Ok) {
*errorMessage = logResponse.message; *errorMessage = logResponse.message;
return false; return false;
@@ -1293,7 +1286,7 @@ bool CvsPluginPrivate::describe(const FilePath &toplevel, const QString &file, c
args.clear(); args.clear();
args << QLatin1String("log") << QLatin1String("-d") << (dateS + QLatin1Char('<') + nextDayS); args << QLatin1String("log") << QLatin1String("-d") << (dateS + QLatin1Char('<') + nextDayS);
const CvsResponse repoLogResponse = runCvs(toplevel, args, 10 * m_settings.timeout.value()); const CvsResponse repoLogResponse = runCvs(toplevel, args, RunFlags::None, nullptr, 10);
if (repoLogResponse.result != CvsResponse::Ok) { if (repoLogResponse.result != CvsResponse::Ok) {
*errorMessage = repoLogResponse.message; *errorMessage = repoLogResponse.message;
return false; return false;
@@ -1329,7 +1322,7 @@ bool CvsPluginPrivate::describe(const FilePath &repositoryPath,
// Run log // Run log
QStringList args(QLatin1String("log")); QStringList args(QLatin1String("log"));
args << (QLatin1String("-r") + it->revisions.front().revision) << it->file; args << (QLatin1String("-r") + it->revisions.front().revision) << it->file;
const CvsResponse logResponse = runCvs(repositoryPath, args, m_settings.timeout.value()); const CvsResponse logResponse = runCvs(repositoryPath, args);
if (logResponse.result != CvsResponse::Ok) { if (logResponse.result != CvsResponse::Ok) {
*errorMessage = logResponse.message; *errorMessage = logResponse.message;
return false; return false;
@@ -1345,8 +1338,7 @@ bool CvsPluginPrivate::describe(const FilePath &repositoryPath,
args << m_settings.diffOptions.value() args << m_settings.diffOptions.value()
<< QLatin1String("-r") << previousRev << QLatin1String("-r") << QLatin1String("-r") << previousRev << QLatin1String("-r")
<< it->revisions.front().revision << it->file; << it->revisions.front().revision << it->file;
const CvsResponse diffResponse = const CvsResponse diffResponse = runCvs(repositoryPath, args, RunFlags::None, codec);
runCvs(repositoryPath, args, m_settings.timeout.value(), RunFlags::None, codec);
switch (diffResponse.result) { switch (diffResponse.result) {
case CvsResponse::Ok: case CvsResponse::Ok:
case CvsResponse::NonNullExitCode: // Diff exit code != 0 case CvsResponse::NonNullExitCode: // Diff exit code != 0
@@ -1390,9 +1382,9 @@ void CvsPluginPrivate::commitFromEditor()
// the working directory (see above). // the working directory (see above).
CvsResponse CvsPluginPrivate::runCvs(const FilePath &workingDirectory, CvsResponse CvsPluginPrivate::runCvs(const FilePath &workingDirectory,
const QStringList &arguments, const QStringList &arguments,
int timeOutS,
RunFlags flags, RunFlags flags,
QTextCodec *outputCodec) const QTextCodec *outputCodec,
int timeoutMultiplier) const
{ {
const FilePath executable = m_settings.binaryPath.filePath(); const FilePath executable = m_settings.binaryPath.filePath();
CvsResponse response; CvsResponse response;
@@ -1402,9 +1394,10 @@ CvsResponse CvsPluginPrivate::runCvs(const FilePath &workingDirectory,
return response; return response;
} }
const int timeoutS = m_settings.timeout.value() * timeoutMultiplier;
const CommandResult result = m_client->vcsSynchronousExec(workingDirectory, const CommandResult result = m_client->vcsSynchronousExec(workingDirectory,
{executable, m_settings.addOptions(arguments)}, {executable, m_settings.addOptions(arguments)},
flags, timeOutS, outputCodec); flags, timeoutS, outputCodec);
response.result = CvsResponse::OtherError; response.result = CvsResponse::OtherError;
response.stdErr = result.cleanedStdErr(); response.stdErr = result.cleanedStdErr();
response.stdOut = result.cleanedStdOut(); response.stdOut = result.cleanedStdOut();
@@ -1451,7 +1444,7 @@ bool CvsPluginPrivate::vcsAdd(const FilePath &workingDir, const QString &rawFile
{ {
QStringList args; QStringList args;
args << QLatin1String("add") << rawFileName; args << QLatin1String("add") << rawFileName;
const auto response = runCvs(workingDir, args, m_settings.timeout.value(), RunFlags::ShowStdOut); const auto response = runCvs(workingDir, args, RunFlags::ShowStdOut);
return response.result == CvsResponse::Ok; return response.result == CvsResponse::Ok;
} }
@@ -1459,7 +1452,7 @@ bool CvsPluginPrivate::vcsDelete(const FilePath &workingDir, const QString &rawF
{ {
QStringList args; QStringList args;
args << QLatin1String("remove") << QLatin1String("-f") << rawFileName; args << QLatin1String("remove") << QLatin1String("-f") << rawFileName;
const auto response = runCvs(workingDir, args, m_settings.timeout.value(), RunFlags::ShowStdOut); const auto response = runCvs(workingDir, args, RunFlags::ShowStdOut);
return response.result == CvsResponse::Ok; return response.result == CvsResponse::Ok;
} }
@@ -1498,8 +1491,7 @@ bool CvsPluginPrivate::managesFile(const FilePath &workingDirectory, const QStri
{ {
QStringList args; QStringList args;
args << QLatin1String("status") << fileName; args << QLatin1String("status") << fileName;
const CvsResponse response = const CvsResponse response = runCvs(workingDirectory, args);
runCvs(workingDirectory, args, m_settings.timeout.value());
if (response.result != CvsResponse::Ok) if (response.result != CvsResponse::Ok)
return false; return false;
return !response.stdOut.contains(QLatin1String("Status: Unknown")); return !response.stdOut.contains(QLatin1String("Status: Unknown"));