forked from qt-creator/qt-creator
Perforce: Proliferate FilePath a bit
Change-Id: Ic3f03de192f782e59bd5c57654a45268c14f3f38 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -70,7 +70,7 @@ void PerforceChecker::resetOverrideCursor()
|
||||
}
|
||||
}
|
||||
|
||||
void PerforceChecker::start(const QString &binary, const QString &workingDirectory,
|
||||
void PerforceChecker::start(const FilePath &binary, const FilePath &workingDirectory,
|
||||
const QStringList &basicArgs,
|
||||
int timeoutMS)
|
||||
{
|
||||
@@ -89,7 +89,7 @@ void PerforceChecker::start(const QString &binary, const QString &workingDirecto
|
||||
if (!workingDirectory.isEmpty())
|
||||
m_process.setWorkingDirectory(workingDirectory);
|
||||
|
||||
m_process.setCommand({FilePath::fromString(m_binary), args});
|
||||
m_process.setCommand({m_binary, args});
|
||||
m_process.start();
|
||||
// Timeout handling
|
||||
m_timeOutMS = timeoutMS;
|
||||
@@ -109,7 +109,7 @@ void PerforceChecker::slotTimeOut()
|
||||
return;
|
||||
m_timedOut = true;
|
||||
m_process.stopProcess();
|
||||
emitFailed(tr("\"%1\" timed out after %2 ms.").arg(m_binary).arg(m_timeOutMS));
|
||||
emitFailed(tr("\"%1\" timed out after %2 ms.").arg(m_binary.toUserOutput()).arg(m_timeOutMS));
|
||||
}
|
||||
|
||||
void PerforceChecker::slotError(QProcess::ProcessError error)
|
||||
@@ -119,7 +119,7 @@ void PerforceChecker::slotError(QProcess::ProcessError error)
|
||||
switch (error) {
|
||||
case QProcess::FailedToStart:
|
||||
emitFailed(tr("Unable to launch \"%1\": %2").
|
||||
arg(QDir::toNativeSeparators(m_binary), m_process.errorString()));
|
||||
arg(m_binary.toUserOutput(), m_process.errorString()));
|
||||
break;
|
||||
case QProcess::Crashed: // Handled elsewhere
|
||||
case QProcess::Timedout:
|
||||
@@ -138,15 +138,15 @@ void PerforceChecker::slotFinished()
|
||||
return;
|
||||
switch (m_process.exitStatus()) {
|
||||
case QProcess::CrashExit:
|
||||
emitFailed(tr("\"%1\" crashed.").arg(QDir::toNativeSeparators(m_binary)));
|
||||
emitFailed(tr("\"%1\" crashed.").arg(m_binary.toUserOutput()));
|
||||
break;
|
||||
case QProcess::NormalExit:
|
||||
if (m_process.exitCode()) {
|
||||
const QString stdErr = QString::fromLocal8Bit(m_process.readAllStandardError());
|
||||
const QString stdErr = m_process.stdErr();
|
||||
emitFailed(tr("\"%1\" terminated with exit code %2: %3").
|
||||
arg(QDir::toNativeSeparators(m_binary)).arg(m_process.exitCode()).arg(stdErr));
|
||||
arg(m_binary.toUserOutput()).arg(m_process.exitCode()).arg(stdErr));
|
||||
} else {
|
||||
parseOutput(QString::fromLocal8Bit(m_process.readAllStandardOutput()));
|
||||
parseOutput(m_process.stdOut());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utils/filepath.h>
|
||||
#include <utils/qtcprocess.h>
|
||||
|
||||
namespace Perforce {
|
||||
@@ -41,9 +42,9 @@ public:
|
||||
explicit PerforceChecker(QObject *parent = nullptr);
|
||||
~PerforceChecker() override;
|
||||
|
||||
void start(const QString &binary,
|
||||
const QString &workingDirectory,
|
||||
const QStringList &basicArgs = QStringList(),
|
||||
void start(const Utils::FilePath &binary,
|
||||
const Utils::FilePath &workingDirectory,
|
||||
const QStringList &basicArgs = {},
|
||||
int timeoutMS = -1);
|
||||
|
||||
bool isRunning() const;
|
||||
@@ -68,7 +69,7 @@ private:
|
||||
inline void resetOverrideCursor();
|
||||
|
||||
Utils::QtcProcess m_process;
|
||||
QString m_binary;
|
||||
Utils::FilePath m_binary;
|
||||
int m_timeOutMS = -1;
|
||||
bool m_timedOut = false;
|
||||
bool m_useOverideCursor = false;
|
||||
|
@@ -239,7 +239,7 @@ public:
|
||||
|
||||
IEditor *openPerforceSubmitEditor(const QString &fileName, const QStringList &depotFileNames);
|
||||
|
||||
void getTopLevel(const QString &workingDirectory = QString(), bool isSync = false);
|
||||
void getTopLevel(const FilePath &workingDirectory = {}, bool isSync = false);
|
||||
|
||||
void updateActions(ActionState) override;
|
||||
bool submitEditorAboutToClose() override;
|
||||
@@ -284,7 +284,7 @@ public:
|
||||
FilePath m_topLevel;
|
||||
};
|
||||
|
||||
typedef QHash<QString, DirectoryCacheEntry> ManagedDirectoryCache;
|
||||
typedef QHash<FilePath, DirectoryCacheEntry> ManagedDirectoryCache;
|
||||
|
||||
IEditor *showOutputInEditor(const QString &title, const QString &output,
|
||||
Id id, const QString &source,
|
||||
@@ -326,7 +326,7 @@ public:
|
||||
|
||||
void updateCheckout(const FilePath &workingDir = {}, const QStringList &dirs = {});
|
||||
bool revertProject(const FilePath &workingDir, const QStringList &args, bool unchangedOnly);
|
||||
bool managesDirectoryFstat(const QString &directory);
|
||||
bool managesDirectoryFstat(const FilePath &directory);
|
||||
|
||||
void applySettings();
|
||||
|
||||
@@ -976,7 +976,7 @@ void PerforcePluginPrivate::updateActions(VcsBasePluginPrivate::ActionState as)
|
||||
|
||||
bool PerforcePluginPrivate::managesDirectory(const FilePath &directory, FilePath *topLevel /* = 0 */) const
|
||||
{
|
||||
const bool rc = const_cast<PerforcePluginPrivate *>(this)->managesDirectoryFstat(directory.toString());
|
||||
const bool rc = const_cast<PerforcePluginPrivate *>(this)->managesDirectoryFstat(directory);
|
||||
if (topLevel) {
|
||||
if (rc)
|
||||
*topLevel = m_settings.topLevelSymLinkTarget();
|
||||
@@ -994,7 +994,7 @@ bool PerforcePluginPrivate::managesFile(const FilePath &workingDirectory, const
|
||||
return result.stdOut.contains(QLatin1String("depotFile"));
|
||||
}
|
||||
|
||||
bool PerforcePluginPrivate::managesDirectoryFstat(const QString &directory)
|
||||
bool PerforcePluginPrivate::managesDirectoryFstat(const FilePath &directory)
|
||||
{
|
||||
// Cached?
|
||||
const ManagedDirectoryCache::const_iterator cit = m_managedDirectoryCache.constFind(directory);
|
||||
@@ -1014,7 +1014,7 @@ bool PerforcePluginPrivate::managesDirectoryFstat(const QString &directory)
|
||||
bool managed = false;
|
||||
do {
|
||||
// Quick check: Must be at or below top level and not "../../other_path"
|
||||
const QString relativeDirArgs = m_settings.relativeToTopLevelArguments(directory);
|
||||
const QString relativeDirArgs = m_settings.relativeToTopLevelArguments(directory.toString());
|
||||
if (!relativeDirArgs.isEmpty() && relativeDirArgs.startsWith(QLatin1String(".."))) {
|
||||
if (!m_settings.defaultEnv())
|
||||
break;
|
||||
@@ -1708,7 +1708,7 @@ void PerforcePluginPrivate::slotTopLevelFailed(const QString &errorMessage)
|
||||
VcsOutputWindow::appendSilently(tr("Perforce: Unable to determine the repository: %1").arg(errorMessage));
|
||||
}
|
||||
|
||||
void PerforcePluginPrivate::getTopLevel(const QString &workingDirectory, bool isSync)
|
||||
void PerforcePluginPrivate::getTopLevel(const FilePath &workingDirectory, bool isSync)
|
||||
{
|
||||
// Run a new checker
|
||||
if (m_settings.p4BinaryPath.value().isEmpty())
|
||||
@@ -1719,7 +1719,7 @@ void PerforcePluginPrivate::getTopLevel(const QString &workingDirectory, bool is
|
||||
connect(checker, &PerforceChecker::succeeded, dd, &PerforcePluginPrivate::setTopLevel);
|
||||
connect(checker, &PerforceChecker::succeeded,checker, &QObject::deleteLater);
|
||||
|
||||
checker->start(m_settings.p4BinaryPath.value(), workingDirectory,
|
||||
checker->start(m_settings.p4BinaryPath.filePath(), workingDirectory,
|
||||
m_settings.commonP4Arguments(QString()), 30000);
|
||||
|
||||
if (isSync)
|
||||
|
@@ -262,7 +262,7 @@ PerforceSettingsPage::PerforceSettingsPage(PerforceSettings *settings)
|
||||
|
||||
errorLabel->setStyleSheet(QString());
|
||||
errorLabel->setText(PerforceSettings::tr("Testing..."));
|
||||
checker->start(settings->p4BinaryPath.value(), QString(), settings->commonP4Arguments(), 10000);
|
||||
checker->start(settings->p4BinaryPath.filePath(), {}, settings->commonP4Arguments(), 10000);
|
||||
});
|
||||
|
||||
Group config {
|
||||
|
Reference in New Issue
Block a user