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:
|
public:
|
||||||
struct Job {
|
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);
|
const ExitCodeInterpreter &interpreter);
|
||||||
|
|
||||||
QString workingDirectory;
|
FilePath workingDirectory;
|
||||||
CommandLine command;
|
CommandLine command;
|
||||||
ExitCodeInterpreter exitCodeInterpreter;
|
ExitCodeInterpreter exitCodeInterpreter;
|
||||||
int timeoutS;
|
int timeoutS;
|
||||||
};
|
};
|
||||||
|
|
||||||
ShellCommandPrivate(const QString &defaultWorkingDirectory, const Environment &environment)
|
ShellCommandPrivate(const FilePath &defaultWorkingDirectory, const Environment &environment)
|
||||||
: m_defaultWorkingDirectory(defaultWorkingDirectory),
|
: m_defaultWorkingDirectory(defaultWorkingDirectory),
|
||||||
m_environment(environment)
|
m_environment(environment)
|
||||||
{}
|
{}
|
||||||
@@ -86,7 +86,7 @@ public:
|
|||||||
~ShellCommandPrivate() { delete m_progressParser; }
|
~ShellCommandPrivate() { delete m_progressParser; }
|
||||||
|
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
const QString m_defaultWorkingDirectory;
|
const FilePath m_defaultWorkingDirectory;
|
||||||
const Environment m_environment;
|
const Environment m_environment;
|
||||||
QVariant m_cookie;
|
QVariant m_cookie;
|
||||||
QTextCodec *m_codec = nullptr;
|
QTextCodec *m_codec = nullptr;
|
||||||
@@ -105,7 +105,7 @@ public:
|
|||||||
bool m_disableUnixTerminal = false;
|
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) :
|
int t, const ExitCodeInterpreter &interpreter) :
|
||||||
workingDirectory(wd),
|
workingDirectory(wd),
|
||||||
command(command),
|
command(command),
|
||||||
@@ -119,8 +119,7 @@ ShellCommandPrivate::Job::Job(const QString &wd, const CommandLine &command,
|
|||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|
||||||
ShellCommand::ShellCommand(const QString &workingDirectory,
|
ShellCommand::ShellCommand(const FilePath &workingDirectory, const Environment &environment) :
|
||||||
const Environment &environment) :
|
|
||||||
d(new Internal::ShellCommandPrivate(workingDirectory, environment))
|
d(new Internal::ShellCommandPrivate(workingDirectory, environment))
|
||||||
{
|
{
|
||||||
connect(&d->m_watcher, &QFutureWatcher<void>::canceled, this, &ShellCommand::cancel);
|
connect(&d->m_watcher, &QFutureWatcher<void>::canceled, this, &ShellCommand::cancel);
|
||||||
@@ -156,7 +155,7 @@ void ShellCommand::setDisplayName(const QString &name)
|
|||||||
d->m_displayName = name;
|
d->m_displayName = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &ShellCommand::defaultWorkingDirectory() const
|
const FilePath &ShellCommand::defaultWorkingDirectory() const
|
||||||
{
|
{
|
||||||
return d->m_defaultWorkingDirectory;
|
return d->m_defaultWorkingDirectory;
|
||||||
}
|
}
|
||||||
@@ -187,13 +186,15 @@ void ShellCommand::addFlags(unsigned f)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ShellCommand::addJob(const CommandLine &command,
|
void ShellCommand::addJob(const CommandLine &command,
|
||||||
const QString &workingDirectory, const ExitCodeInterpreter &interpreter)
|
const FilePath &workingDirectory,
|
||||||
|
const ExitCodeInterpreter &interpreter)
|
||||||
{
|
{
|
||||||
addJob(command, defaultTimeoutS(), workingDirectory, interpreter);
|
addJob(command, defaultTimeoutS(), workingDirectory, interpreter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShellCommand::addJob(const CommandLine &command, int timeoutS,
|
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,
|
d->m_jobs.push_back(Internal::ShellCommandPrivate::Job(workDirectory(workingDirectory), command,
|
||||||
timeoutS, interpreter));
|
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())
|
if (!wd.isEmpty())
|
||||||
return wd;
|
return wd;
|
||||||
@@ -308,9 +309,9 @@ void ShellCommand::run(QFutureInterface<void> &future)
|
|||||||
|
|
||||||
void ShellCommand::runCommand(QtcProcess &proc,
|
void ShellCommand::runCommand(QtcProcess &proc,
|
||||||
const CommandLine &command,
|
const CommandLine &command,
|
||||||
const QString &workingDirectory)
|
const FilePath &workingDirectory)
|
||||||
{
|
{
|
||||||
const QString dir = workDirectory(workingDirectory);
|
const FilePath dir = workDirectory(workingDirectory);
|
||||||
|
|
||||||
if (command.executable().isEmpty()) {
|
if (command.executable().isEmpty()) {
|
||||||
proc.setResult(QtcProcess::StartFailed);
|
proc.setResult(QtcProcess::StartFailed);
|
||||||
@@ -340,13 +341,12 @@ void ShellCommand::runCommand(QtcProcess &proc,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShellCommand::runFullySynchronous(QtcProcess &process,
|
void ShellCommand::runFullySynchronous(QtcProcess &process, const FilePath &workingDirectory)
|
||||||
const QString &workingDirectory)
|
|
||||||
{
|
{
|
||||||
// Set up process
|
// Set up process
|
||||||
if (d->m_disableUnixTerminal)
|
if (d->m_disableUnixTerminal)
|
||||||
process.setDisableUnixTerminal();
|
process.setDisableUnixTerminal();
|
||||||
const QString dir = workDirectory(workingDirectory);
|
const FilePath dir = workDirectory(workingDirectory);
|
||||||
if (!dir.isEmpty())
|
if (!dir.isEmpty())
|
||||||
process.setWorkingDirectory(dir);
|
process.setWorkingDirectory(dir);
|
||||||
process.setEnvironment(processEnvironment());
|
process.setEnvironment(processEnvironment());
|
||||||
@@ -372,8 +372,7 @@ void ShellCommand::runFullySynchronous(QtcProcess &process,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShellCommand::runSynchronous(QtcProcess &process,
|
void ShellCommand::runSynchronous(QtcProcess &process, const FilePath &workingDirectory)
|
||||||
const QString &workingDirectory)
|
|
||||||
{
|
{
|
||||||
connect(this, &ShellCommand::terminate, &process, &QtcProcess::stopProcess);
|
connect(this, &ShellCommand::terminate, &process, &QtcProcess::stopProcess);
|
||||||
process.setEnvironment(processEnvironment());
|
process.setEnvironment(processEnvironment());
|
||||||
@@ -381,7 +380,7 @@ void ShellCommand::runSynchronous(QtcProcess &process,
|
|||||||
process.setCodec(d->m_codec);
|
process.setCodec(d->m_codec);
|
||||||
if (d->m_disableUnixTerminal)
|
if (d->m_disableUnixTerminal)
|
||||||
process.setDisableUnixTerminal();
|
process.setDisableUnixTerminal();
|
||||||
const QString dir = workDirectory(workingDirectory);
|
const FilePath dir = workDirectory(workingDirectory);
|
||||||
if (!dir.isEmpty())
|
if (!dir.isEmpty())
|
||||||
process.setWorkingDirectory(dir);
|
process.setWorkingDirectory(dir);
|
||||||
// connect stderr to the output window if desired
|
// 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;
|
~ShellCommand() override;
|
||||||
|
|
||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
void setDisplayName(const QString &name);
|
void setDisplayName(const QString &name);
|
||||||
|
|
||||||
void addJob(const CommandLine &command,
|
void addJob(const CommandLine &command,
|
||||||
const QString &workingDirectory = QString(),
|
const FilePath &workingDirectory = {},
|
||||||
const ExitCodeInterpreter &interpreter = {});
|
const ExitCodeInterpreter &interpreter = {});
|
||||||
void addJob(const CommandLine &command, int timeoutS,
|
void addJob(const CommandLine &command, int timeoutS,
|
||||||
const QString &workingDirectory = QString(),
|
const FilePath &workingDirectory = {},
|
||||||
const ExitCodeInterpreter &interpreter = {});
|
const ExitCodeInterpreter &interpreter = {});
|
||||||
void execute(); // Execute tasks asynchronously!
|
void execute(); // Execute tasks asynchronously!
|
||||||
void abort();
|
void abort();
|
||||||
bool lastExecutionSuccess() const;
|
bool lastExecutionSuccess() const;
|
||||||
int lastExecutionExitCode() const;
|
int lastExecutionExitCode() const;
|
||||||
|
|
||||||
const QString &defaultWorkingDirectory() const;
|
const FilePath &defaultWorkingDirectory() const;
|
||||||
virtual const Environment processEnvironment() const;
|
virtual const Environment processEnvironment() const;
|
||||||
|
|
||||||
int defaultTimeoutS() const;
|
int defaultTimeoutS() const;
|
||||||
@@ -123,9 +123,9 @@ public:
|
|||||||
// This is called once per job in a thread.
|
// This is called once per job in a thread.
|
||||||
// When called from the UI thread it will execute fully synchronously, so no signals will
|
// When called from the UI thread it will execute fully synchronously, so no signals will
|
||||||
// be triggered!
|
// be triggered!
|
||||||
virtual void runCommand(Utils::QtcProcess &process,
|
virtual void runCommand(QtcProcess &process,
|
||||||
const CommandLine &command,
|
const CommandLine &command,
|
||||||
const QString &workingDirectory = QString());
|
const FilePath &workingDirectory = {});
|
||||||
|
|
||||||
void cancel();
|
void cancel();
|
||||||
|
|
||||||
@@ -141,23 +141,21 @@ signals:
|
|||||||
void append(const QString &text);
|
void append(const QString &text);
|
||||||
void appendSilently(const QString &text);
|
void appendSilently(const QString &text);
|
||||||
void appendError(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);
|
void appendMessage(const QString &text);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void addTask(QFuture<void> &future);
|
virtual void addTask(QFuture<void> &future);
|
||||||
int timeoutS() const;
|
int timeoutS() const;
|
||||||
QString workDirectory(const QString &wd) const;
|
FilePath workDirectory(const FilePath &wd) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void run(QFutureInterface<void> &future);
|
void run(QFutureInterface<void> &future);
|
||||||
|
|
||||||
// Run without a event loop in fully blocking mode. No signals will be delivered.
|
// Run without a event loop in fully blocking mode. No signals will be delivered.
|
||||||
void runFullySynchronous(QtcProcess &proc,
|
void runFullySynchronous(QtcProcess &proc, const FilePath &workingDirectory);
|
||||||
const QString &workingDirectory);
|
|
||||||
// Run with an event loop. Signals will be delivered.
|
// Run with an event loop. Signals will be delivered.
|
||||||
void runSynchronous(QtcProcess &proc,
|
void runSynchronous(QtcProcess &proc, const FilePath &workingDirectory);
|
||||||
const QString &workingDirectory);
|
|
||||||
|
|
||||||
class Internal::ShellCommandPrivate *const d;
|
class Internal::ShellCommandPrivate *const d;
|
||||||
};
|
};
|
||||||
|
@@ -31,9 +31,11 @@
|
|||||||
#include <QFutureInterface>
|
#include <QFutureInterface>
|
||||||
#include <QFutureWatcher>
|
#include <QFutureWatcher>
|
||||||
|
|
||||||
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
ShellCommand::ShellCommand(const QString &workingDirectory, const Utils::Environment &environment) :
|
ShellCommand::ShellCommand(const FilePath &workingDirectory, const Environment &environment) :
|
||||||
Utils::ShellCommand(workingDirectory, environment)
|
Utils::ShellCommand(workingDirectory, environment)
|
||||||
{
|
{
|
||||||
connect(Core::ICore::instance(), &Core::ICore::coreAboutToClose,
|
connect(Core::ICore::instance(), &Core::ICore::coreAboutToClose,
|
||||||
|
@@ -40,7 +40,7 @@ class CORE_EXPORT ShellCommand : public Utils::ShellCommand
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ShellCommand(const QString &workingDirectory, const Utils::Environment &environment);
|
ShellCommand(const Utils::FilePath &workingDirectory, const Utils::Environment &environment);
|
||||||
|
|
||||||
FutureProgress *futureProgress() const;
|
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()
|
void VcsManager::clearVersionControlCache()
|
||||||
|
@@ -82,7 +82,7 @@ public:
|
|||||||
// added to revision control. Calls vcsAdd for each file.
|
// added to revision control. Calls vcsAdd for each file.
|
||||||
static void promptToAdd(const QString &directory, const QStringList &fileNames);
|
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
|
// Utility messages for adding files
|
||||||
static QString msgAddToVcsTitle();
|
static QString msgAddToVcsTitle();
|
||||||
|
@@ -321,7 +321,7 @@ void QueryContext::start()
|
|||||||
fp->setKeepOnFinish(Core::FutureProgress::HideOnFinish);
|
fp->setKeepOnFinish(Core::FutureProgress::HideOnFinish);
|
||||||
m_progress.reportStarted();
|
m_progress.reportStarted();
|
||||||
// Order: synchronous call to error handling if something goes wrong.
|
// 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});
|
{FilePath::fromString(m_binary), m_arguments});
|
||||||
m_timer.start();
|
m_timer.start();
|
||||||
m_process.setCommand({FilePath::fromString(m_binary), m_arguments});
|
m_process.setCommand({FilePath::fromString(m_binary), m_arguments});
|
||||||
|
@@ -169,7 +169,7 @@ void FetchContext::start()
|
|||||||
m_progress.reportStarted();
|
m_progress.reportStarted();
|
||||||
// Order: initialize future before starting the process in case error handling is invoked.
|
// Order: initialize future before starting the process in case error handling is invoked.
|
||||||
const QStringList args = m_change->gitFetchArguments(m_server);
|
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.setCommand({m_git, args});
|
||||||
m_process.start();
|
m_process.start();
|
||||||
}
|
}
|
||||||
|
@@ -663,7 +663,7 @@ class ConflictHandler final : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
static void attachToCommand(VcsCommand *command, const QString &abortCommand = QString()) {
|
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
|
handler->setParent(command); // delete when command goes out of scope
|
||||||
|
|
||||||
command->addFlags(VcsCommand::ExpectRepoChanges);
|
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)
|
void GitClient::merge(const FilePath &workingDirectory, const QStringList &unmergedFileNames)
|
||||||
{
|
{
|
||||||
auto mergeTool = new MergeTool(this);
|
auto mergeTool = new MergeTool(this);
|
||||||
if (!mergeTool->start(workingDirectory.toString(), unmergedFileNames))
|
if (!mergeTool->start(workingDirectory, unmergedFileNames))
|
||||||
delete mergeTool;
|
delete mergeTool;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2593,8 +2593,7 @@ bool GitClient::tryLauchingGitK(const Environment &env,
|
|||||||
arguments.append(ProcessArgs::splitArgs(gitkOpts, HostOsInfo::hostOs()));
|
arguments.append(ProcessArgs::splitArgs(gitkOpts, HostOsInfo::hostOs()));
|
||||||
if (!fileName.isEmpty())
|
if (!fileName.isEmpty())
|
||||||
arguments << "--" << fileName;
|
arguments << "--" << fileName;
|
||||||
VcsOutputWindow::appendCommand(workingDirectory.toString(),
|
VcsOutputWindow::appendCommand(workingDirectory, {FilePath::fromString(binary), arguments});
|
||||||
{FilePath::fromString(binary), arguments});
|
|
||||||
// This should always use QProcess::startDetached (as not to kill
|
// This should always use QProcess::startDetached (as not to kill
|
||||||
// the child), but that does not have an environment parameter.
|
// the child), but that does not have an environment parameter.
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
@@ -50,7 +50,7 @@ MergeTool::~MergeTool()
|
|||||||
delete m_process;
|
delete m_process;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MergeTool::start(const QString &workingDirectory, const QStringList &files)
|
bool MergeTool::start(const FilePath &workingDirectory, const QStringList &files)
|
||||||
{
|
{
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
arguments << "mergetool" << "-y" << files;
|
arguments << "mergetool" << "-y" << files;
|
||||||
@@ -58,7 +58,7 @@ bool MergeTool::start(const QString &workingDirectory, const QStringList &files)
|
|||||||
env.insert("LANG", "C");
|
env.insert("LANG", "C");
|
||||||
env.insert("LANGUAGE", "C");
|
env.insert("LANGUAGE", "C");
|
||||||
m_process = new QProcess(this);
|
m_process = new QProcess(this);
|
||||||
m_process->setWorkingDirectory(workingDirectory);
|
m_process->setWorkingDirectory(workingDirectory.toString());
|
||||||
m_process->setProcessEnvironment(env);
|
m_process->setProcessEnvironment(env);
|
||||||
m_process->setProcessChannelMode(QProcess::MergedChannels);
|
m_process->setProcessChannelMode(QProcess::MergedChannels);
|
||||||
const Utils::FilePath binary = GitClient::instance()->vcsBinary();
|
const Utils::FilePath binary = GitClient::instance()->vcsBinary();
|
||||||
|
@@ -33,6 +33,8 @@ class QMessageBox;
|
|||||||
class QProcess;
|
class QProcess;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace Utils { class FilePath; }
|
||||||
|
|
||||||
namespace Git {
|
namespace Git {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -52,7 +54,7 @@ class MergeTool : public QObject
|
|||||||
public:
|
public:
|
||||||
explicit MergeTool(QObject *parent = nullptr);
|
explicit MergeTool(QObject *parent = nullptr);
|
||||||
~MergeTool() override;
|
~MergeTool() override;
|
||||||
bool start(const QString &workingDirectory, const QStringList &files = QStringList());
|
bool start(const Utils::FilePath &workingDirectory, const QStringList &files = {});
|
||||||
|
|
||||||
enum MergeType {
|
enum MergeType {
|
||||||
NormalMerge,
|
NormalMerge,
|
||||||
|
@@ -1377,7 +1377,7 @@ PerforceResponse PerforcePluginPrivate::runP4Cmd(const FilePath &workingDir,
|
|||||||
actualArgs.append(args);
|
actualArgs.append(args);
|
||||||
|
|
||||||
if (flags & CommandToWindow)
|
if (flags & CommandToWindow)
|
||||||
VcsOutputWindow::appendCommand(workingDir.toString(), {m_settings.p4BinaryPath.filePath(), actualArgs});
|
VcsOutputWindow::appendCommand(workingDir, {m_settings.p4BinaryPath.filePath(), actualArgs});
|
||||||
|
|
||||||
if (flags & ShowBusyCursor)
|
if (flags & ShowBusyCursor)
|
||||||
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
|
||||||
|
@@ -131,13 +131,13 @@ void UpdateInfoPlugin::startCheckForUpdates()
|
|||||||
|
|
||||||
Utils::Environment env = Utils::Environment::systemEnvironment();
|
Utils::Environment env = Utils::Environment::systemEnvironment();
|
||||||
env.set("QT_LOGGING_RULES", "*=false");
|
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"));
|
d->m_checkUpdatesCommand->setDisplayName(tr("Checking for Updates"));
|
||||||
connect(d->m_checkUpdatesCommand, &ShellCommand::stdOutText, this, &UpdateInfoPlugin::collectCheckForUpdatesOutput);
|
connect(d->m_checkUpdatesCommand, &ShellCommand::stdOutText, this, &UpdateInfoPlugin::collectCheckForUpdatesOutput);
|
||||||
connect(d->m_checkUpdatesCommand, &ShellCommand::finished, this, &UpdateInfoPlugin::checkForUpdatesFinished);
|
connect(d->m_checkUpdatesCommand, &ShellCommand::finished, this, &UpdateInfoPlugin::checkForUpdatesFinished);
|
||||||
d->m_checkUpdatesCommand->addJob({Utils::FilePath::fromString(d->m_maintenanceTool), {"--checkupdates"}},
|
d->m_checkUpdatesCommand->addJob({Utils::FilePath::fromString(d->m_maintenanceTool), {"--checkupdates"}},
|
||||||
60 * 3, // 3 minutes timeout
|
60 * 3, // 3 minutes timeout
|
||||||
/*workingDirectory=*/QString(),
|
/*workingDirectory=*/{},
|
||||||
[](int /*exitCode*/) { return Utils::QtcProcess::FinishedWithSuccess; });
|
[](int /*exitCode*/) { return Utils::QtcProcess::FinishedWithSuccess; });
|
||||||
d->m_checkUpdatesCommand->execute();
|
d->m_checkUpdatesCommand->execute();
|
||||||
d->m_progress = d->m_checkUpdatesCommand->futureProgress();
|
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,
|
void VcsBaseClientImpl::enqueueJob(VcsCommand *cmd, const QStringList &args,
|
||||||
const QString &workingDirectory,
|
const FilePath &workingDirectory,
|
||||||
const ExitCodeInterpreter &interpreter) const
|
const ExitCodeInterpreter &interpreter) const
|
||||||
{
|
{
|
||||||
cmd->addJob({vcsBinary(), args}, vcsTimeoutS(), workingDirectory, interpreter);
|
cmd->addJob({vcsBinary(), args}, vcsTimeoutS(), workingDirectory, interpreter);
|
||||||
@@ -415,7 +415,7 @@ void VcsBaseClient::diff(const FilePath &workingDir, const QStringList &files,
|
|||||||
: VcsBaseEditor::getCodec(source);
|
: VcsBaseEditor::getCodec(source);
|
||||||
VcsCommand *command = createCommand(workingDir, editor);
|
VcsCommand *command = createCommand(workingDir, editor);
|
||||||
command->setCodec(codec);
|
command->setCodec(codec);
|
||||||
enqueueJob(command, args, workingDir.toString(), exitCodeInterpreter(DiffCommand));
|
enqueueJob(command, args, workingDir, exitCodeInterpreter(DiffCommand));
|
||||||
}
|
}
|
||||||
|
|
||||||
void VcsBaseClient::log(const FilePath &workingDir,
|
void VcsBaseClient::log(const FilePath &workingDir,
|
||||||
|
@@ -80,7 +80,7 @@ public:
|
|||||||
JobOutputBindMode mode = NoOutputBind) const;
|
JobOutputBindMode mode = NoOutputBind) const;
|
||||||
|
|
||||||
void enqueueJob(VcsCommand *cmd, const QStringList &args,
|
void enqueueJob(VcsCommand *cmd, const QStringList &args,
|
||||||
const QString &workingDirectory = QString(),
|
const Utils::FilePath &workingDirectory = {},
|
||||||
const Utils::ExitCodeInterpreter &interpreter = {}) const;
|
const Utils::ExitCodeInterpreter &interpreter = {}) const;
|
||||||
|
|
||||||
virtual Utils::Environment processEnvironment() const;
|
virtual Utils::Environment processEnvironment() const;
|
||||||
|
@@ -38,7 +38,7 @@ using namespace Utils;
|
|||||||
namespace VcsBase {
|
namespace VcsBase {
|
||||||
|
|
||||||
VcsCommand::VcsCommand(const FilePath &workingDirectory, const Environment &environment) :
|
VcsCommand::VcsCommand(const FilePath &workingDirectory, const Environment &environment) :
|
||||||
Core::ShellCommand(workingDirectory.toString(), environment),
|
Core::ShellCommand(workingDirectory, environment),
|
||||||
m_preventRepositoryChanged(false)
|
m_preventRepositoryChanged(false)
|
||||||
{
|
{
|
||||||
VcsOutputWindow::setRepository(workingDirectory.toString());
|
VcsOutputWindow::setRepository(workingDirectory.toString());
|
||||||
@@ -73,7 +73,7 @@ const Environment VcsCommand::processEnvironment() const
|
|||||||
|
|
||||||
void VcsCommand::runCommand(QtcProcess &proc,
|
void VcsCommand::runCommand(QtcProcess &proc,
|
||||||
const CommandLine &command,
|
const CommandLine &command,
|
||||||
const QString &workingDirectory)
|
const FilePath &workingDirectory)
|
||||||
{
|
{
|
||||||
ShellCommand::runCommand(proc, command, workingDirectory);
|
ShellCommand::runCommand(proc, command, workingDirectory);
|
||||||
emitRepositoryChanged(workingDirectory);
|
emitRepositoryChanged(workingDirectory);
|
||||||
@@ -85,7 +85,7 @@ void VcsCommand::addTask(QFuture<void> &future)
|
|||||||
Internal::VcsPlugin::addFuture(future);
|
Internal::VcsPlugin::addFuture(future);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VcsCommand::emitRepositoryChanged(const QString &workingDirectory)
|
void VcsCommand::emitRepositoryChanged(const FilePath &workingDirectory)
|
||||||
{
|
{
|
||||||
if (m_preventRepositoryChanged || !(flags() & VcsCommand::ExpectRepoChanges))
|
if (m_preventRepositoryChanged || !(flags() & VcsCommand::ExpectRepoChanges))
|
||||||
return;
|
return;
|
||||||
|
@@ -49,13 +49,13 @@ public:
|
|||||||
|
|
||||||
void runCommand(Utils::QtcProcess &process,
|
void runCommand(Utils::QtcProcess &process,
|
||||||
const Utils::CommandLine &command,
|
const Utils::CommandLine &command,
|
||||||
const QString &workDirectory = {}) override;
|
const Utils::FilePath &workDirectory = {}) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void addTask(QFuture<void> &future) override;
|
void addTask(QFuture<void> &future) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void emitRepositoryChanged(const QString &workingDirectory);
|
void emitRepositoryChanged(const Utils::FilePath &workingDirectory);
|
||||||
|
|
||||||
void coreAboutToClose() override;
|
void coreAboutToClose() override;
|
||||||
|
|
||||||
|
@@ -460,14 +460,11 @@ static inline QString formatArguments(const QStringList &args)
|
|||||||
return rc;
|
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())
|
if (workingDir.isEmpty())
|
||||||
return tr("Running: %1 %2").arg(nativeExecutable, args) + '\n';
|
return tr("Running: %1").arg(command.toUserOutput()) + '\n';
|
||||||
return tr("Running in %1: %2 %3").
|
return tr("Running in %1: %2").arg(workingDir.toUserOutput(), command.toUserOutput()) + '\n';
|
||||||
arg(QDir::toNativeSeparators(workingDir), nativeExecutable, args) + '\n';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VcsOutputWindow::appendShellCommandLine(const QString &text)
|
void VcsOutputWindow::appendShellCommandLine(const QString &text)
|
||||||
@@ -475,7 +472,7 @@ void VcsOutputWindow::appendShellCommandLine(const QString &text)
|
|||||||
append(filterPasswordFromUrls(text), Command, true);
|
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));
|
appendShellCommandLine(msgExecutionLogEntry(workingDirectory, command));
|
||||||
}
|
}
|
||||||
|
@@ -29,7 +29,11 @@
|
|||||||
|
|
||||||
#include <coreplugin/ioutputpane.h>
|
#include <coreplugin/ioutputpane.h>
|
||||||
|
|
||||||
namespace Utils { class CommandLine; }
|
namespace Utils {
|
||||||
|
class CommandLine;
|
||||||
|
class FilePath;
|
||||||
|
} // Utils
|
||||||
|
|
||||||
namespace VcsBase {
|
namespace VcsBase {
|
||||||
|
|
||||||
namespace Internal { class VcsPlugin; }
|
namespace Internal { class VcsPlugin; }
|
||||||
@@ -64,7 +68,7 @@ public:
|
|||||||
// Helper to consistently format log entries for commands as
|
// Helper to consistently format log entries for commands as
|
||||||
// 'Executing <dir>: <cmd> <args>'. Hides well-known password option
|
// 'Executing <dir>: <cmd> <args>'. Hides well-known password option
|
||||||
// arguments.
|
// arguments.
|
||||||
static QString msgExecutionLogEntry(const QString &workingDir,
|
static QString msgExecutionLogEntry(const Utils::FilePath &workingDir,
|
||||||
const Utils::CommandLine &command);
|
const Utils::CommandLine &command);
|
||||||
|
|
||||||
enum MessageStyle {
|
enum MessageStyle {
|
||||||
@@ -104,7 +108,7 @@ public slots:
|
|||||||
|
|
||||||
// Append a standard-formatted entry for command execution
|
// Append a standard-formatted entry for command execution
|
||||||
// (see msgExecutionLogEntry).
|
// (see msgExecutionLogEntry).
|
||||||
static void appendCommand(const QString &workingDirectory,
|
static void appendCommand(const Utils::FilePath &workingDirectory,
|
||||||
const Utils::CommandLine &command);
|
const Utils::CommandLine &command);
|
||||||
|
|
||||||
// Append a blue message text and pop up.
|
// 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()) {
|
foreach (const QVariant &value, tmp.value(QLatin1String(VCSCOMMAND_JOBS)).toList()) {
|
||||||
const QVariantMap job = value.toMap();
|
const QVariantMap job = value.toMap();
|
||||||
const bool skipEmpty = job.value(QLatin1String(JOB_SKIP_EMPTY), true).toBool();
|
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();
|
const QString cmdString = job.value(QLatin1String(JOB_COMMAND)).toString();
|
||||||
QTC_ASSERT(!cmdString.isEmpty(), continue);
|
QTC_ASSERT(!cmdString.isEmpty(), continue);
|
||||||
@@ -307,7 +307,7 @@ void VcsCommandPage::delayedInitialize()
|
|||||||
args << tmp;
|
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;
|
const int timeoutS = command->defaultTimeoutS() * job.timeOutFactor;
|
||||||
command->addJob({FilePath::fromUserInput(commandString), args}, timeoutS, dir);
|
command->addJob({FilePath::fromUserInput(commandString), args}, timeoutS, dir);
|
||||||
}
|
}
|
||||||
@@ -324,10 +324,10 @@ void VcsCommandPage::setCheckoutData(const QString &repo, const QString &baseDir
|
|||||||
m_arguments = args;
|
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)
|
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)
|
void VcsCommandPage::setVersionControlId(const QString &id)
|
||||||
|
@@ -29,10 +29,13 @@
|
|||||||
|
|
||||||
#include <projectexplorer/jsonwizard/jsonwizardpagefactory.h>
|
#include <projectexplorer/jsonwizard/jsonwizardpagefactory.h>
|
||||||
|
|
||||||
|
#include <utils/filepath.h>
|
||||||
#include <utils/shellcommandpage.h>
|
#include <utils/shellcommandpage.h>
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
|
|
||||||
|
namespace Utils { class FilePath; }
|
||||||
|
|
||||||
namespace VcsBase {
|
namespace VcsBase {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
@@ -59,7 +62,7 @@ public:
|
|||||||
|
|
||||||
void setCheckoutData(const QString &repo, const QString &baseDir, const QString &name,
|
void setCheckoutData(const QString &repo, const QString &baseDir, const QString &name,
|
||||||
const QStringList &args);
|
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);
|
const QVariant &condition, int timeoutFactor);
|
||||||
void setVersionControlId(const QString &id);
|
void setVersionControlId(const QString &id);
|
||||||
void setRunMessage(const QString &msg);
|
void setRunMessage(const QString &msg);
|
||||||
@@ -68,24 +71,21 @@ private slots:
|
|||||||
void delayedInitialize();
|
void delayedInitialize();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
struct JobData
|
||||||
|
{
|
||||||
|
bool skipEmptyArguments = false;
|
||||||
|
Utils::FilePath workDirectory;
|
||||||
|
QStringList job;
|
||||||
|
QVariant condition;
|
||||||
|
int timeOutFactor;
|
||||||
|
};
|
||||||
|
|
||||||
QString m_vcsId;
|
QString m_vcsId;
|
||||||
QString m_repository;
|
QString m_repository;
|
||||||
QString m_directory;
|
QString m_directory;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
QString m_runMessage;
|
QString m_runMessage;
|
||||||
QStringList m_arguments;
|
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;
|
QList<JobData> m_additionalJobs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user