summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2021-08-11 10:02:58 +0200
committerhjk <hjk@qt.io>2021-08-17 07:16:04 +0000
commitbbde6ac9bf1ac3cee0d87ff526783fd9a50c91a7 (patch)
tree535c1ddd1958d7ecb616312c6d512ee2911229e4 /src
parent2aaa0a2180e7515423934351a9b1c2873987982d (diff)
downloadqt-creator-bbde6ac9bf1ac3cee0d87ff526783fd9a50c91a7.tar.gz
VCS: Use more FilePath in ShellCommand and surroundings
Change-Id: Ie8c5fac09b45a54bcbe9a876044b653e7fccede5 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/libs/utils/shellcommand.cpp37
-rw-r--r--src/libs/utils/shellcommand.h22
-rw-r--r--src/plugins/coreplugin/shellcommand.cpp4
-rw-r--r--src/plugins/coreplugin/shellcommand.h2
-rw-r--r--src/plugins/coreplugin/vcsmanager.cpp4
-rw-r--r--src/plugins/coreplugin/vcsmanager.h2
-rw-r--r--src/plugins/git/gerrit/gerritmodel.cpp2
-rw-r--r--src/plugins/git/gerrit/gerritplugin.cpp2
-rw-r--r--src/plugins/git/gitclient.cpp7
-rw-r--r--src/plugins/git/mergetool.cpp4
-rw-r--r--src/plugins/git/mergetool.h4
-rw-r--r--src/plugins/perforce/perforceplugin.cpp2
-rw-r--r--src/plugins/updateinfo/updateinfoplugin.cpp4
-rw-r--r--src/plugins/vcsbase/vcsbaseclient.cpp4
-rw-r--r--src/plugins/vcsbase/vcsbaseclient.h2
-rw-r--r--src/plugins/vcsbase/vcscommand.cpp6
-rw-r--r--src/plugins/vcsbase/vcscommand.h4
-rw-r--r--src/plugins/vcsbase/vcsoutputwindow.cpp11
-rw-r--r--src/plugins/vcsbase/vcsoutputwindow.h10
-rw-r--r--src/plugins/vcsbase/wizard/vcscommandpage.cpp8
-rw-r--r--src/plugins/vcsbase/wizard/vcscommandpage.h26
21 files changed, 84 insertions, 83 deletions
diff --git a/src/libs/utils/shellcommand.cpp b/src/libs/utils/shellcommand.cpp
index 50fd328206..b803db8f0a 100644
--- a/src/libs/utils/shellcommand.cpp
+++ b/src/libs/utils/shellcommand.cpp
@@ -69,16 +69,16 @@ class ShellCommandPrivate
{
public:
struct Job {
- explicit Job(const QString &wd, const CommandLine &command, int t,
+ explicit Job(const FilePath &wd, const CommandLine &command, int t,
const ExitCodeInterpreter &interpreter);
- QString workingDirectory;
+ FilePath workingDirectory;
CommandLine command;
ExitCodeInterpreter exitCodeInterpreter;
int timeoutS;
};
- ShellCommandPrivate(const QString &defaultWorkingDirectory, const Environment &environment)
+ ShellCommandPrivate(const FilePath &defaultWorkingDirectory, const Environment &environment)
: m_defaultWorkingDirectory(defaultWorkingDirectory),
m_environment(environment)
{}
@@ -86,7 +86,7 @@ public:
~ShellCommandPrivate() { delete m_progressParser; }
QString m_displayName;
- const QString m_defaultWorkingDirectory;
+ const FilePath m_defaultWorkingDirectory;
const Environment m_environment;
QVariant m_cookie;
QTextCodec *m_codec = nullptr;
@@ -105,7 +105,7 @@ public:
bool m_disableUnixTerminal = false;
};
-ShellCommandPrivate::Job::Job(const QString &wd, const CommandLine &command,
+ShellCommandPrivate::Job::Job(const FilePath &wd, const CommandLine &command,
int t, const ExitCodeInterpreter &interpreter) :
workingDirectory(wd),
command(command),
@@ -119,8 +119,7 @@ ShellCommandPrivate::Job::Job(const QString &wd, const CommandLine &command,
} // namespace Internal
-ShellCommand::ShellCommand(const QString &workingDirectory,
- const Environment &environment) :
+ShellCommand::ShellCommand(const FilePath &workingDirectory, const Environment &environment) :
d(new Internal::ShellCommandPrivate(workingDirectory, environment))
{
connect(&d->m_watcher, &QFutureWatcher<void>::canceled, this, &ShellCommand::cancel);
@@ -156,7 +155,7 @@ void ShellCommand::setDisplayName(const QString &name)
d->m_displayName = name;
}
-const QString &ShellCommand::defaultWorkingDirectory() const
+const FilePath &ShellCommand::defaultWorkingDirectory() const
{
return d->m_defaultWorkingDirectory;
}
@@ -187,13 +186,15 @@ void ShellCommand::addFlags(unsigned f)
}
void ShellCommand::addJob(const CommandLine &command,
- const QString &workingDirectory, const ExitCodeInterpreter &interpreter)
+ const FilePath &workingDirectory,
+ const ExitCodeInterpreter &interpreter)
{
addJob(command, defaultTimeoutS(), workingDirectory, interpreter);
}
void ShellCommand::addJob(const CommandLine &command, int timeoutS,
- const QString &workingDirectory, const ExitCodeInterpreter &interpreter)
+ const FilePath &workingDirectory,
+ const ExitCodeInterpreter &interpreter)
{
d->m_jobs.push_back(Internal::ShellCommandPrivate::Job(workDirectory(workingDirectory), command,
timeoutS, interpreter));
@@ -237,7 +238,7 @@ int ShellCommand::timeoutS() const
});
}
-QString ShellCommand::workDirectory(const QString &wd) const
+FilePath ShellCommand::workDirectory(const FilePath &wd) const
{
if (!wd.isEmpty())
return wd;
@@ -308,9 +309,9 @@ void ShellCommand::run(QFutureInterface<void> &future)
void ShellCommand::runCommand(QtcProcess &proc,
const CommandLine &command,
- const QString &workingDirectory)
+ const FilePath &workingDirectory)
{
- const QString dir = workDirectory(workingDirectory);
+ const FilePath dir = workDirectory(workingDirectory);
if (command.executable().isEmpty()) {
proc.setResult(QtcProcess::StartFailed);
@@ -340,13 +341,12 @@ void ShellCommand::runCommand(QtcProcess &proc,
}
}
-void ShellCommand::runFullySynchronous(QtcProcess &process,
- const QString &workingDirectory)
+void ShellCommand::runFullySynchronous(QtcProcess &process, const FilePath &workingDirectory)
{
// Set up process
if (d->m_disableUnixTerminal)
process.setDisableUnixTerminal();
- const QString dir = workDirectory(workingDirectory);
+ const FilePath dir = workDirectory(workingDirectory);
if (!dir.isEmpty())
process.setWorkingDirectory(dir);
process.setEnvironment(processEnvironment());
@@ -372,8 +372,7 @@ void ShellCommand::runFullySynchronous(QtcProcess &process,
}
}
-void ShellCommand::runSynchronous(QtcProcess &process,
- const QString &workingDirectory)
+void ShellCommand::runSynchronous(QtcProcess &process, const FilePath &workingDirectory)
{
connect(this, &ShellCommand::terminate, &process, &QtcProcess::stopProcess);
process.setEnvironment(processEnvironment());
@@ -381,7 +380,7 @@ void ShellCommand::runSynchronous(QtcProcess &process,
process.setCodec(d->m_codec);
if (d->m_disableUnixTerminal)
process.setDisableUnixTerminal();
- const QString dir = workDirectory(workingDirectory);
+ const FilePath dir = workDirectory(workingDirectory);
if (!dir.isEmpty())
process.setWorkingDirectory(dir);
// connect stderr to the output window if desired
diff --git a/src/libs/utils/shellcommand.h b/src/libs/utils/shellcommand.h
index 9ac01bc9d0..dcdd0795f1 100644
--- a/src/libs/utils/shellcommand.h
+++ b/src/libs/utils/shellcommand.h
@@ -82,24 +82,24 @@ public:
};
- ShellCommand(const QString &workingDirectory, const Environment &environment);
+ ShellCommand(const FilePath &workingDirectory, const Environment &environment);
~ShellCommand() override;
QString displayName() const;
void setDisplayName(const QString &name);
void addJob(const CommandLine &command,
- const QString &workingDirectory = QString(),
+ const FilePath &workingDirectory = {},
const ExitCodeInterpreter &interpreter = {});
void addJob(const CommandLine &command, int timeoutS,
- const QString &workingDirectory = QString(),
+ const FilePath &workingDirectory = {},
const ExitCodeInterpreter &interpreter = {});
void execute(); // Execute tasks asynchronously!
void abort();
bool lastExecutionSuccess() const;
int lastExecutionExitCode() const;
- const QString &defaultWorkingDirectory() const;
+ const FilePath &defaultWorkingDirectory() const;
virtual const Environment processEnvironment() const;
int defaultTimeoutS() const;
@@ -123,9 +123,9 @@ public:
// This is called once per job in a thread.
// When called from the UI thread it will execute fully synchronously, so no signals will
// be triggered!
- virtual void runCommand(Utils::QtcProcess &process,
+ virtual void runCommand(QtcProcess &process,
const CommandLine &command,
- const QString &workingDirectory = QString());
+ const FilePath &workingDirectory = {});
void cancel();
@@ -141,23 +141,21 @@ signals:
void append(const QString &text);
void appendSilently(const QString &text);
void appendError(const QString &text);
- void appendCommand(const QString &workingDirectory, const Utils::CommandLine &command);
+ void appendCommand(const Utils::FilePath &workingDirectory, const Utils::CommandLine &command);
void appendMessage(const QString &text);
protected:
virtual void addTask(QFuture<void> &future);
int timeoutS() const;
- QString workDirectory(const QString &wd) const;
+ FilePath workDirectory(const FilePath &wd) const;
private:
void run(QFutureInterface<void> &future);
// Run without a event loop in fully blocking mode. No signals will be delivered.
- void runFullySynchronous(QtcProcess &proc,
- const QString &workingDirectory);
+ void runFullySynchronous(QtcProcess &proc, const FilePath &workingDirectory);
// Run with an event loop. Signals will be delivered.
- void runSynchronous(QtcProcess &proc,
- const QString &workingDirectory);
+ void runSynchronous(QtcProcess &proc, const FilePath &workingDirectory);
class Internal::ShellCommandPrivate *const d;
};
diff --git a/src/plugins/coreplugin/shellcommand.cpp b/src/plugins/coreplugin/shellcommand.cpp
index 38dbfdea44..a945192add 100644
--- a/src/plugins/coreplugin/shellcommand.cpp
+++ b/src/plugins/coreplugin/shellcommand.cpp
@@ -31,9 +31,11 @@
#include <QFutureInterface>
#include <QFutureWatcher>
+using namespace Utils;
+
namespace Core {
-ShellCommand::ShellCommand(const QString &workingDirectory, const Utils::Environment &environment) :
+ShellCommand::ShellCommand(const FilePath &workingDirectory, const Environment &environment) :
Utils::ShellCommand(workingDirectory, environment)
{
connect(Core::ICore::instance(), &Core::ICore::coreAboutToClose,
diff --git a/src/plugins/coreplugin/shellcommand.h b/src/plugins/coreplugin/shellcommand.h
index 37026a82d7..6f5a085f01 100644
--- a/src/plugins/coreplugin/shellcommand.h
+++ b/src/plugins/coreplugin/shellcommand.h
@@ -40,7 +40,7 @@ class CORE_EXPORT ShellCommand : public Utils::ShellCommand
Q_OBJECT
public:
- ShellCommand(const QString &workingDirectory, const Utils::Environment &environment);
+ ShellCommand(const Utils::FilePath &workingDirectory, const Utils::Environment &environment);
FutureProgress *futureProgress() const;
diff --git a/src/plugins/coreplugin/vcsmanager.cpp b/src/plugins/coreplugin/vcsmanager.cpp
index 80d4889f3a..d4fed2d7d8 100644
--- a/src/plugins/coreplugin/vcsmanager.cpp
+++ b/src/plugins/coreplugin/vcsmanager.cpp
@@ -458,9 +458,9 @@ void VcsManager::promptToAdd(const QString &directory, const QStringList &fileNa
}
}
-void VcsManager::emitRepositoryChanged(const QString &repository)
+void VcsManager::emitRepositoryChanged(const FilePath &repository)
{
- emit m_instance->repositoryChanged(FilePath::fromString(repository));
+ emit m_instance->repositoryChanged(repository);
}
void VcsManager::clearVersionControlCache()
diff --git a/src/plugins/coreplugin/vcsmanager.h b/src/plugins/coreplugin/vcsmanager.h
index 6cb5241e91..7cb15f2f58 100644
--- a/src/plugins/coreplugin/vcsmanager.h
+++ b/src/plugins/coreplugin/vcsmanager.h
@@ -82,7 +82,7 @@ public:
// added to revision control. Calls vcsAdd for each file.
static void promptToAdd(const QString &directory, const QStringList &fileNames);
- static void emitRepositoryChanged(const QString &repository);
+ static void emitRepositoryChanged(const Utils::FilePath &repository);
// Utility messages for adding files
static QString msgAddToVcsTitle();
diff --git a/src/plugins/git/gerrit/gerritmodel.cpp b/src/plugins/git/gerrit/gerritmodel.cpp
index aae9f0ede7..f1b6f593fa 100644
--- a/src/plugins/git/gerrit/gerritmodel.cpp
+++ b/src/plugins/git/gerrit/gerritmodel.cpp
@@ -321,7 +321,7 @@ void QueryContext::start()
fp->setKeepOnFinish(Core::FutureProgress::HideOnFinish);
m_progress.reportStarted();
// Order: synchronous call to error handling if something goes wrong.
- VcsOutputWindow::appendCommand(m_process.workingDirectory().toString(),
+ VcsOutputWindow::appendCommand(m_process.workingDirectory(),
{FilePath::fromString(m_binary), m_arguments});
m_timer.start();
m_process.setCommand({FilePath::fromString(m_binary), m_arguments});
diff --git a/src/plugins/git/gerrit/gerritplugin.cpp b/src/plugins/git/gerrit/gerritplugin.cpp
index fbb95fa162..920e942049 100644
--- a/src/plugins/git/gerrit/gerritplugin.cpp
+++ b/src/plugins/git/gerrit/gerritplugin.cpp
@@ -169,7 +169,7 @@ void FetchContext::start()
m_progress.reportStarted();
// Order: initialize future before starting the process in case error handling is invoked.
const QStringList args = m_change->gitFetchArguments(m_server);
- VcsBase::VcsOutputWindow::appendCommand(m_repository.toString(), {m_git, args});
+ VcsBase::VcsOutputWindow::appendCommand(m_repository, {m_git, args});
m_process.setCommand({m_git, args});
m_process.start();
}
diff --git a/src/plugins/git/gitclient.cpp b/src/plugins/git/gitclient.cpp
index 3898758558..c743f61504 100644
--- a/src/plugins/git/gitclient.cpp
+++ b/src/plugins/git/gitclient.cpp
@@ -663,7 +663,7 @@ class ConflictHandler final : public QObject
Q_OBJECT
public:
static void attachToCommand(VcsCommand *command, const QString &abortCommand = QString()) {
- auto handler = new ConflictHandler(FilePath::fromString(command->defaultWorkingDirectory()), abortCommand);
+ auto handler = new ConflictHandler(command->defaultWorkingDirectory(), abortCommand);
handler->setParent(command); // delete when command goes out of scope
command->addFlags(VcsCommand::ExpectRepoChanges);
@@ -1059,7 +1059,7 @@ void GitClient::diffBranch(const FilePath &workingDirectory, const QString &bran
void GitClient::merge(const FilePath &workingDirectory, const QStringList &unmergedFileNames)
{
auto mergeTool = new MergeTool(this);
- if (!mergeTool->start(workingDirectory.toString(), unmergedFileNames))
+ if (!mergeTool->start(workingDirectory, unmergedFileNames))
delete mergeTool;
}
@@ -2593,8 +2593,7 @@ bool GitClient::tryLauchingGitK(const Environment &env,
arguments.append(ProcessArgs::splitArgs(gitkOpts, HostOsInfo::hostOs()));
if (!fileName.isEmpty())
arguments << "--" << fileName;
- VcsOutputWindow::appendCommand(workingDirectory.toString(),
- {FilePath::fromString(binary), arguments});
+ VcsOutputWindow::appendCommand(workingDirectory, {FilePath::fromString(binary), arguments});
// This should always use QProcess::startDetached (as not to kill
// the child), but that does not have an environment parameter.
bool success = false;
diff --git a/src/plugins/git/mergetool.cpp b/src/plugins/git/mergetool.cpp
index 8441231b4a..5c63cb3285 100644
--- a/src/plugins/git/mergetool.cpp
+++ b/src/plugins/git/mergetool.cpp
@@ -50,7 +50,7 @@ MergeTool::~MergeTool()
delete m_process;
}
-bool MergeTool::start(const QString &workingDirectory, const QStringList &files)
+bool MergeTool::start(const FilePath &workingDirectory, const QStringList &files)
{
QStringList arguments;
arguments << "mergetool" << "-y" << files;
@@ -58,7 +58,7 @@ bool MergeTool::start(const QString &workingDirectory, const QStringList &files)
env.insert("LANG", "C");
env.insert("LANGUAGE", "C");
m_process = new QProcess(this);
- m_process->setWorkingDirectory(workingDirectory);
+ m_process->setWorkingDirectory(workingDirectory.toString());
m_process->setProcessEnvironment(env);
m_process->setProcessChannelMode(QProcess::MergedChannels);
const Utils::FilePath binary = GitClient::instance()->vcsBinary();
diff --git a/src/plugins/git/mergetool.h b/src/plugins/git/mergetool.h
index 667ba09fdb..d9d3be6283 100644
--- a/src/plugins/git/mergetool.h
+++ b/src/plugins/git/mergetool.h
@@ -33,6 +33,8 @@ class QMessageBox;
class QProcess;
QT_END_NAMESPACE
+namespace Utils { class FilePath; }
+
namespace Git {
namespace Internal {
@@ -52,7 +54,7 @@ class MergeTool : public QObject
public:
explicit MergeTool(QObject *parent = nullptr);
~MergeTool() override;
- bool start(const QString &workingDirectory, const QStringList &files = QStringList());
+ bool start(const Utils::FilePath &workingDirectory, const QStringList &files = {});
enum MergeType {
NormalMerge,
diff --git a/src/plugins/perforce/perforceplugin.cpp b/src/plugins/perforce/perforceplugin.cpp
index 3734704c96..d393214a43 100644
--- a/src/plugins/perforce/perforceplugin.cpp
+++ b/src/plugins/perforce/perforceplugin.cpp
@@ -1377,7 +1377,7 @@ PerforceResponse PerforcePluginPrivate::runP4Cmd(const FilePath &workingDir,
actualArgs.append(args);
if (flags & CommandToWindow)
- VcsOutputWindow::appendCommand(workingDir.toString(), {m_settings.p4BinaryPath.filePath(), actualArgs});
+ VcsOutputWindow::appendCommand(workingDir, {m_settings.p4BinaryPath.filePath(), actualArgs});
if (flags & ShowBusyCursor)
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
diff --git a/src/plugins/updateinfo/updateinfoplugin.cpp b/src/plugins/updateinfo/updateinfoplugin.cpp
index 87ff5f1570..c6872dcda8 100644
--- a/src/plugins/updateinfo/updateinfoplugin.cpp
+++ b/src/plugins/updateinfo/updateinfoplugin.cpp
@@ -131,13 +131,13 @@ void UpdateInfoPlugin::startCheckForUpdates()
Utils::Environment env = Utils::Environment::systemEnvironment();
env.set("QT_LOGGING_RULES", "*=false");
- d->m_checkUpdatesCommand = new ShellCommand(QString(), env);
+ d->m_checkUpdatesCommand = new ShellCommand({}, env);
d->m_checkUpdatesCommand->setDisplayName(tr("Checking for Updates"));
connect(d->m_checkUpdatesCommand, &ShellCommand::stdOutText, this, &UpdateInfoPlugin::collectCheckForUpdatesOutput);
connect(d->m_checkUpdatesCommand, &ShellCommand::finished, this, &UpdateInfoPlugin::checkForUpdatesFinished);
d->m_checkUpdatesCommand->addJob({Utils::FilePath::fromString(d->m_maintenanceTool), {"--checkupdates"}},
60 * 3, // 3 minutes timeout
- /*workingDirectory=*/QString(),
+ /*workingDirectory=*/{},
[](int /*exitCode*/) { return Utils::QtcProcess::FinishedWithSuccess; });
d->m_checkUpdatesCommand->execute();
d->m_progress = d->m_checkUpdatesCommand->futureProgress();
diff --git a/src/plugins/vcsbase/vcsbaseclient.cpp b/src/plugins/vcsbase/vcsbaseclient.cpp
index 8b74bee395..ecbb5ea37c 100644
--- a/src/plugins/vcsbase/vcsbaseclient.cpp
+++ b/src/plugins/vcsbase/vcsbaseclient.cpp
@@ -112,7 +112,7 @@ VcsCommand *VcsBaseClientImpl::createCommand(const FilePath &workingDirectory,
}
void VcsBaseClientImpl::enqueueJob(VcsCommand *cmd, const QStringList &args,
- const QString &workingDirectory,
+ const FilePath &workingDirectory,
const ExitCodeInterpreter &interpreter) const
{
cmd->addJob({vcsBinary(), args}, vcsTimeoutS(), workingDirectory, interpreter);
@@ -415,7 +415,7 @@ void VcsBaseClient::diff(const FilePath &workingDir, const QStringList &files,
: VcsBaseEditor::getCodec(source);
VcsCommand *command = createCommand(workingDir, editor);
command->setCodec(codec);
- enqueueJob(command, args, workingDir.toString(), exitCodeInterpreter(DiffCommand));
+ enqueueJob(command, args, workingDir, exitCodeInterpreter(DiffCommand));
}
void VcsBaseClient::log(const FilePath &workingDir,
diff --git a/src/plugins/vcsbase/vcsbaseclient.h b/src/plugins/vcsbase/vcsbaseclient.h
index 77666748aa..7abc9a03f3 100644
--- a/src/plugins/vcsbase/vcsbaseclient.h
+++ b/src/plugins/vcsbase/vcsbaseclient.h
@@ -80,7 +80,7 @@ public:
JobOutputBindMode mode = NoOutputBind) const;
void enqueueJob(VcsCommand *cmd, const QStringList &args,
- const QString &workingDirectory = QString(),
+ const Utils::FilePath &workingDirectory = {},
const Utils::ExitCodeInterpreter &interpreter = {}) const;
virtual Utils::Environment processEnvironment() const;
diff --git a/src/plugins/vcsbase/vcscommand.cpp b/src/plugins/vcsbase/vcscommand.cpp
index dad00d7907..85623541ea 100644
--- a/src/plugins/vcsbase/vcscommand.cpp
+++ b/src/plugins/vcsbase/vcscommand.cpp
@@ -38,7 +38,7 @@ using namespace Utils;
namespace VcsBase {
VcsCommand::VcsCommand(const FilePath &workingDirectory, const Environment &environment) :
- Core::ShellCommand(workingDirectory.toString(), environment),
+ Core::ShellCommand(workingDirectory, environment),
m_preventRepositoryChanged(false)
{
VcsOutputWindow::setRepository(workingDirectory.toString());
@@ -73,7 +73,7 @@ const Environment VcsCommand::processEnvironment() const
void VcsCommand::runCommand(QtcProcess &proc,
const CommandLine &command,
- const QString &workingDirectory)
+ const FilePath &workingDirectory)
{
ShellCommand::runCommand(proc, command, workingDirectory);
emitRepositoryChanged(workingDirectory);
@@ -85,7 +85,7 @@ void VcsCommand::addTask(QFuture<void> &future)
Internal::VcsPlugin::addFuture(future);
}
-void VcsCommand::emitRepositoryChanged(const QString &workingDirectory)
+void VcsCommand::emitRepositoryChanged(const FilePath &workingDirectory)
{
if (m_preventRepositoryChanged || !(flags() & VcsCommand::ExpectRepoChanges))
return;
diff --git a/src/plugins/vcsbase/vcscommand.h b/src/plugins/vcsbase/vcscommand.h
index 541da9822f..9d5ac493b6 100644
--- a/src/plugins/vcsbase/vcscommand.h
+++ b/src/plugins/vcsbase/vcscommand.h
@@ -49,13 +49,13 @@ public:
void runCommand(Utils::QtcProcess &process,
const Utils::CommandLine &command,
- const QString &workDirectory = {}) override;
+ const Utils::FilePath &workDirectory = {}) override;
protected:
void addTask(QFuture<void> &future) override;
private:
- void emitRepositoryChanged(const QString &workingDirectory);
+ void emitRepositoryChanged(const Utils::FilePath &workingDirectory);
void coreAboutToClose() override;
diff --git a/src/plugins/vcsbase/vcsoutputwindow.cpp b/src/plugins/vcsbase/vcsoutputwindow.cpp
index 07d029ea6d..b4f00bb4ed 100644
--- a/src/plugins/vcsbase/vcsoutputwindow.cpp
+++ b/src/plugins/vcsbase/vcsoutputwindow.cpp
@@ -460,14 +460,11 @@ static inline QString formatArguments(const QStringList &args)
return rc;
}
-QString VcsOutputWindow::msgExecutionLogEntry(const QString &workingDir, const CommandLine &command)
+QString VcsOutputWindow::msgExecutionLogEntry(const FilePath &workingDir, const CommandLine &command)
{
- const QString args = formatArguments(command.splitArguments());
- const QString nativeExecutable = ProcessArgs::quoteArg(command.executable().toUserOutput());
if (workingDir.isEmpty())
- return tr("Running: %1 %2").arg(nativeExecutable, args) + '\n';
- return tr("Running in %1: %2 %3").
- arg(QDir::toNativeSeparators(workingDir), nativeExecutable, args) + '\n';
+ return tr("Running: %1").arg(command.toUserOutput()) + '\n';
+ return tr("Running in %1: %2").arg(workingDir.toUserOutput(), command.toUserOutput()) + '\n';
}
void VcsOutputWindow::appendShellCommandLine(const QString &text)
@@ -475,7 +472,7 @@ void VcsOutputWindow::appendShellCommandLine(const QString &text)
append(filterPasswordFromUrls(text), Command, true);
}
-void VcsOutputWindow::appendCommand(const QString &workingDirectory, const CommandLine &command)
+void VcsOutputWindow::appendCommand(const FilePath &workingDirectory, const CommandLine &command)
{
appendShellCommandLine(msgExecutionLogEntry(workingDirectory, command));
}
diff --git a/src/plugins/vcsbase/vcsoutputwindow.h b/src/plugins/vcsbase/vcsoutputwindow.h
index 21bd81be97..198d8532d3 100644
--- a/src/plugins/vcsbase/vcsoutputwindow.h
+++ b/src/plugins/vcsbase/vcsoutputwindow.h
@@ -29,7 +29,11 @@
#include <coreplugin/ioutputpane.h>
-namespace Utils { class CommandLine; }
+namespace Utils {
+class CommandLine;
+class FilePath;
+} // Utils
+
namespace VcsBase {
namespace Internal { class VcsPlugin; }
@@ -64,7 +68,7 @@ public:
// Helper to consistently format log entries for commands as
// 'Executing <dir>: <cmd> <args>'. Hides well-known password option
// arguments.
- static QString msgExecutionLogEntry(const QString &workingDir,
+ static QString msgExecutionLogEntry(const Utils::FilePath &workingDir,
const Utils::CommandLine &command);
enum MessageStyle {
@@ -104,7 +108,7 @@ public slots:
// Append a standard-formatted entry for command execution
// (see msgExecutionLogEntry).
- static void appendCommand(const QString &workingDirectory,
+ static void appendCommand(const Utils::FilePath &workingDirectory,
const Utils::CommandLine &command);
// Append a blue message text and pop up.
diff --git a/src/plugins/vcsbase/wizard/vcscommandpage.cpp b/src/plugins/vcsbase/wizard/vcscommandpage.cpp
index e84745d6e0..5da40d2cd0 100644
--- a/src/plugins/vcsbase/wizard/vcscommandpage.cpp
+++ b/src/plugins/vcsbase/wizard/vcscommandpage.cpp
@@ -100,7 +100,7 @@ WizardPage *VcsCommandPageFactory::create(JsonWizard *wizard, Id typeId, const Q
foreach (const QVariant &value, tmp.value(QLatin1String(VCSCOMMAND_JOBS)).toList()) {
const QVariantMap job = value.toMap();
const bool skipEmpty = job.value(QLatin1String(JOB_SKIP_EMPTY), true).toBool();
- const QString workDir = job.value(QLatin1String(JOB_WORK_DIRECTORY)).toString();
+ const FilePath workDir = FilePath::fromVariant(job.value(QLatin1String(JOB_WORK_DIRECTORY)));
const QString cmdString = job.value(QLatin1String(JOB_COMMAND)).toString();
QTC_ASSERT(!cmdString.isEmpty(), continue);
@@ -307,7 +307,7 @@ void VcsCommandPage::delayedInitialize()
args << tmp;
}
- const QString dir = wiz->expander()->expand(job.workDirectory);
+ const FilePath dir = wiz->expander()->expand(job.workDirectory);
const int timeoutS = command->defaultTimeoutS() * job.timeOutFactor;
command->addJob({FilePath::fromUserInput(commandString), args}, timeoutS, dir);
}
@@ -324,10 +324,10 @@ void VcsCommandPage::setCheckoutData(const QString &repo, const QString &baseDir
m_arguments = args;
}
-void VcsCommandPage::appendJob(bool skipEmpty, const QString &workDir, const QStringList &command,
+void VcsCommandPage::appendJob(bool skipEmpty, const FilePath &workDir, const QStringList &command,
const QVariant &condition, int timeoutFactor)
{
- m_additionalJobs.append(JobData(skipEmpty, workDir, command, condition, timeoutFactor));
+ m_additionalJobs.append(JobData{skipEmpty, workDir, command, condition, timeoutFactor});
}
void VcsCommandPage::setVersionControlId(const QString &id)
diff --git a/src/plugins/vcsbase/wizard/vcscommandpage.h b/src/plugins/vcsbase/wizard/vcscommandpage.h
index b09af42b3d..38070fba3b 100644
--- a/src/plugins/vcsbase/wizard/vcscommandpage.h
+++ b/src/plugins/vcsbase/wizard/vcscommandpage.h
@@ -29,10 +29,13 @@
#include <projectexplorer/jsonwizard/jsonwizardpagefactory.h>
+#include <utils/filepath.h>
#include <utils/shellcommandpage.h>
#include <QCoreApplication>
+namespace Utils { class FilePath; }
+
namespace VcsBase {
namespace Internal {
@@ -59,7 +62,7 @@ public:
void setCheckoutData(const QString &repo, const QString &baseDir, const QString &name,
const QStringList &args);
- void appendJob(bool skipEmpty, const QString &workDir, const QStringList &command,
+ void appendJob(bool skipEmpty, const Utils::FilePath &workDir, const QStringList &command,
const QVariant &condition, int timeoutFactor);
void setVersionControlId(const QString &id);
void setRunMessage(const QString &msg);
@@ -68,24 +71,21 @@ private slots:
void delayedInitialize();
private:
+ struct JobData
+ {
+ bool skipEmptyArguments = false;
+ Utils::FilePath workDirectory;
+ QStringList job;
+ QVariant condition;
+ int timeOutFactor;
+ };
+
QString m_vcsId;
QString m_repository;
QString m_directory;
QString m_name;
QString m_runMessage;
QStringList m_arguments;
-
- struct JobData {
- JobData(bool s, const QString &wd, const QStringList &c, const QVariant &cnd, int toF) :
- workDirectory(wd), job(c), condition(cnd), timeOutFactor(toF), skipEmptyArguments(s)
- { }
-
- QString workDirectory;
- QStringList job;
- QVariant condition;
- int timeOutFactor;
- bool skipEmptyArguments = false;
- };
QList<JobData> m_additionalJobs;
};