VcsCommand: Remove unused SshPasswordPrompt

Change-Id: I402d619656d8339b1e81bc9ae96acf56178505d2
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
Jarek Kobus
2022-08-26 09:09:55 +02:00
parent aa361b886e
commit a50afa486a
7 changed files with 35 additions and 67 deletions

View File

@@ -113,8 +113,6 @@ const char CVS_SUBMIT_MIMETYPE[] = "text/vnd.qtcreator.cvs.submit";
const char CVSCOMMITEDITOR_ID[] = "CVS Commit Editor";
const char CVSCOMMITEDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("VCS", "CVS Commit Editor");
const int s_defaultFlags = VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut;
class CvsResponse
{
public:
@@ -310,7 +308,7 @@ private:
CvsResponse runCvs(const FilePath &workingDirectory,
const QStringList &arguments,
int timeOutS,
unsigned flags,
unsigned flags = 0,
QTextCodec *outputCodec = nullptr) const;
void annotate(const FilePath &workingDir, const QString &file,
@@ -873,7 +871,7 @@ void CvsPluginPrivate::revertAll()
QStringList args;
args << QLatin1String("update") << QLatin1String("-C") << state.topLevel().toString();
const auto revertResponse = runCvs(state.topLevel(), args, m_settings.timeout.value(),
s_defaultFlags);
VcsCommand::ShowStdOut);
if (revertResponse.result == CvsResponse::Ok)
emit repositoryChanged(state.topLevel());
else
@@ -910,7 +908,7 @@ void CvsPluginPrivate::revertCurrentFile()
args.clear();
args << QLatin1String("update") << QLatin1String("-C") << state.relativeCurrentFile();
const auto revertResponse = runCvs(state.currentFileTopLevel(), args,
m_settings.timeout.value(), s_defaultFlags);
m_settings.timeout.value(), VcsCommand::ShowStdOut);
if (revertResponse.result == CvsResponse::Ok)
emit filesChanged(QStringList(state.currentFile()));
}
@@ -1020,7 +1018,7 @@ bool CvsPluginPrivate::commit(const QString &messageFile,
args << QLatin1String("-F") << messageFile;
args.append(fileList);
const auto response = runCvs(m_commitRepository, args, 10 * m_settings.timeout.value(),
s_defaultFlags);
VcsCommand::ShowStdOut);
return response.result == CvsResponse::Ok ;
}
@@ -1057,8 +1055,7 @@ void CvsPluginPrivate::filelog(const FilePath &workingDir,
args << QLatin1String("log");
args.append(file);
const CvsResponse response =
runCvs(workingDir, args, m_settings.timeout.value(),
VcsCommand::SshPasswordPrompt, codec);
runCvs(workingDir, args, m_settings.timeout.value(), 0, codec);
if (response.result != CvsResponse::Ok)
return;
@@ -1097,7 +1094,7 @@ bool CvsPluginPrivate::update(const FilePath &topLevel, const QString &file)
args.push_back(QLatin1String("-dR"));
if (!file.isEmpty())
args.append(file);
const auto response = runCvs(topLevel, args, 10 * m_settings.timeout.value(), s_defaultFlags);
const auto response = runCvs(topLevel, args, 10 * m_settings.timeout.value(), VcsCommand::ShowStdOut);
const bool ok = response.result == CvsResponse::Ok;
if (ok)
emit repositoryChanged(topLevel);
@@ -1142,7 +1139,7 @@ bool CvsPluginPrivate::edit(const FilePath &topLevel, const QStringList &files)
{
QStringList args(QLatin1String("edit"));
args.append(files);
const auto response = runCvs(topLevel, args, m_settings.timeout.value(), s_defaultFlags);
const auto response = runCvs(topLevel, args, m_settings.timeout.value(), VcsCommand::ShowStdOut);
return response.result == CvsResponse::Ok;
}
@@ -1180,7 +1177,7 @@ bool CvsPluginPrivate::unedit(const FilePath &topLevel, const QStringList &files
if (modified)
args.append(QLatin1String("-y"));
args.append(files);
const auto response = runCvs(topLevel, args, m_settings.timeout.value(), s_defaultFlags);
const auto response = runCvs(topLevel, args, m_settings.timeout.value(), VcsCommand::ShowStdOut);
return response.result == CvsResponse::Ok;
}
@@ -1197,8 +1194,7 @@ void CvsPluginPrivate::annotate(const FilePath &workingDir, const QString &file,
if (!revision.isEmpty())
args << QLatin1String("-r") << revision;
args << file;
const CvsResponse response = runCvs(workingDir, args, m_settings.timeout.value(),
VcsCommand::SshPasswordPrompt, codec);
const CvsResponse response = runCvs(workingDir, args, m_settings.timeout.value(), 0, codec);
if (response.result != CvsResponse::Ok)
return;
@@ -1299,8 +1295,7 @@ bool CvsPluginPrivate::describe(const FilePath &toplevel, const QString &file, c
// Run log to obtain commit id and details
QStringList args;
args << QLatin1String("log") << (QLatin1String("-r") + changeNr) << file;
const CvsResponse logResponse = runCvs(toplevel, args, m_settings.timeout.value(),
VcsCommand::SshPasswordPrompt);
const CvsResponse logResponse = runCvs(toplevel, args, m_settings.timeout.value());
if (logResponse.result != CvsResponse::Ok) {
*errorMessage = logResponse.message;
return false;
@@ -1321,8 +1316,7 @@ bool CvsPluginPrivate::describe(const FilePath &toplevel, const QString &file, c
args.clear();
args << QLatin1String("log") << QLatin1String("-d") << (dateS + QLatin1Char('<') + nextDayS);
const CvsResponse repoLogResponse = runCvs(toplevel, args, 10 * m_settings.timeout.value(),
VcsCommand::SshPasswordPrompt);
const CvsResponse repoLogResponse = runCvs(toplevel, args, 10 * m_settings.timeout.value());
if (repoLogResponse.result != CvsResponse::Ok) {
*errorMessage = repoLogResponse.message;
return false;
@@ -1358,8 +1352,7 @@ bool CvsPluginPrivate::describe(const FilePath &repositoryPath,
// Run log
QStringList args(QLatin1String("log"));
args << (QLatin1String("-r") + it->revisions.front().revision) << it->file;
const CvsResponse logResponse = runCvs(repositoryPath, args, m_settings.timeout.value(),
VcsCommand::SshPasswordPrompt);
const CvsResponse logResponse = runCvs(repositoryPath, args, m_settings.timeout.value());
if (logResponse.result != CvsResponse::Ok) {
*errorMessage = logResponse.message;
return false;
@@ -1487,7 +1480,7 @@ bool CvsPluginPrivate::vcsAdd(const FilePath &workingDir, const QString &rawFile
{
QStringList args;
args << QLatin1String("add") << rawFileName;
const auto response = runCvs(workingDir, args, m_settings.timeout.value(), s_defaultFlags);
const auto response = runCvs(workingDir, args, m_settings.timeout.value(), VcsCommand::ShowStdOut);
return response.result == CvsResponse::Ok;
}
@@ -1495,7 +1488,7 @@ bool CvsPluginPrivate::vcsDelete(const FilePath &workingDir, const QString &rawF
{
QStringList args;
args << QLatin1String("remove") << QLatin1String("-f") << rawFileName;
const auto response = runCvs(workingDir, args, m_settings.timeout.value(), s_defaultFlags);
const auto response = runCvs(workingDir, args, m_settings.timeout.value(), VcsCommand::ShowStdOut);
return response.result == CvsResponse::Ok;
}
@@ -1535,7 +1528,7 @@ bool CvsPluginPrivate::managesFile(const FilePath &workingDirectory, const QStri
QStringList args;
args << QLatin1String("status") << fileName;
const CvsResponse response =
runCvs(workingDirectory, args, m_settings.timeout.value(), VcsCommand::SshPasswordPrompt);
runCvs(workingDirectory, args, m_settings.timeout.value());
if (response.result != CvsResponse::Ok)
return false;
return !response.stdOut.contains(QLatin1String("Status: Unknown"));

View File

@@ -2500,11 +2500,9 @@ void GitClient::continuePreviousGitCommand(const FilePath &workingDirectory,
QStringList GitClient::synchronousRepositoryBranches(const QString &repositoryURL,
const FilePath &workingDirectory) const
{
const unsigned flags = VcsCommand::SshPasswordPrompt
| VcsCommand::SuppressStdErr
| VcsCommand::SuppressFailMessage;
const CommandResult result = vcsSynchronousExec(workingDirectory,
{"ls-remote", repositoryURL, HEAD, "refs/heads/*"}, flags);
{"ls-remote", repositoryURL, HEAD, "refs/heads/*"},
VcsCommand::SuppressStdErr | VcsCommand::SuppressFailMessage);
QStringList branches;
branches << tr("<Detached HEAD>");
QString headSha;
@@ -3121,9 +3119,7 @@ bool GitClient::executeAndHandleConflicts(const FilePath &workingDirectory,
const QStringList &arguments,
const QString &abortCommand) const
{
// Disable UNIX terminals to suppress SSH prompting.
const unsigned flags = VcsCommand::SshPasswordPrompt
| VcsCommand::ShowStdOut
const unsigned flags = VcsCommand::ShowStdOut
| VcsCommand::ExpectRepoChanges
| VcsCommand::ShowSuccessMessage;
const CommandResult result = vcsSynchronousExec(workingDirectory, arguments, flags);
@@ -3254,11 +3250,8 @@ void GitClient::addFuture(const QFuture<void> &future)
// Subversion: git svn
void GitClient::synchronousSubversionFetch(const FilePath &workingDirectory) const
{
// Disable UNIX terminals to suppress SSH prompting.
const unsigned flags = VcsCommand::SshPasswordPrompt
| VcsCommand::ShowStdOut
| VcsCommand::ShowSuccessMessage;
vcsSynchronousExec(workingDirectory, {"svn", "fetch"}, flags);
vcsSynchronousExec(workingDirectory, {"svn", "fetch"},
VcsCommand::ShowStdOut | VcsCommand::ShowSuccessMessage);
}
void GitClient::subversionLog(const FilePath &workingDirectory) const
@@ -3427,9 +3420,7 @@ VcsCommand *GitClient::vcsExecAbortable(const FilePath &workingDirectory,
if (abortCommand.isEmpty())
abortCommand = arguments.at(0);
VcsCommand *command = createCommand(workingDirectory, nullptr, VcsWindowOutputBind);
command->addFlags(VcsCommand::SshPasswordPrompt
| VcsCommand::ShowStdOut
| VcsCommand::ShowSuccessMessage);
command->addFlags(VcsCommand::ShowStdOut | VcsCommand::ShowSuccessMessage);
// For rebase, Git might request an editor (which means the process keeps running until the
// user closes it), so run without timeout.
command->addJob({vcsBinary(), arguments}, isRebase ? 0 : vcsTimeoutS());

View File

@@ -118,9 +118,7 @@ bool MercurialClient::synchronousClone(const FilePath &workingDirectory,
{
Q_UNUSED(srcLocation)
Q_UNUSED(extraOptions)
const unsigned flags = VcsCommand::SshPasswordPrompt
| VcsCommand::ShowStdOut
| VcsCommand::ShowSuccessMessage;
const unsigned flags = VcsCommand::ShowStdOut | VcsCommand::ShowSuccessMessage;
if (workingDirectory.exists()) {
// Let's make first init
@@ -164,17 +162,13 @@ bool MercurialClient::synchronousPull(const FilePath &workingDir, const QString
{
QStringList args;
args << vcsCommandString(PullCommand) << extraOptions << srcLocation;
// Disable UNIX terminals to suppress SSH prompting
const unsigned flags = VcsCommand::SshPasswordPrompt
| VcsCommand::ShowStdOut
| VcsCommand::ShowSuccessMessage;
// cause mercurial doesn`t understand LANG
Environment env = Environment::systemEnvironment();
env.set("LANGUAGE", "C");
VcsCommand *command = VcsBaseClient::createVcsCommand(workingDir, env);
command->addFlags(flags);
command->addFlags(VcsCommand::ShowStdOut | VcsCommand::ShowSuccessMessage);
const CommandResult result = command->runCommand({vcsBinary(), args}, vcsTimeoutS());
delete command;

View File

@@ -222,7 +222,7 @@ void SubversionDiffEditorController::requestDescription()
args << m_authenticationOptions;
args << QLatin1String("-r");
args << QString::number(m_changeNumber);
runCommand(QList<QStringList>() << args, VcsCommand::SshPasswordPrompt);
runCommand(QList<QStringList>() << args, 0);
}
void SubversionDiffEditorController::requestDiff()

View File

@@ -108,8 +108,6 @@ const char CMD_ID_UPDATE[] = "Subversion.Update";
const char CMD_ID_COMMIT_PROJECT[] = "Subversion.CommitProject";
const char CMD_ID_DESCRIBE[] = "Subversion.Describe";
const int s_defaultFlags = VcsCommand::SshPasswordPrompt | VcsCommand::ShowStdOut;
struct SubversionResponse
{
bool error = false;
@@ -694,7 +692,7 @@ void SubversionPluginPrivate::revertAll()
args << QLatin1String("revert");
args << SubversionClient::addAuthenticationOptions(m_settings);
args << QLatin1String("--recursive") << state.topLevel().toString();
const auto revertResponse = runSvn(state.topLevel(), args, s_defaultFlags);
const auto revertResponse = runSvn(state.topLevel(), args, VcsCommand::ShowStdOut);
if (revertResponse.error)
QMessageBox::warning(ICore::dialogParent(), title,
tr("Revert failed: %1").arg(revertResponse.message), QMessageBox::Ok);
@@ -731,7 +729,7 @@ void SubversionPluginPrivate::revertCurrentFile()
args << SubversionClient::addAuthenticationOptions(m_settings);
args << SubversionClient::escapeFile(state.relativeCurrentFile());
const auto revertResponse = runSvn(state.currentFileTopLevel(), args, s_defaultFlags);
const auto revertResponse = runSvn(state.currentFileTopLevel(), args, VcsCommand::ShowStdOut);
if (!revertResponse.error)
emit filesChanged(QStringList(state.currentFile()));
@@ -900,7 +898,7 @@ void SubversionPluginPrivate::svnUpdate(const FilePath &workingDir, const QStrin
args.push_back(QLatin1String(Constants::NON_INTERACTIVE_OPTION));
if (!relativePath.isEmpty())
args.append(relativePath);
const auto response = runSvn(workingDir, args, s_defaultFlags, 10);
const auto response = runSvn(workingDir, args, VcsCommand::ShowStdOut, 10);
if (!response.error)
emit repositoryChanged(workingDir);
}
@@ -928,8 +926,7 @@ void SubversionPluginPrivate::vcsAnnotateHelper(const FilePath &workingDir, cons
args.push_back(QLatin1String("-v"));
args.append(QDir::toNativeSeparators(SubversionClient::escapeFile(file)));
const auto response = runSvn(workingDir, args,
VcsCommand::SshPasswordPrompt | VcsCommand::ForceCLocale, 1, codec);
const auto response = runSvn(workingDir, args, VcsCommand::ForceCLocale, 1, codec);
if (response.error)
return;
@@ -1086,7 +1083,7 @@ bool SubversionPluginPrivate::vcsAdd(const FilePath &workingDir, const QString &
args << QLatin1String("add")
<< SubversionClient::addAuthenticationOptions(m_settings)
<< QLatin1String("--parents") << file;
const auto response = runSvn(workingDir, args, s_defaultFlags);
const auto response = runSvn(workingDir, args, VcsCommand::ShowStdOut);
return !response.error;
}
@@ -1099,7 +1096,7 @@ bool SubversionPluginPrivate::vcsDelete(const FilePath &workingDir, const QStrin
args << SubversionClient::addAuthenticationOptions(m_settings)
<< QLatin1String("--force") << file;
const auto response = runSvn(workingDir, args, s_defaultFlags);
const auto response = runSvn(workingDir, args, VcsCommand::ShowStdOut);
return !response.error;
}
@@ -1110,7 +1107,7 @@ bool SubversionPluginPrivate::vcsMove(const FilePath &workingDir, const QString
args << QDir::toNativeSeparators(SubversionClient::escapeFile(from))
<< QDir::toNativeSeparators(SubversionClient::escapeFile(to));
const auto response = runSvn(workingDir, args,
s_defaultFlags | VcsCommand::FullySynchronously);
VcsCommand::ShowStdOut | VcsCommand::FullySynchronously);
return !response.error;
}
@@ -1136,7 +1133,7 @@ bool SubversionPluginPrivate::vcsCheckout(const FilePath &directory, const QByte
args << QLatin1String(tempUrl.toEncoded()) << directory.toString();
const auto response = runSvn(directory, args, VcsCommand::SshPasswordPrompt, 10);
const auto response = runSvn(directory, args, 0, 10);
return !response.error;
}

View File

@@ -329,10 +329,7 @@ bool VcsBaseClient::synchronousPull(const FilePath &workingDir,
{
QStringList args;
args << vcsCommandString(PullCommand) << extraOptions << srcLocation;
// Disable UNIX terminals to suppress SSH prompting
const unsigned flags = VcsCommand::SshPasswordPrompt
| VcsCommand::ShowStdOut
| VcsCommand::ShowSuccessMessage;
const unsigned flags = VcsCommand::ShowStdOut | VcsCommand::ShowSuccessMessage;
const bool ok = vcsSynchronousExec(workingDir, args, flags).result()
== ProcessResult::FinishedWithSuccess;
if (ok)
@@ -346,10 +343,7 @@ bool VcsBaseClient::synchronousPush(const FilePath &workingDir,
{
QStringList args;
args << vcsCommandString(PushCommand) << extraOptions << dstLocation;
// Disable UNIX terminals to suppress SSH prompting
const unsigned flags = VcsCommand::SshPasswordPrompt
| VcsCommand::ShowStdOut
| VcsCommand::ShowSuccessMessage;
const unsigned flags = VcsCommand::ShowStdOut | VcsCommand::ShowSuccessMessage;
return vcsSynchronousExec(workingDir, args, flags).result()
== ProcessResult::FinishedWithSuccess;
}

View File

@@ -114,8 +114,7 @@ public:
// triggered by file watchers).
SilentOutput = 0x100, // Suppress user notifications about the output happening.
NoFullySync = 0x200, // Avoid fully synchronous execution even in UI thread.
SshPasswordPrompt = 0x400, // Disable terminal on UNIX to force graphical prompt.
ExpectRepoChanges = 0x800, // Expect changes in repository by the command
ExpectRepoChanges = 0x400, // Expect changes in repository by the command
NoOutput = SuppressStdErr | SuppressFailMessage | SuppressCommandLogging
};