forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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
|
||||
|
@@ -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;
|
||||
};
|
||||
|
@@ -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,
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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()
|
||||
|
@@ -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();
|
||||
|
@@ -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});
|
||||
|
@@ -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();
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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();
|
||||
|
@@ -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,
|
||||
|
@@ -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));
|
||||
|
@@ -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();
|
||||
|
@@ -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,
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
||||
|
@@ -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));
|
||||
}
|
||||
|
@@ -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.
|
||||
|
@@ -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)
|
||||
|
@@ -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;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user