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:
@@ -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