forked from qt-creator/qt-creator
Some QString -> FileName transformation
Change-Id: I4a8a8f68bb1e52750380218793ec3029b488c01f Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
f8dfa03d4f
commit
71b56d2b9c
@@ -257,7 +257,7 @@ void ChangeSelectionDialog::recalculateDetails()
|
||||
|
||||
connect(m_process, SIGNAL(finished(int)), this, SLOT(setDetails(int)));
|
||||
|
||||
m_process->start(m_gitBinaryPath, args);
|
||||
m_process->start(m_gitBinaryPath.toString(), args);
|
||||
m_process->closeWriteChannel();
|
||||
if (!m_process->waitForStarted())
|
||||
m_ui->detailsText->setPlainText(tr("Error: Could not start Git."));
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
|
||||
#include <coreplugin/id.h>
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QDialog>
|
||||
#include <QProcessEnvironment>
|
||||
|
||||
@@ -87,7 +89,7 @@ private:
|
||||
Ui::ChangeSelectionDialog *m_ui;
|
||||
|
||||
QProcess *m_process;
|
||||
QString m_gitBinaryPath;
|
||||
Utils::FileName m_gitBinaryPath;
|
||||
QProcessEnvironment m_gitEnvironment;
|
||||
ChangeCommand m_command;
|
||||
QStringListModel *m_changeModel;
|
||||
|
||||
@@ -314,8 +314,8 @@ void QueryContext::startQuery(const QString &query)
|
||||
{
|
||||
QStringList arguments = m_baseArguments;
|
||||
arguments.push_back(query);
|
||||
VcsBase::VcsBaseOutputWindow::instance()
|
||||
->appendCommand(m_process.workingDirectory(), m_binary, arguments);
|
||||
VcsBase::VcsBaseOutputWindow::instance()->appendCommand(
|
||||
m_process.workingDirectory(), Utils::FileName::fromString(m_binary), arguments);
|
||||
m_timer.start();
|
||||
m_process.start(m_binary, arguments);
|
||||
m_process.closeWriteChannel();
|
||||
|
||||
@@ -73,10 +73,10 @@ static inline QString detectSsh()
|
||||
if (!ssh.isEmpty())
|
||||
return ssh;
|
||||
if (Utils::HostOsInfo::isWindowsHost()) { // Windows: Use ssh.exe from git if it cannot be found.
|
||||
const QString git = GerritPlugin::gitBinary();
|
||||
const Utils::FileName git = GerritPlugin::gitBinary();
|
||||
if (!git.isEmpty()) {
|
||||
// Is 'git\cmd' in the path (folder containing .bats)?
|
||||
QString path = QFileInfo(git).absolutePath();
|
||||
QString path = git.parentDir().toString();
|
||||
if (path.endsWith(QLatin1String("cmd"), Qt::CaseInsensitive))
|
||||
path.replace(path.size() - 3, 3, QLatin1String("bin"));
|
||||
ssh = path + QLatin1Char('/') + QLatin1String(defaultSshC);
|
||||
|
||||
@@ -99,7 +99,7 @@ class FetchContext : public QObject
|
||||
Q_OBJECT
|
||||
public:
|
||||
FetchContext(const QSharedPointer<GerritChange> &change,
|
||||
const QString &repository, const QString &git,
|
||||
const QString &repository, const Utils::FileName &git,
|
||||
const QSharedPointer<GerritParameters> &p,
|
||||
FetchMode fm, QObject *parent = 0);
|
||||
~FetchContext();
|
||||
@@ -129,7 +129,7 @@ private:
|
||||
const QSharedPointer<GerritChange> m_change;
|
||||
const QString m_repository;
|
||||
const FetchMode m_fetchMode;
|
||||
const QString m_git;
|
||||
const Utils::FileName m_git;
|
||||
const QSharedPointer<GerritParameters> m_parameters;
|
||||
State m_state;
|
||||
QProcess m_process;
|
||||
@@ -137,7 +137,7 @@ private:
|
||||
};
|
||||
|
||||
FetchContext::FetchContext(const QSharedPointer<GerritChange> &change,
|
||||
const QString &repository, const QString &git,
|
||||
const QString &repository, const Utils::FileName &git,
|
||||
const QSharedPointer<GerritParameters> &p,
|
||||
FetchMode fm, QObject *parent)
|
||||
: QObject(parent)
|
||||
@@ -179,18 +179,18 @@ void FetchContext::start()
|
||||
// Order: initialize future before starting the process in case error handling is invoked.
|
||||
const QStringList args = m_change->gitFetchArguments(m_parameters);
|
||||
VcsBase::VcsBaseOutputWindow::instance()->appendCommand(m_repository, m_git, args);
|
||||
m_process.start(m_git, args);
|
||||
m_process.start(m_git.toString(), args);
|
||||
m_process.closeWriteChannel();
|
||||
}
|
||||
|
||||
void FetchContext::processFinished(int exitCode, QProcess::ExitStatus es)
|
||||
{
|
||||
if (es != QProcess::NormalExit) {
|
||||
handleError(tr("%1 crashed.").arg(m_git));
|
||||
handleError(tr("%1 crashed.").arg(m_git.toUserOutput()));
|
||||
return;
|
||||
}
|
||||
if (exitCode) {
|
||||
handleError(tr("%1 returned %2.").arg(m_git).arg(exitCode));
|
||||
handleError(tr("%1 returned %2.").arg(m_git.toUserOutput()).arg(exitCode));
|
||||
return;
|
||||
}
|
||||
if (m_state == FetchState) {
|
||||
@@ -235,7 +235,7 @@ void FetchContext::handleError(const QString &e)
|
||||
|
||||
void FetchContext::processError(QProcess::ProcessError e)
|
||||
{
|
||||
const QString msg = tr("Error running %1: %2").arg(m_git, m_process.errorString());
|
||||
const QString msg = tr("Error running %1: %2").arg(m_git.toUserOutput(), m_process.errorString());
|
||||
if (e == QProcess::FailedToStart)
|
||||
handleError(msg);
|
||||
else
|
||||
@@ -388,13 +388,13 @@ void GerritPlugin::push()
|
||||
push(GitPlugin::instance()->currentState().topLevel());
|
||||
}
|
||||
|
||||
QString GerritPlugin::gitBinary()
|
||||
Utils::FileName GerritPlugin::gitBinary()
|
||||
{
|
||||
bool ok;
|
||||
const QString git = gitClient()->gitBinaryPath(&ok);
|
||||
const Utils::FileName git = gitClient()->gitBinaryPath(&ok);
|
||||
if (!ok) {
|
||||
VcsBase::VcsBaseOutputWindow::instance()->appendError(tr("Git is not available."));
|
||||
return QString();
|
||||
return Utils::FileName();
|
||||
}
|
||||
return git;
|
||||
}
|
||||
@@ -423,7 +423,7 @@ void GerritPlugin::fetchCheckout(const QSharedPointer<GerritChange> &change)
|
||||
void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
|
||||
{
|
||||
// Locate git.
|
||||
const QString git = gitBinary();
|
||||
const Utils::FileName git = gitBinary();
|
||||
if (git.isEmpty())
|
||||
return;
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
#ifndef GERRIT_INTERNAL_GERRITPLUGIN_H
|
||||
#define GERRIT_INTERNAL_GERRITPLUGIN_H
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
#include <QSharedPointer>
|
||||
@@ -61,7 +63,7 @@ public:
|
||||
|
||||
bool initialize(Core::ActionContainer *ac);
|
||||
|
||||
static QString gitBinary();
|
||||
static Utils::FileName gitBinary();
|
||||
static QString branch(const QString &repository);
|
||||
void addToLocator(Core::CommandLocator *locator);
|
||||
void push(const QString &topLevel);
|
||||
|
||||
@@ -133,7 +133,7 @@ private:
|
||||
void addJob(VcsBase::Command *command, const QStringList &arguments);
|
||||
int timeout() const;
|
||||
QProcessEnvironment processEnvironment() const;
|
||||
QString gitPath() const;
|
||||
Utils::FileName gitPath() const;
|
||||
|
||||
QPointer<DiffEditor::DiffEditorController> m_controller;
|
||||
const QString m_workingDirectory;
|
||||
@@ -303,7 +303,7 @@ QProcessEnvironment GitDiffHandler::processEnvironment() const
|
||||
return m_gitClient->processEnvironment();
|
||||
}
|
||||
|
||||
QString GitDiffHandler::gitPath() const
|
||||
Utils::FileName GitDiffHandler::gitPath() const
|
||||
{
|
||||
return m_gitClient->gitBinaryPath();
|
||||
}
|
||||
@@ -2185,7 +2185,9 @@ VcsBase::Command *GitClient::executeGit(const QString &workingDirectory,
|
||||
unsigned additionalFlags,
|
||||
int editorLineNumber)
|
||||
{
|
||||
outputWindow()->appendCommand(workingDirectory, settings()->stringValue(GitSettings::binaryPathKey), arguments);
|
||||
outputWindow()->appendCommand(workingDirectory,
|
||||
Utils::FileName::fromUserInput(settings()->stringValue(GitSettings::binaryPathKey)),
|
||||
arguments);
|
||||
VcsBase::Command *command = createCommand(workingDirectory, editor, useOutputToWindow, editorLineNumber);
|
||||
command->addJob(arguments, settings()->intValue(GitSettings::timeoutKey));
|
||||
command->addFlags(additionalFlags);
|
||||
@@ -2543,7 +2545,7 @@ QStringList GitClient::synchronousRepositoryBranches(const QString &repositoryUR
|
||||
|
||||
void GitClient::launchGitK(const QString &workingDirectory, const QString &fileName)
|
||||
{
|
||||
const QFileInfo binaryInfo(gitBinaryPath());
|
||||
const QFileInfo binaryInfo = gitBinaryPath().toFileInfo();
|
||||
QDir foundBinDir(binaryInfo.dir());
|
||||
const bool foundBinDirIsCmdDir = foundBinDir.dirName() == QLatin1String("cmd");
|
||||
QProcessEnvironment env = processEnvironment();
|
||||
@@ -2564,10 +2566,10 @@ void GitClient::launchGitK(const QString &workingDirectory, const QString &fileN
|
||||
}
|
||||
|
||||
Utils::Environment sysEnv = Utils::Environment::systemEnvironment();
|
||||
const QString exec = sysEnv.searchInPath(QLatin1String("gitk"));
|
||||
const Utils::FileName exec = sysEnv.searchInPath(QLatin1String("gitk"));
|
||||
|
||||
if (!exec.isEmpty() && tryLauchingGitK(env, workingDirectory, fileName,
|
||||
QFileInfo(exec).absolutePath())) {
|
||||
exec.parentDir().toString())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2602,7 +2604,7 @@ bool GitClient::tryLauchingGitK(const QProcessEnvironment &env,
|
||||
arguments.append(Utils::QtcProcess::splitArgs(gitkOpts, Utils::HostOsInfo::hostOs()));
|
||||
if (!fileName.isEmpty())
|
||||
arguments << QLatin1String("--") << fileName;
|
||||
outwin->appendCommand(workingDirectory, binary, arguments);
|
||||
outwin->appendCommand(workingDirectory, Utils::FileName::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;
|
||||
@@ -2625,10 +2627,11 @@ bool GitClient::tryLauchingGitK(const QProcessEnvironment &env,
|
||||
|
||||
bool GitClient::launchGitGui(const QString &workingDirectory) {
|
||||
bool success;
|
||||
QString gitBinary = gitBinaryPath(&success);
|
||||
if (success)
|
||||
success = QProcess::startDetached(gitBinary, QStringList(QLatin1String("gui")),
|
||||
Utils::FileName gitBinary = gitBinaryPath(&success);
|
||||
if (success) {
|
||||
success = QProcess::startDetached(gitBinary.toString(), QStringList(QLatin1String("gui")),
|
||||
workingDirectory);
|
||||
}
|
||||
|
||||
if (!success)
|
||||
outputWindow()->appendError(msgCannotLaunch(QLatin1String("git gui")));
|
||||
@@ -2636,7 +2639,7 @@ bool GitClient::launchGitGui(const QString &workingDirectory) {
|
||||
return success;
|
||||
}
|
||||
|
||||
QString GitClient::gitBinaryPath(bool *ok, QString *errorMessage) const
|
||||
Utils::FileName GitClient::gitBinaryPath(bool *ok, QString *errorMessage) const
|
||||
{
|
||||
return settings()->gitBinaryPath(ok, errorMessage);
|
||||
}
|
||||
@@ -3269,9 +3272,7 @@ void GitClient::asyncCommand(const QString &workingDirectory, const QStringList
|
||||
// Git might request an editor, so this must be done asynchronously
|
||||
// and without timeout
|
||||
QString gitCommand = arguments.first();
|
||||
outputWindow()->appendCommand(workingDirectory,
|
||||
settings()->stringValue(GitSettings::binaryPathKey),
|
||||
arguments);
|
||||
outputWindow()->appendCommand(workingDirectory, settings()->binaryPath(), arguments);
|
||||
VcsBase::Command *command = createCommand(workingDirectory, 0, true);
|
||||
new ConflictHandler(command, workingDirectory, gitCommand);
|
||||
if (hasProgress)
|
||||
@@ -3317,7 +3318,7 @@ void GitClient::interactiveRebase(const QString &workingDirectory, const QString
|
||||
if (fixup)
|
||||
arguments << QLatin1String("--autosquash");
|
||||
arguments << commit + QLatin1Char('^');
|
||||
outputWindow()->appendCommand(workingDirectory, settings()->stringValue(GitSettings::binaryPathKey), arguments);
|
||||
outputWindow()->appendCommand(workingDirectory, settings()->binaryPath(), arguments);
|
||||
if (fixup)
|
||||
m_disableEditor = true;
|
||||
asyncCommand(workingDirectory, arguments, true);
|
||||
@@ -3506,7 +3507,7 @@ GitSettings *GitClient::settings() const
|
||||
// determine version as '(major << 16) + (minor << 8) + patch' or 0.
|
||||
unsigned GitClient::gitVersion(QString *errorMessage) const
|
||||
{
|
||||
const QString newGitBinary = gitBinaryPath();
|
||||
const Utils::FileName newGitBinary = gitBinaryPath();
|
||||
if (m_gitVersionForBinary != newGitBinary && !newGitBinary.isEmpty()) {
|
||||
// Do not execute repeatedly if that fails (due to git
|
||||
// not being installed) until settings are changed.
|
||||
|
||||
@@ -134,7 +134,7 @@ public:
|
||||
explicit GitClient(GitSettings *settings);
|
||||
~GitClient();
|
||||
|
||||
QString gitBinaryPath(bool *ok = 0, QString *errorMessage = 0) const;
|
||||
Utils::FileName gitBinaryPath(bool *ok = 0, QString *errorMessage = 0) const;
|
||||
unsigned gitVersion(QString *errorMessage = 0) const;
|
||||
|
||||
QString findRepositoryForDirectory(const QString &dir);
|
||||
@@ -423,7 +423,7 @@ private:
|
||||
QString msgBoxText, const QString &buttonName,
|
||||
const QString &gitCommand, ContinueCommandMode continueMode);
|
||||
|
||||
mutable QString m_gitVersionForBinary;
|
||||
mutable Utils::FileName m_gitVersionForBinary;
|
||||
mutable unsigned m_cachedGitVersion;
|
||||
|
||||
const QString m_msgWait;
|
||||
|
||||
@@ -70,7 +70,7 @@ GitSettings::GitSettings()
|
||||
declareKey(lastResetIndexKey, 0);
|
||||
}
|
||||
|
||||
QString GitSettings::gitBinaryPath(bool *ok, QString *errorMessage) const
|
||||
Utils::FileName GitSettings::gitBinaryPath(bool *ok, QString *errorMessage) const
|
||||
{
|
||||
// Locate binary in path if one is specified, otherwise default
|
||||
// to pathless binary
|
||||
@@ -79,7 +79,7 @@ QString GitSettings::gitBinaryPath(bool *ok, QString *errorMessage) const
|
||||
if (errorMessage)
|
||||
errorMessage->clear();
|
||||
|
||||
QString binPath = binaryPath();
|
||||
Utils::FileName binPath = binaryPath();
|
||||
if (binPath.isEmpty()) {
|
||||
if (ok)
|
||||
*ok = false;
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
static const QLatin1String graphLogKey;
|
||||
static const QLatin1String lastResetIndexKey;
|
||||
|
||||
QString gitBinaryPath(bool *ok = 0, QString *errorMessage = 0) const;
|
||||
Utils::FileName gitBinaryPath(bool *ok = 0, QString *errorMessage = 0) const;
|
||||
|
||||
GitSettings &operator = (const GitSettings &s);
|
||||
};
|
||||
|
||||
@@ -98,9 +98,9 @@ bool MergeTool::start(const QString &workingDirectory, const QStringList &files)
|
||||
}
|
||||
m_process = new MergeToolProcess(this);
|
||||
m_process->setWorkingDirectory(workingDirectory);
|
||||
const QString binary = m_gitClient->gitBinaryPath();
|
||||
const Utils::FileName binary = m_gitClient->gitBinaryPath();
|
||||
VcsBase::VcsBaseOutputWindow::instance()->appendCommand(workingDirectory, binary, arguments);
|
||||
m_process->start(binary, arguments);
|
||||
m_process->start(binary.toString(), arguments);
|
||||
if (m_process->waitForStarted()) {
|
||||
connect(m_process, SIGNAL(finished(int)), this, SLOT(done()));
|
||||
connect(m_process, SIGNAL(readyRead()), this, SLOT(readData()));
|
||||
|
||||
Reference in New Issue
Block a user