Vcs: Use FilePath in IVersionControl API

Adapt first level of users.

Change-Id: Ifcd7bff45631ff3b9e26a9e3176daa6cf0cf2e56
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
hjk
2021-07-29 09:31:09 +02:00
parent 69c6c9f7d5
commit edcedabed9
33 changed files with 391 additions and 379 deletions

View File

@@ -149,17 +149,17 @@ public:
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final; bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final;
bool managesDirectory(const QString &filename, QString *topLevel) const final; bool managesDirectory(const Utils::FilePath &filePath, Utils::FilePath *topLevel) const final;
bool managesFile(const QString &workingDirectory, const QString &fileName) const final; bool managesFile(const Utils::FilePath &workingDirectory, const QString &fileName) const final;
bool isConfigured() const final; bool isConfigured() const final;
bool supportsOperation(Operation operation) const final; bool supportsOperation(Operation operation) const final;
bool vcsOpen(const QString &fileName) final; bool vcsOpen(const Utils::FilePath &fileName) final;
bool vcsAdd(const QString &filename) final; bool vcsAdd(const Utils::FilePath &filePath) final;
bool vcsDelete(const QString &filename) final; bool vcsDelete(const Utils::FilePath &filePath) final;
bool vcsMove(const QString &from, const QString &to) final; bool vcsMove(const Utils::FilePath &from, const Utils::FilePath &to) final;
bool vcsCreateRepository(const QString &directory) final; bool vcsCreateRepository(const Utils::FilePath &directory) final;
void vcsAnnotate(const QString &file, int line) final; void vcsAnnotate(const Utils::FilePath &file, int line) final;
void vcsDescribe(const QString &source, const QString &id) final { m_client.view(source, id); } void vcsDescribe(const Utils::FilePath &source, const QString &id) final { m_client.view(source.toString(), id); }
Core::ShellCommand *createInitialCheckoutCommand(const QString &url, Core::ShellCommand *createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory, const Utils::FilePath &baseDirectory,
@@ -850,18 +850,18 @@ bool BazaarPluginPrivate::isVcsFileOrDirectory(const Utils::FilePath &fileName)
return m_client.isVcsDirectory(fileName); return m_client.isVcsDirectory(fileName);
} }
bool BazaarPluginPrivate::managesDirectory(const QString &directory, QString *topLevel) const bool BazaarPluginPrivate::managesDirectory(const FilePath &directory, FilePath *topLevel) const
{ {
QFileInfo dir(directory); QFileInfo dir(directory.toString());
const QString topLevelFound = m_client.findTopLevelForFile(dir); const QString topLevelFound = m_client.findTopLevelForFile(dir);
if (topLevel) if (topLevel)
*topLevel = topLevelFound; *topLevel = FilePath::fromString(topLevelFound);
return !topLevelFound.isEmpty(); return !topLevelFound.isEmpty();
} }
bool BazaarPluginPrivate::managesFile(const QString &workingDirectory, const QString &fileName) const bool BazaarPluginPrivate::managesFile(const FilePath &workingDirectory, const QString &fileName) const
{ {
return m_client.managesFile(workingDirectory, fileName); return m_client.managesFile(workingDirectory.toString(), fileName);
} }
bool BazaarPluginPrivate::isConfigured() const bool BazaarPluginPrivate::isConfigured() const
@@ -892,41 +892,41 @@ bool BazaarPluginPrivate::supportsOperation(Operation operation) const
return supported; return supported;
} }
bool BazaarPluginPrivate::vcsOpen(const QString &filename) bool BazaarPluginPrivate::vcsOpen(const FilePath &filePath)
{ {
Q_UNUSED(filename) Q_UNUSED(filePath)
return true; return true;
} }
bool BazaarPluginPrivate::vcsAdd(const QString &filename) bool BazaarPluginPrivate::vcsAdd(const FilePath &filePath)
{ {
const QFileInfo fi(filename); const QFileInfo fi = filePath.toFileInfo();
return m_client.synchronousAdd(fi.absolutePath(), fi.fileName()); return m_client.synchronousAdd(fi.absolutePath(), fi.fileName());
} }
bool BazaarPluginPrivate::vcsDelete(const QString &filename) bool BazaarPluginPrivate::vcsDelete(const FilePath &filePath)
{ {
const QFileInfo fi(filename); const QFileInfo fi = filePath.toFileInfo();
return m_client.synchronousRemove(fi.absolutePath(), fi.fileName()); return m_client.synchronousRemove(fi.absolutePath(), fi.fileName());
} }
bool BazaarPluginPrivate::vcsMove(const QString &from, const QString &to) bool BazaarPluginPrivate::vcsMove(const FilePath &from, const FilePath &to)
{ {
const QFileInfo fromInfo(from); const QFileInfo fromInfo = from.toFileInfo();
const QFileInfo toInfo(to); const QFileInfo toInfo = to.toFileInfo();
return m_client.synchronousMove(fromInfo.absolutePath(), return m_client.synchronousMove(fromInfo.absolutePath(),
fromInfo.absoluteFilePath(), fromInfo.absoluteFilePath(),
toInfo.absoluteFilePath()); toInfo.absoluteFilePath());
} }
bool BazaarPluginPrivate::vcsCreateRepository(const QString &directory) bool BazaarPluginPrivate::vcsCreateRepository(const FilePath &directory)
{ {
return m_client.synchronousCreateRepository(directory); return m_client.synchronousCreateRepository(directory.toString());
} }
void BazaarPluginPrivate::vcsAnnotate(const QString &file, int line) void BazaarPluginPrivate::vcsAnnotate(const FilePath &file, int line)
{ {
const QFileInfo fi(file); const QFileInfo fi = file.toFileInfo();
m_client.annotate(fi.absolutePath(), fi.fileName(), QString(), line); m_client.annotate(fi.absolutePath(), fi.fileName(), QString(), line);
} }

View File

@@ -183,28 +183,28 @@ public:
QString displayName() const final; QString displayName() const final;
Utils::Id id() const final; Utils::Id id() const final;
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final; bool isVcsFileOrDirectory(const FilePath &filePath) const final;
bool managesDirectory(const QString &directory, QString *topLevel) const final; bool managesDirectory(const FilePath &directory, FilePath *topLevel) const final;
bool managesFile(const QString &workingDirectory, const QString &fileName) const final; bool managesFile(const FilePath &workingDirectory, const QString &fileName) const final;
bool isConfigured() const final; bool isConfigured() const final;
bool supportsOperation(Operation operation) const final; bool supportsOperation(Operation operation) const final;
OpenSupportMode openSupportMode(const QString &fileName) const final; OpenSupportMode openSupportMode(const FilePath &filePath) const final;
bool vcsOpen(const QString &fileName) final; bool vcsOpen(const FilePath &filePath) final;
SettingsFlags settingsFlags() const final; SettingsFlags settingsFlags() const final;
bool vcsAdd(const QString &fileName) final; bool vcsAdd(const FilePath &filePath) final;
bool vcsDelete(const QString &filename) final; bool vcsDelete(const FilePath &filename) final;
bool vcsMove(const QString &from, const QString &to) final; bool vcsMove(const FilePath &from, const FilePath &to) final;
bool vcsCreateRepository(const QString &directory) final; bool vcsCreateRepository(const FilePath &directory) final;
void vcsAnnotate(const QString &file, int line) final; void vcsAnnotate(const FilePath &file, int line) final;
void vcsDescribe(const QString &source, const QString &changeNr) final; void vcsDescribe(const FilePath &source, const QString &changeNr) final;
QString vcsOpenText() const final; QString vcsOpenText() const final;
QString vcsMakeWritableText() const final; QString vcsMakeWritableText() const final;
QString vcsTopic(const QString &directory) final; QString vcsTopic(const FilePath &directory) final;
/// ///
ClearCaseSubmitEditor *openClearCaseSubmitEditor(const QString &fileName, bool isUcm); ClearCaseSubmitEditor *openClearCaseSubmitEditor(const QString &fileName, bool isUcm);
@@ -1605,36 +1605,36 @@ void ClearCasePluginPrivate::vcsAnnotateHelper(const QString &workingDir, const
} }
} }
void ClearCasePluginPrivate::vcsDescribe(const QString &source, const QString &changeNr) void ClearCasePluginPrivate::vcsDescribe(const FilePath &source, const QString &changeNr)
{ {
const QFileInfo fi(source); const QFileInfo fi = source.toFileInfo();
QString topLevel; FilePath topLevel;
const bool manages = managesDirectory(fi.isDir() ? source : fi.absolutePath(), &topLevel); const bool manages = managesDirectory(fi.isDir() ? source : FilePath::fromString(fi.absolutePath()), &topLevel);
if (!manages || topLevel.isEmpty()) if (!manages || topLevel.isEmpty())
return; return;
if (Constants::debug) if (Constants::debug)
qDebug() << Q_FUNC_INFO << source << topLevel << changeNr; qDebug() << Q_FUNC_INFO << source << topLevel << changeNr;
QString description; QString description;
QString relPath = QDir::toNativeSeparators(QDir(topLevel).relativeFilePath(source)); QString relPath = QDir::toNativeSeparators(QDir(topLevel.toString()).relativeFilePath(source.toString()));
QString id = QString::fromLatin1("%1@@%2").arg(relPath).arg(changeNr); QString id = QString::fromLatin1("%1@@%2").arg(relPath).arg(changeNr);
QStringList args(QLatin1String("describe")); QStringList args(QLatin1String("describe"));
args.push_back(id); args.push_back(id);
QTextCodec *codec = VcsBaseEditor::getCodec(source); QTextCodec *codec = VcsBaseEditor::getCodec(source.toString());
const ClearCaseResponse response = runCleartool(topLevel, args, m_settings.timeOutS, 0, codec); const ClearCaseResponse response = runCleartool(topLevel.toString(), args, m_settings.timeOutS, 0, codec);
description = response.stdOut; description = response.stdOut;
if (m_settings.extDiffAvailable) if (m_settings.extDiffAvailable)
description += diffExternal(id); description += diffExternal(id);
// Re-use an existing view if possible to support // Re-use an existing view if possible to support
// the common usage pattern of continuously changing and diffing a file // the common usage pattern of continuously changing and diffing a file
const QString tag = VcsBaseEditor::editorTag(DiffOutput, source, QStringList(), changeNr); const QString tag = VcsBaseEditor::editorTag(DiffOutput, source.toString(), QStringList(), changeNr);
if (IEditor *editor = VcsBaseEditor::locateEditorByTag(tag)) { if (IEditor *editor = VcsBaseEditor::locateEditorByTag(tag)) {
editor->document()->setContents(description.toUtf8()); editor->document()->setContents(description.toUtf8());
EditorManager::activateEditor(editor); EditorManager::activateEditor(editor);
} else { } else {
const QString title = QString::fromLatin1("cc describe %1").arg(id); const QString title = QString::fromLatin1("cc describe %1").arg(id);
IEditor *newEditor = showOutputInEditor(title, description, diffEditorParameters.id, source, codec); IEditor *newEditor = showOutputInEditor(title, description, diffEditorParameters.id, source.toString(), codec);
VcsBaseEditor::tagEditor(newEditor, tag); VcsBaseEditor::tagEditor(newEditor, tag);
} }
} }
@@ -2028,17 +2028,17 @@ bool ClearCasePluginPrivate::vcsMove(const QString &workingDir, const QString &f
/// ///
/// Check if the directory is managed under ClearCase control. /// Check if the directory is managed under ClearCase control.
/// ///
bool ClearCasePluginPrivate::managesDirectory(const QString &directory, QString *topLevel /* = 0 */) const bool ClearCasePluginPrivate::managesDirectory(const FilePath &directory, FilePath *topLevel /* = 0 */) const
{ {
#ifdef WITH_TESTS #ifdef WITH_TESTS
// If running with tests and fake ClearTool is enabled, then pretend we manage every directory // If running with tests and fake ClearTool is enabled, then pretend we manage every directory
QString topLevelFound = m_fakeClearTool ? directory : findTopLevel(directory); QString topLevelFound = m_fakeClearTool ? directory.toString() : findTopLevel(directory.toString());
#else #else
QString topLevelFound = findTopLevel(directory); QString topLevelFound = findTopLevel(directory.toString());
#endif #endif
if (topLevel) if (topLevel)
*topLevel = topLevelFound; *topLevel = FilePath::fromString(topLevelFound);
return !topLevelFound.isEmpty(); return !topLevelFound.isEmpty();
} }
@@ -2147,9 +2147,9 @@ bool ClearCasePluginPrivate::ccCheckUcm(const QString &viewname, const QString &
return catcsData.indexOf(QRegularExpression("(^|\\n)ucm\\n")) != -1; return catcsData.indexOf(QRegularExpression("(^|\\n)ucm\\n")) != -1;
} }
bool ClearCasePluginPrivate::managesFile(const QString &workingDirectory, const QString &fileName) const bool ClearCasePluginPrivate::managesFile(const FilePath &workingDirectory, const QString &fileName) const
{ {
QString absFile = QFileInfo(QDir(workingDirectory), fileName).absoluteFilePath(); QString absFile = QFileInfo(QDir(workingDirectory.toString()), fileName).absoluteFilePath();
const FileStatus::Status status = getFileStatus(absFile); const FileStatus::Status status = getFileStatus(absFile);
return status != FileStatus::NotManaged && status != FileStatus::Derived; return status != FileStatus::NotManaged && status != FileStatus::Derived;
} }
@@ -2403,9 +2403,9 @@ Utils::Id ClearCasePluginPrivate::id() const
return Constants::VCS_ID_CLEARCASE; return Constants::VCS_ID_CLEARCASE;
} }
bool ClearCasePluginPrivate::isVcsFileOrDirectory(const Utils::FilePath &fileName) const bool ClearCasePluginPrivate::isVcsFileOrDirectory(const FilePath &filePath) const
{ {
Q_UNUSED(fileName) Q_UNUSED(filePath)
return false; // ClearCase has no files/directories littering the sources return false; // ClearCase has no files/directories littering the sources
} }
@@ -2440,13 +2440,13 @@ bool ClearCasePluginPrivate::supportsOperation(Operation operation) const
return rc; return rc;
} }
Core::IVersionControl::OpenSupportMode ClearCasePluginPrivate::openSupportMode(const QString &fileName) const Core::IVersionControl::OpenSupportMode ClearCasePluginPrivate::openSupportMode(const FilePath &filePath) const
{ {
if (isDynamic()) { if (isDynamic()) {
// NB! Has to use managesFile() and not vcsStatus() since the index can only be guaranteed // NB! Has to use managesFile() and not vcsStatus() since the index can only be guaranteed
// to be up to date if the file has been explicitly opened, which is not the case when // to be up to date if the file has been explicitly opened, which is not the case when
// doing a search and replace as a part of a refactoring. // doing a search and replace as a part of a refactoring.
if (managesFile(QFileInfo(fileName).absolutePath(), fileName)) { if (managesFile(FilePath::fromString(filePath.toFileInfo().absolutePath()), filePath.toString())) {
// Checkout is the only option for managed files in dynamic views // Checkout is the only option for managed files in dynamic views
return IVersionControl::OpenMandatory; return IVersionControl::OpenMandatory;
} else { } else {
@@ -2459,9 +2459,9 @@ Core::IVersionControl::OpenSupportMode ClearCasePluginPrivate::openSupportMode(c
} }
} }
bool ClearCasePluginPrivate::vcsOpen(const QString &fileName) bool ClearCasePluginPrivate::vcsOpen(const FilePath &filePath)
{ {
const QFileInfo fi(fileName); const QFileInfo fi = filePath.toFileInfo();
return vcsOpen(fi.absolutePath(), fi.fileName()); return vcsOpen(fi.absolutePath(), fi.fileName());
} }
@@ -2473,28 +2473,28 @@ Core::IVersionControl::SettingsFlags ClearCasePluginPrivate::settingsFlags() con
return rc; return rc;
} }
bool ClearCasePluginPrivate::vcsAdd(const QString &fileName) bool ClearCasePluginPrivate::vcsAdd(const FilePath &filePath)
{ {
const QFileInfo fi(fileName); const QFileInfo fi = filePath.toFileInfo();
return vcsAdd(fi.absolutePath(), fi.fileName()); return vcsAdd(fi.absolutePath(), fi.fileName());
} }
bool ClearCasePluginPrivate::vcsDelete(const QString &fileName) bool ClearCasePluginPrivate::vcsDelete(const FilePath &filePath)
{ {
const QFileInfo fi(fileName); const QFileInfo fi = filePath.toFileInfo();
return vcsDelete(fi.absolutePath(), fi.fileName()); return vcsDelete(fi.absolutePath(), fi.fileName());
} }
bool ClearCasePluginPrivate::vcsMove(const QString &from, const QString &to) bool ClearCasePluginPrivate::vcsMove(const FilePath &from, const FilePath &to)
{ {
const QFileInfo ifrom(from); const QFileInfo ifrom = from.toFileInfo();
const QFileInfo ito(to); const QFileInfo ito = from.toFileInfo();
return vcsMove(ifrom.absolutePath(), ifrom.fileName(), ito.fileName()); return vcsMove(ifrom.absolutePath(), from.fileName(), to.fileName());
} }
void ClearCasePluginPrivate::vcsAnnotate(const QString &file, int line) void ClearCasePluginPrivate::vcsAnnotate(const FilePath &filePath, int line)
{ {
const QFileInfo fi(file); const QFileInfo fi = filePath.toFileInfo();
vcsAnnotateHelper(fi.absolutePath(), fi.fileName(), QString(), line); vcsAnnotateHelper(fi.absolutePath(), fi.fileName(), QString(), line);
} }
@@ -2510,12 +2510,12 @@ QString ClearCasePluginPrivate::vcsMakeWritableText() const
return tr("&Hijack"); return tr("&Hijack");
} }
QString ClearCasePluginPrivate::vcsTopic(const QString &directory) QString ClearCasePluginPrivate::vcsTopic(const FilePath &directory)
{ {
return ccGetView(directory).name; return ccGetView(directory.toString()).name;
} }
bool ClearCasePluginPrivate::vcsCreateRepository(const QString &) bool ClearCasePluginPrivate::vcsCreateRepository(const FilePath &)
{ {
return false; return false;
} }

View File

@@ -33,7 +33,7 @@ namespace Core {
namespace Internal { namespace Internal {
AddToVcsDialog::AddToVcsDialog(QWidget *parent, const QString &title, AddToVcsDialog::AddToVcsDialog(QWidget *parent, const QString &title,
const QStringList &files, const QString &vcsDisplayName) : const Utils::FilePaths &files, const QString &vcsDisplayName) :
QDialog(parent), QDialog(parent),
ui(new Ui::AddToVcsDialog) ui(new Ui::AddToVcsDialog)
{ {
@@ -45,8 +45,8 @@ AddToVcsDialog::AddToVcsDialog(QWidget *parent, const QString &title,
ui->addFilesLabel->setText(addTo); ui->addFilesLabel->setText(addTo);
setWindowTitle(title); setWindowTitle(title);
foreach (const QString &file, files) { for (const Utils::FilePath &file : files) {
QListWidgetItem *item = new QListWidgetItem(QDir::toNativeSeparators(file)); QListWidgetItem *item = new QListWidgetItem(file.toUserOutput());
ui->filesListWidget->addItem(item); ui->filesListWidget->addItem(item);
} }
} }

View File

@@ -25,6 +25,8 @@
#pragma once #pragma once
#include <utils/filepath.h>
#include <QDialog> #include <QDialog>
namespace Core { namespace Core {
@@ -38,7 +40,7 @@ class AddToVcsDialog : public QDialog
public: public:
explicit AddToVcsDialog(QWidget *parent, const QString &title, explicit AddToVcsDialog(QWidget *parent, const QString &title,
const QStringList &files, const QString &vcsDisplayName); const Utils::FilePaths &files, const QString &vcsDisplayName);
~AddToVcsDialog() override; ~AddToVcsDialog() override;
private: private:

View File

@@ -308,7 +308,7 @@ int ReadOnlyFilesDialog::exec()
} }
break; break;
case RO_OpenVCS: case RO_OpenVCS:
if (!d->versionControls[buttongroup.filePath]->vcsOpen(buttongroup.filePath.toString())) { if (!d->versionControls[buttongroup.filePath]->vcsOpen(buttongroup.filePath)) {
failedToMakeWritable << buttongroup.filePath; failedToMakeWritable << buttongroup.filePath;
continue; continue;
} }
@@ -429,7 +429,7 @@ void ReadOnlyFilesDialogPrivate::initDialog(const FilePaths &filePaths)
IVersionControl *versionControlForFile = IVersionControl *versionControlForFile =
VcsManager::findVersionControlForDirectory(directory.toString()); VcsManager::findVersionControlForDirectory(directory.toString());
const bool fileManagedByVCS = versionControlForFile const bool fileManagedByVCS = versionControlForFile
&& versionControlForFile->openSupportMode(filePath.toString()) != IVersionControl::NoOpen; && versionControlForFile->openSupportMode(filePath) != IVersionControl::NoOpen;
if (fileManagedByVCS) { if (fileManagedByVCS) {
const QString vcsOpenTextForFile = const QString vcsOpenTextForFile =
Utils::stripAccelerator(versionControlForFile->vcsOpenText()); Utils::stripAccelerator(versionControlForFile->vcsOpenText());
@@ -447,7 +447,7 @@ void ReadOnlyFilesDialogPrivate::initDialog(const FilePaths &filePaths)
vcsMakeWritableTextForAll.clear(); vcsMakeWritableTextForAll.clear();
} }
// Add make writable if it is supported by the reposetory. // Add make writable if it is supported by the reposetory.
if (versionControlForFile->openSupportMode(filePath.toString()) == IVersionControl::OpenOptional) { if (versionControlForFile->openSupportMode(filePath) == IVersionControl::OpenOptional) {
useMakeWritable = true; useMakeWritable = true;
createRadioButtonForItem(item, radioButtonGroup, MakeWritable); createRadioButtonForItem(item, radioButtonGroup, MakeWritable);
} }

View File

@@ -2006,7 +2006,7 @@ void EditorManagerPrivate::updateMakeWritableWarning()
bool promptVCS = false; bool promptVCS = false;
const QString directory = document->filePath().toFileInfo().absolutePath(); const QString directory = document->filePath().toFileInfo().absolutePath();
IVersionControl *versionControl = VcsManager::findVersionControlForDirectory(directory); IVersionControl *versionControl = VcsManager::findVersionControlForDirectory(directory);
if (versionControl && versionControl->openSupportMode(document->filePath().toString()) != IVersionControl::NoOpen) { if (versionControl && versionControl->openSupportMode(document->filePath()) != IVersionControl::NoOpen) {
if (versionControl->settingsFlags() & IVersionControl::AutoOpen) { if (versionControl->settingsFlags() & IVersionControl::AutoOpen) {
vcsOpenCurrentEditor(); vcsOpenCurrentEditor();
ww = false; ww = false;
@@ -2258,10 +2258,10 @@ void EditorManagerPrivate::vcsOpenCurrentEditor()
const QString directory = document->filePath().toFileInfo().absolutePath(); const QString directory = document->filePath().toFileInfo().absolutePath();
IVersionControl *versionControl = VcsManager::findVersionControlForDirectory(directory); IVersionControl *versionControl = VcsManager::findVersionControlForDirectory(directory);
if (!versionControl || versionControl->openSupportMode(document->filePath().toString()) == IVersionControl::NoOpen) if (!versionControl || versionControl->openSupportMode(document->filePath()) == IVersionControl::NoOpen)
return; return;
if (!versionControl->vcsOpen(document->filePath().toString())) { if (!versionControl->vcsOpen(document->filePath())) {
// TODO: wrong dialog parent // TODO: wrong dialog parent
QMessageBox::warning(ICore::dialogParent(), tr("Cannot Open File"), QMessageBox::warning(ICore::dialogParent(), tr("Cannot Open File"),
tr("Cannot open the file for editing with VCS.")); tr("Cannot open the file for editing with VCS."));

View File

@@ -205,7 +205,7 @@ bool FileUtils::renameFile(const FilePath &orgFilePath, const FilePath &newFileP
bool result = false; bool result = false;
if (vc && vc->supportsOperation(IVersionControl::MoveOperation)) if (vc && vc->supportsOperation(IVersionControl::MoveOperation))
result = vc->vcsMove(orgFilePath.toString(), newFilePath.toString()); result = vc->vcsMove(orgFilePath, newFilePath);
if (!result) // The moving via vcs failed or the vcs does not support moving, fall back if (!result) // The moving via vcs failed or the vcs does not support moving, fall back
result = Utils::FileUtils::renameFile(orgFilePath, newFilePath); result = Utils::FileUtils::renameFile(orgFilePath, newFilePath);
if (result) { if (result) {

View File

@@ -68,6 +68,9 @@
\fn Core::IVersionControl::TopicCache::refreshTopic(const QString &repository) \fn Core::IVersionControl::TopicCache::refreshTopic(const QString &repository)
Returns the current topic for \a repository. Returns the current topic for \a repository.
*/ */
using namespace Utils;
namespace Core { namespace Core {
QString IVersionControl::vcsOpenText() const QString IVersionControl::vcsOpenText() const
@@ -146,7 +149,7 @@ void IVersionControl::setTopicCache(TopicCache *topicCache)
m_topicCache = topicCache; m_topicCache = topicCache;
} }
QString IVersionControl::vcsTopic(const QString &topLevel) QString IVersionControl::vcsTopic(const FilePath &topLevel)
{ {
return m_topicCache ? m_topicCache->topic(topLevel) : QString(); return m_topicCache ? m_topicCache->topic(topLevel) : QString();
} }
@@ -161,17 +164,16 @@ IVersionControl::~IVersionControl()
delete m_topicCache; delete m_topicCache;
} }
QStringList IVersionControl::unmanagedFiles(const QStringList &filePaths) const FilePaths IVersionControl::unmanagedFiles(const FilePaths &filePaths) const
{ {
return Utils::filtered(filePaths, [this](const QString &f) { return Utils::filtered(filePaths, [this](const FilePath &fp) {
const Utils::FilePath fp = Utils::FilePath::fromString(f); return !managesFile(fp.parentDir(), fp.fileName());
return !managesFile(fp.parentDir().toString(), fp.fileName());
}); });
} }
IVersionControl::OpenSupportMode IVersionControl::openSupportMode(const QString &fileName) const IVersionControl::OpenSupportMode IVersionControl::openSupportMode(const FilePath &filePath) const
{ {
Q_UNUSED(fileName) Q_UNUSED(filePath)
return NoOpen; return NoOpen;
} }
@@ -182,26 +184,26 @@ IVersionControl::TopicCache::~TopicCache() = default;
If the cache for \a topLevel is valid, it will be used. Otherwise it will be refreshed. If the cache for \a topLevel is valid, it will be used. Otherwise it will be refreshed.
*/ */
QString IVersionControl::TopicCache::topic(const QString &topLevel) QString IVersionControl::TopicCache::topic(const FilePath &topLevel)
{ {
QTC_ASSERT(!topLevel.isEmpty(), return QString()); QTC_ASSERT(!topLevel.isEmpty(), return QString());
TopicData &data = m_cache[topLevel]; TopicData &data = m_cache[topLevel];
QString file = trackFile(topLevel); const FilePath file = trackFile(topLevel);
if (file.isEmpty()) if (file.isEmpty())
return QString(); return QString();
const QDateTime lastModified = QFileInfo(file).lastModified(); const QDateTime lastModified = file.lastModified();
if (lastModified == data.timeStamp) if (lastModified == data.timeStamp)
return data.topic; return data.topic;
data.timeStamp = lastModified; data.timeStamp = lastModified;
return data.topic = refreshTopic(topLevel); return data.topic = refreshTopic(topLevel);
} }
void IVersionControl::fillLinkContextMenu(QMenu *, const QString &, const QString &) void IVersionControl::fillLinkContextMenu(QMenu *, const FilePath &, const QString &)
{ {
} }
bool IVersionControl::handleLink(const QString &workingDirectory, const QString &reference) bool IVersionControl::handleLink(const FilePath &workingDirectory, const QString &reference)
{ {
QTC_ASSERT(!reference.isEmpty(), return false); QTC_ASSERT(!reference.isEmpty(), return false);
vcsDescribe(workingDirectory, reference); vcsDescribe(workingDirectory, reference);
@@ -221,42 +223,40 @@ TestVersionControl::~TestVersionControl()
VcsManager::clearVersionControlCache(); VcsManager::clearVersionControlCache();
} }
void TestVersionControl::setManagedDirectories(const QHash<QString, QString> &dirs) void TestVersionControl::setManagedDirectories(const QHash<FilePath, FilePath> &dirs)
{ {
m_managedDirs = dirs; m_managedDirs = dirs;
m_dirCount = 0; m_dirCount = 0;
VcsManager::clearVersionControlCache(); VcsManager::clearVersionControlCache();
} }
void TestVersionControl::setManagedFiles(const QSet<QString> &files) void TestVersionControl::setManagedFiles(const QSet<FilePath> &files)
{ {
m_managedFiles = files; m_managedFiles = files;
m_fileCount = 0; m_fileCount = 0;
VcsManager::clearVersionControlCache(); VcsManager::clearVersionControlCache();
} }
bool TestVersionControl::managesDirectory(const QString &filename, QString *topLevel) const bool TestVersionControl::managesDirectory(const FilePath &filePath, FilePath *topLevel) const
{ {
++m_dirCount; ++m_dirCount;
if (m_managedDirs.contains(filename)) { if (m_managedDirs.contains(filePath)) {
if (topLevel) if (topLevel)
*topLevel = m_managedDirs.value(filename); *topLevel = m_managedDirs.value(filePath);
return true; return true;
} }
return false; return false;
} }
bool TestVersionControl::managesFile(const QString &workingDirectory, const QString &fileName) const bool TestVersionControl::managesFile(const FilePath &workingDirectory, const QString &fileName) const
{ {
++m_fileCount; ++m_fileCount;
QFileInfo fi(workingDirectory + QLatin1Char('/') + fileName); FilePath full = workingDirectory.pathAppended(fileName);
QString dir = fi.absolutePath(); if (!managesDirectory(full.parentDir(), nullptr))
if (!managesDirectory(dir, nullptr))
return false; return false;
QString file = fi.absoluteFilePath(); return m_managedFiles.contains(full.absoluteFilePath());
return m_managedFiles.contains(file);
} }
} // namespace Core } // namespace Core

View File

@@ -28,7 +28,7 @@
#include "core_global.h" #include "core_global.h"
#include <utils/id.h> #include <utils/id.h>
#include <utils/fileutils.h> #include <utils/filepath.h>
#include <QDateTime> #include <QDateTime>
#include <QFlags> #include <QFlags>
@@ -71,11 +71,11 @@ public:
{ {
public: public:
virtual ~TopicCache(); virtual ~TopicCache();
QString topic(const QString &topLevel); QString topic(const Utils::FilePath &topLevel);
protected: protected:
virtual QString trackFile(const QString &repository) = 0; virtual Utils::FilePath trackFile(const Utils::FilePath &repository) = 0;
virtual QString refreshTopic(const QString &repository) = 0; virtual QString refreshTopic(const Utils::FilePath &repository) = 0;
private: private:
class TopicData class TopicData
@@ -85,7 +85,7 @@ public:
QString topic; QString topic;
}; };
QHash<QString, TopicData> m_cache; QHash<Utils::FilePath, TopicData> m_cache;
}; };
@@ -97,8 +97,8 @@ public:
/*! /*!
* \brief isVcsFileOrDirectory * \brief isVcsFileOrDirectory
* \param fileName * \param filePath
* \return True if filename is a file or directory that is maintained by the * \return True if filePath is a file or directory that is maintained by the
* version control system. * version control system.
* *
* It will return true only for exact matches of the name, not for e.g. files in a * It will return true only for exact matches of the name, not for e.g. files in a
@@ -106,7 +106,7 @@ public:
* *
* This method needs to be thread safe! * This method needs to be thread safe!
*/ */
virtual bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const = 0; virtual bool isVcsFileOrDirectory(const Utils::FilePath &filePath) const = 0;
/*! /*!
* Returns whether files in this directory should be managed with this * Returns whether files in this directory should be managed with this
@@ -116,22 +116,24 @@ public:
* that all files in the returned directory are managed by the same IVersionControl. * that all files in the returned directory are managed by the same IVersionControl.
*/ */
virtual bool managesDirectory(const QString &filename, QString *topLevel = nullptr) const = 0; virtual bool managesDirectory(const Utils::FilePath &filePath,
Utils::FilePath *topLevel = nullptr) const = 0;
/*! /*!
* Returns whether \a fileName is managed by this version control. * Returns whether \a relativeFilePath is managed by this version control.
* *
* \a workingDirectory is assumed to be part of a valid repository (not necessarily its * \a workingDirectory is assumed to be part of a valid repository (not necessarily its
* top level). \a fileName is expected to be relative to workingDirectory. * top level). \a fileName is expected to be relative to workingDirectory.
*/ */
virtual bool managesFile(const QString &workingDirectory, const QString &fileName) const = 0; virtual bool managesFile(const Utils::FilePath &workingDirectory,
const QString &fileName) const = 0;
/*! /*!
* Returns the subset of \a filePaths that is not managed by this version control. * Returns the subset of \a filePaths that is not managed by this version control.
* *
* The \a filePaths are expected to be absolute paths. * The \a filePaths are expected to be absolute paths.
*/ */
virtual QStringList unmanagedFiles(const QStringList &filePaths) const; virtual Utils::FilePaths unmanagedFiles(const Utils::FilePaths &filePaths) const;
/*! /*!
* Returns true is the VCS is configured to run. * Returns true is the VCS is configured to run.
@@ -145,9 +147,9 @@ public:
virtual bool supportsOperation(Operation operation) const = 0; virtual bool supportsOperation(Operation operation) const = 0;
/*! /*!
* Returns the open support mode for \a fileName. * Returns the open support mode for \a filePath.
*/ */
virtual OpenSupportMode openSupportMode(const QString &fileName) const; virtual OpenSupportMode openSupportMode(const Utils::FilePath &filepath) const;
/*! /*!
* Called prior to save, if the file is read only. Should be implemented if * Called prior to save, if the file is read only. Should be implemented if
@@ -155,7 +157,7 @@ public:
* *
* \note The EditorManager calls this for the editors. * \note The EditorManager calls this for the editors.
*/ */
virtual bool vcsOpen(const QString &fileName) = 0; virtual bool vcsOpen(const Utils::FilePath &filePath) = 0;
/*! /*!
* Returns settings. * Returns settings.
@@ -171,34 +173,34 @@ public:
* \note This function should be called from IProject subclasses after * \note This function should be called from IProject subclasses after
* files are added to the project. * files are added to the project.
*/ */
virtual bool vcsAdd(const QString &filename) = 0; virtual bool vcsAdd(const Utils::FilePath &filePath) = 0;
/*! /*!
* Called after a file has been removed from the project (if the user * Called after a file has been removed from the project (if the user
* wants), e.g. 'p4 delete', 'svn delete'. * wants), e.g. 'p4 delete', 'svn delete'.
*/ */
virtual bool vcsDelete(const QString &filename) = 0; virtual bool vcsDelete(const Utils::FilePath &filePath) = 0;
/*! /*!
* Called to rename a file, should do the actual on disk renaming * Called to rename a file, should do the actual on disk renaming
* (e.g. git mv, svn move, p4 move) * (e.g. git mv, svn move, p4 move)
*/ */
virtual bool vcsMove(const QString &from, const QString &to) = 0; virtual bool vcsMove(const Utils::FilePath &from, const Utils::FilePath &to) = 0;
/*! /*!
* Called to initialize the version control system in a directory. * Called to initialize the version control system in a directory.
*/ */
virtual bool vcsCreateRepository(const QString &directory) = 0; virtual bool vcsCreateRepository(const Utils::FilePath &directory) = 0;
/*! /*!
* Topic (e.g. name of the current branch) * Topic (e.g. name of the current branch)
*/ */
virtual QString vcsTopic(const QString &topLevel); virtual QString vcsTopic(const Utils::FilePath &topLevel);
/*! /*!
* Display annotation for a file and scroll to line * Display annotation for a file and scroll to line
*/ */
virtual void vcsAnnotate(const QString &file, int line) = 0; virtual void vcsAnnotate(const Utils::FilePath &file, int line) = 0;
/*! /*!
* Display text for Open operation * Display text for Open operation
@@ -213,7 +215,7 @@ public:
/*! /*!
* Display details of reference * Display details of reference
*/ */
virtual void vcsDescribe(const QString &workingDirectory, const QString &reference) = 0; virtual void vcsDescribe(const Utils::FilePath &workingDirectory, const QString &reference) = 0;
/*! /*!
* Return a list of paths where tools that came with the VCS may be installed. * Return a list of paths where tools that came with the VCS may be installed.
@@ -233,10 +235,10 @@ public:
const QStringList &extraArgs); const QStringList &extraArgs);
virtual void fillLinkContextMenu(QMenu *menu, virtual void fillLinkContextMenu(QMenu *menu,
const QString &workingDirectory, const Utils::FilePath &workingDirectory,
const QString &reference); const QString &reference);
virtual bool handleLink(const QString &workingDirectory, const QString &reference); virtual bool handleLink(const Utils::FilePath &workingDirectory, const QString &reference);
class CORE_EXPORT RepoUrl { class CORE_EXPORT RepoUrl {
public: public:
@@ -281,11 +283,11 @@ public:
{ } { }
~TestVersionControl() override; ~TestVersionControl() override;
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final bool isVcsFileOrDirectory(const Utils::FilePath &filePath) const final
{ Q_UNUSED(fileName) return false; } { Q_UNUSED(filePath) return false; }
void setManagedDirectories(const QHash<QString, QString> &dirs); void setManagedDirectories(const QHash<Utils::FilePath, Utils::FilePath> &dirs);
void setManagedFiles(const QSet<QString> &files); void setManagedFiles(const QSet<Utils::FilePath> &files);
int dirCount() const { return m_dirCount; } int dirCount() const { return m_dirCount; }
int fileCount() const { return m_fileCount; } int fileCount() const { return m_fileCount; }
@@ -293,23 +295,23 @@ public:
// IVersionControl interface // IVersionControl interface
QString displayName() const override { return m_displayName; } QString displayName() const override { return m_displayName; }
Utils::Id id() const override { return m_id; } Utils::Id id() const override { return m_id; }
bool managesDirectory(const QString &filename, QString *topLevel) const override; bool managesDirectory(const Utils::FilePath &filePath, Utils::FilePath *topLevel) const override;
bool managesFile(const QString &workingDirectory, const QString &fileName) const override; bool managesFile(const Utils::FilePath &workingDirectory, const QString &fileName) const override;
bool isConfigured() const override { return true; } bool isConfigured() const override { return true; }
bool supportsOperation(Operation) const override { return false; } bool supportsOperation(Operation) const override { return false; }
bool vcsOpen(const QString &) override { return false; } bool vcsOpen(const Utils::FilePath &) override { return false; }
bool vcsAdd(const QString &) override { return false; } bool vcsAdd(const Utils::FilePath &) override { return false; }
bool vcsDelete(const QString &) override { return false; } bool vcsDelete(const Utils::FilePath &) override { return false; }
bool vcsMove(const QString &, const QString &) override { return false; } bool vcsMove(const Utils::FilePath &, const Utils::FilePath &) override { return false; }
bool vcsCreateRepository(const QString &) override { return false; } bool vcsCreateRepository(const Utils::FilePath &) override { return false; }
void vcsAnnotate(const QString &, int) override {} void vcsAnnotate(const Utils::FilePath &, int) override {}
void vcsDescribe(const QString &, const QString &) override {} void vcsDescribe(const Utils::FilePath &, const QString &) override {}
private: private:
Utils::Id m_id; Utils::Id m_id;
QString m_displayName; QString m_displayName;
QHash<QString, QString> m_managedDirs; QHash<Utils::FilePath, Utils::FilePath> m_managedDirs;
QSet<QString> m_managedFiles; QSet<Utils::FilePath> m_managedFiles;
mutable int m_dirCount = 0; mutable int m_dirCount = 0;
mutable int m_fileCount = 0; mutable int m_fileCount = 0;
}; };

View File

@@ -241,9 +241,9 @@ IVersionControl* VcsManager::findVersionControlForDirectory(const QString &input
StringVersionControlPairs allThatCanManage; StringVersionControlPairs allThatCanManage;
foreach (IVersionControl * versionControl, versionControls()) { foreach (IVersionControl * versionControl, versionControls()) {
QString topLevel; FilePath topLevel;
if (versionControl->managesDirectory(directory, &topLevel)) if (versionControl->managesDirectory(FilePath::fromString(directory), &topLevel))
allThatCanManage.push_back(StringVersionControlPair(topLevel, versionControl)); allThatCanManage.push_back(StringVersionControlPair(topLevel.toString(), versionControl));
} }
// To properly find a nested repository (say, git checkout inside SVN), // To properly find a nested repository (say, git checkout inside SVN),
@@ -386,7 +386,7 @@ FilePaths VcsManager::promptToDelete(IVersionControl *vc, const FilePaths &fileP
FilePaths failedFiles; FilePaths failedFiles;
for (const FilePath &fp : filePaths) { for (const FilePath &fp : filePaths) {
if (!vc->vcsDelete(fp.toString())) if (!vc->vcsDelete(fp))
failedFiles << fp; failedFiles << fp;
} }
return failedFiles; return failedFiles;
@@ -437,7 +437,7 @@ void VcsManager::promptToAdd(const QString &directory, const QStringList &fileNa
if (!vc || !vc->supportsOperation(IVersionControl::AddOperation)) if (!vc || !vc->supportsOperation(IVersionControl::AddOperation))
return; return;
const QStringList unmanagedFiles = vc->unmanagedFiles(fileNames); const FilePaths unmanagedFiles = vc->unmanagedFiles(Utils::transform(fileNames, &FilePath::fromString));
if (unmanagedFiles.isEmpty()) if (unmanagedFiles.isEmpty())
return; return;
@@ -445,9 +445,9 @@ void VcsManager::promptToAdd(const QString &directory, const QStringList &fileNa
unmanagedFiles, vc->displayName()); unmanagedFiles, vc->displayName());
if (dlg.exec() == QDialog::Accepted) { if (dlg.exec() == QDialog::Accepted) {
QStringList notAddedToVc; QStringList notAddedToVc;
foreach (const QString &file, unmanagedFiles) { for (const FilePath &file : unmanagedFiles) {
if (!vc->vcsAdd(QDir(directory).filePath(file))) if (!vc->vcsAdd(FilePath::fromString(QDir(directory).filePath(file.path()))))
notAddedToVc << file; notAddedToVc << file.toUserOutput();
} }
if (!notAddedToVc.isEmpty()) { if (!notAddedToVc.isEmpty()) {
@@ -495,16 +495,16 @@ namespace Internal {
const char ID_VCS_A[] = "A"; const char ID_VCS_A[] = "A";
const char ID_VCS_B[] = "B"; const char ID_VCS_B[] = "B";
using FileHash = QHash<QString, QString>; using FileHash = QHash<FilePath, FilePath>;
static FileHash makeHash(const QStringList &list) static FileHash makeHash(const QStringList &list)
{ {
FileHash result; FileHash result;
foreach (const QString &i, list) { for (const QString &i : list) {
QStringList parts = i.split(QLatin1Char(':')); QStringList parts = i.split(QLatin1Char(':'));
QTC_ASSERT(parts.count() == 2, continue); QTC_ASSERT(parts.count() == 2, continue);
result.insert(QString::fromLatin1(TEST_PREFIX) + parts.at(0), result.insert(FilePath::fromString(QString::fromLatin1(TEST_PREFIX) + parts.at(0)),
QString::fromLatin1(TEST_PREFIX) + parts.at(1)); FilePath::fromString(QString::fromLatin1(TEST_PREFIX) + parts.at(1)));
} }
return result; return result;
} }

View File

@@ -236,18 +236,18 @@ public:
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final; bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final;
bool managesDirectory(const QString &directory, QString *topLevel) const final; bool managesDirectory(const Utils::FilePath &directory, Utils::FilePath *topLevel) const final;
bool managesFile(const QString &workingDirectory, const QString &fileName) const final; bool managesFile(const Utils::FilePath &workingDirectory, const QString &fileName) const final;
bool isConfigured() const final; bool isConfigured() const final;
bool supportsOperation(Operation operation) const final; bool supportsOperation(Operation operation) const final;
OpenSupportMode openSupportMode(const QString &fileName) const final; OpenSupportMode openSupportMode(const Utils::FilePath &filePath) const final;
bool vcsOpen(const QString &fileName) final; bool vcsOpen(const Utils::FilePath &filePath) final;
bool vcsAdd(const QString &fileName) final; bool vcsAdd(const Utils::FilePath &filePath) final;
bool vcsDelete(const QString &filename) final; bool vcsDelete(const Utils::FilePath &filePath) final;
bool vcsMove(const QString &, const QString &) final { return false; } bool vcsMove(const Utils::FilePath &, const Utils::FilePath &) final { return false; }
bool vcsCreateRepository(const QString &directory) final; bool vcsCreateRepository(const Utils::FilePath &directory) final;
void vcsAnnotate(const QString &file, int line) final; void vcsAnnotate(const Utils::FilePath &filePath, int line) final;
QString vcsOpenText() const final; QString vcsOpenText() const final;
@@ -268,7 +268,7 @@ public:
void vcsAnnotate(const QString &workingDirectory, const QString &file, void vcsAnnotate(const QString &workingDirectory, const QString &file,
const QString &revision, int lineNumber); const QString &revision, int lineNumber);
void vcsDescribe(const QString &source, const QString &changeNr) final; void vcsDescribe(const Utils::FilePath &source, const QString &changeNr) final;
protected: protected:
void updateActions(ActionState) final; void updateActions(ActionState) final;
@@ -436,38 +436,38 @@ bool CvsPluginPrivate::supportsOperation(Operation operation) const
return rc; return rc;
} }
Core::IVersionControl::OpenSupportMode CvsPluginPrivate::openSupportMode(const QString &fileName) const Core::IVersionControl::OpenSupportMode CvsPluginPrivate::openSupportMode(const FilePath &filePath) const
{ {
Q_UNUSED(fileName) Q_UNUSED(filePath)
return OpenOptional; return OpenOptional;
} }
bool CvsPluginPrivate::vcsOpen(const QString &fileName) bool CvsPluginPrivate::vcsOpen(const FilePath &filePath)
{ {
const QFileInfo fi(fileName); const QFileInfo fi = filePath.toFileInfo();
return edit(fi.absolutePath(), QStringList(fi.fileName())); return edit(fi.absolutePath(), QStringList(fi.fileName()));
} }
bool CvsPluginPrivate::vcsAdd(const QString &fileName) bool CvsPluginPrivate::vcsAdd(const FilePath &filePath)
{ {
const QFileInfo fi(fileName); const QFileInfo fi = filePath.toFileInfo();
return vcsAdd(fi.absolutePath(), fi.fileName()); return vcsAdd(fi.absolutePath(), fi.fileName());
} }
bool CvsPluginPrivate::vcsDelete(const QString &fileName) bool CvsPluginPrivate::vcsDelete(const FilePath &filePath)
{ {
const QFileInfo fi(fileName); const QFileInfo fi = filePath.toFileInfo();
return vcsDelete(fi.absolutePath(), fi.fileName()); return vcsDelete(fi.absolutePath(), fi.fileName());
} }
bool CvsPluginPrivate::vcsCreateRepository(const QString &) bool CvsPluginPrivate::vcsCreateRepository(const FilePath &)
{ {
return false; return false;
} }
void CvsPluginPrivate::vcsAnnotate(const QString &file, int line) void CvsPluginPrivate::vcsAnnotate(const FilePath &filePath, int line)
{ {
const QFileInfo fi(file); const QFileInfo fi = filePath.toFileInfo();
vcsAnnotate(fi.absolutePath(), fi.fileName(), QString(), line); vcsAnnotate(fi.absolutePath(), fi.fileName(), QString(), line);
} }
@@ -740,10 +740,10 @@ CvsPluginPrivate::CvsPluginPrivate()
connect(&m_settings, &AspectContainer::applied, this, &IVersionControl::configurationChanged); connect(&m_settings, &AspectContainer::applied, this, &IVersionControl::configurationChanged);
} }
void CvsPluginPrivate::vcsDescribe(const QString &source, const QString &changeNr) void CvsPluginPrivate::vcsDescribe(const FilePath &source, const QString &changeNr)
{ {
QString errorMessage; QString errorMessage;
if (!describe(source, changeNr, &errorMessage)) if (!describe(source.toString(), changeNr, &errorMessage))
VcsOutputWindow::appendError(errorMessage); VcsOutputWindow::appendError(errorMessage);
}; };
@@ -1284,15 +1284,14 @@ void CvsPluginPrivate::updateRepository()
bool CvsPluginPrivate::describe(const QString &file, const QString &changeNr, QString *errorMessage) bool CvsPluginPrivate::describe(const QString &file, const QString &changeNr, QString *errorMessage)
{ {
FilePath toplevel;
QString toplevel; const bool manages = managesDirectory(FilePath::fromString(QFileInfo(file).absolutePath()), &toplevel);
const bool manages = managesDirectory(QFileInfo(file).absolutePath(), &toplevel);
if (!manages || toplevel.isEmpty()) { if (!manages || toplevel.isEmpty()) {
*errorMessage = tr("Cannot find repository for \"%1\".") *errorMessage = tr("Cannot find repository for \"%1\".")
.arg(QDir::toNativeSeparators(file)); .arg(QDir::toNativeSeparators(file));
return false; return false;
} }
return describe(toplevel, QDir(toplevel).relativeFilePath(file), changeNr, errorMessage); return describe(toplevel.toString(), QDir(toplevel.toString()).relativeFilePath(file), changeNr, errorMessage);
} }
bool CvsPluginPrivate::describe(const QString &toplevel, const QString &file, const bool CvsPluginPrivate::describe(const QString &toplevel, const QString &file, const
@@ -1518,12 +1517,12 @@ bool CvsPluginPrivate::vcsDelete(const QString &workingDir, const QString &rawFi
/* CVS has a "CVS" directory in each directory it manages. The top level /* CVS has a "CVS" directory in each directory it manages. The top level
* is the first directory under the directory that does not have it. */ * is the first directory under the directory that does not have it. */
bool CvsPluginPrivate::managesDirectory(const QString &directory, QString *topLevel /* = 0 */) const bool CvsPluginPrivate::managesDirectory(const FilePath &directory, FilePath *topLevel /* = 0 */) const
{ {
if (topLevel) if (topLevel)
topLevel->clear(); topLevel->clear();
bool manages = false; bool manages = false;
const QDir dir(directory); const QDir dir(directory.toString());
do { do {
if (!dir.exists() || !checkCVSDirectory(dir)) if (!dir.exists() || !checkCVSDirectory(dir))
break; break;
@@ -1538,7 +1537,7 @@ bool CvsPluginPrivate::managesDirectory(const QString &directory, QString *topLe
!parentDir.isRoot() && parentDir.cdUp(); !parentDir.isRoot() && parentDir.cdUp();
lastDirectory = parentDir) { lastDirectory = parentDir) {
if (!checkCVSDirectory(parentDir)) { if (!checkCVSDirectory(parentDir)) {
*topLevel = lastDirectory.absolutePath(); *topLevel = FilePath::fromString(lastDirectory.absolutePath());
break; break;
} }
} }
@@ -1547,12 +1546,12 @@ bool CvsPluginPrivate::managesDirectory(const QString &directory, QString *topLe
return manages; return manages;
} }
bool CvsPluginPrivate::managesFile(const QString &workingDirectory, const QString &fileName) const bool CvsPluginPrivate::managesFile(const FilePath &workingDirectory, const QString &fileName) const
{ {
QStringList args; QStringList args;
args << QLatin1String("status") << fileName; args << QLatin1String("status") << fileName;
const CvsResponse response = const CvsResponse response =
runCvs(workingDirectory, args, m_settings.timeout.value(), VcsCommand::SshPasswordPrompt); runCvs(workingDirectory.toString(), args, m_settings.timeout.value(), VcsCommand::SshPasswordPrompt);
if (response.result != CvsResponse::Ok) if (response.result != CvsResponse::Ok)
return false; return false;
return !response.stdOut.contains(QLatin1String("Status: Unknown")); return !response.stdOut.contains(QLatin1String("Status: Unknown"));

View File

@@ -844,14 +844,13 @@ bool GitClient::managesFile(const QString &workingDirectory, const QString &file
return proc.result() == QtcProcess::FinishedWithSuccess; return proc.result() == QtcProcess::FinishedWithSuccess;
} }
QStringList GitClient::unmanagedFiles(const QStringList &filePaths) const FilePaths GitClient::unmanagedFiles(const FilePaths &filePaths) const
{ {
QMap<QString, QStringList> filesForDir; QMap<QString, QStringList> filesForDir;
for (const QString &filePath : filePaths) { for (const FilePath &fp : filePaths) {
const FilePath fp = FilePath::fromString(filePath);
filesForDir[fp.parentDir().toString()] << fp.fileName(); filesForDir[fp.parentDir().toString()] << fp.fileName();
} }
QStringList res; FilePaths res;
for (auto it = filesForDir.begin(), end = filesForDir.end(); it != end; ++it) { for (auto it = filesForDir.begin(), end = filesForDir.end(); it != end; ++it) {
QStringList args({"ls-files", "-z"}); QStringList args({"ls-files", "-z"});
const QDir wd(it.key()); const QDir wd(it.key());
@@ -863,9 +862,10 @@ QStringList GitClient::unmanagedFiles(const QStringList &filePaths) const
const QStringList managedFilePaths const QStringList managedFilePaths
= transform(proc.stdOut().split('\0', Qt::SkipEmptyParts), = transform(proc.stdOut().split('\0', Qt::SkipEmptyParts),
[&wd](const QString &fp) { return wd.absoluteFilePath(fp); }); [&wd](const QString &fp) { return wd.absoluteFilePath(fp); });
res += filtered(it.value(), [&managedFilePaths, &wd](const QString &fp) { const QStringList filtered = Utils::filtered(it.value(), [&managedFilePaths, &wd](const QString &fp) {
return !managedFilePaths.contains(wd.absoluteFilePath(fp)); return !managedFilePaths.contains(wd.absoluteFilePath(fp));
}); });
res += transform(filtered, &FilePath::fromString);
} }
return res; return res;
} }

View File

@@ -153,7 +153,7 @@ public:
QString findRepositoryForDirectory(const QString &directory) const; QString findRepositoryForDirectory(const QString &directory) const;
QString findGitDirForRepository(const QString &repositoryDir) const; QString findGitDirForRepository(const QString &repositoryDir) const;
bool managesFile(const QString &workingDirectory, const QString &fileName) const; bool managesFile(const QString &workingDirectory, const QString &fileName) const;
QStringList unmanagedFiles(const QStringList &filePaths) const; Utils::FilePaths unmanagedFiles(const Utils::FilePaths &filePaths) const;
void diffFile(const QString &workingDirectory, const QString &fileName) const; void diffFile(const QString &workingDirectory, const QString &fileName) const;
void diffFiles(const QString &workingDirectory, void diffFiles(const QString &workingDirectory,

View File

@@ -59,6 +59,8 @@
#include <aggregation/aggregate.h> #include <aggregation/aggregate.h>
#include <texteditor/texteditor.h> #include <texteditor/texteditor.h>
#include <utils/algorithm.h>
#include <utils/infobar.h> #include <utils/infobar.h>
#include <utils/parameteraction.h> #include <utils/parameteraction.h>
#include <utils/pathchooser.h> #include <utils/pathchooser.h>
@@ -112,15 +114,15 @@ public:
{ } { }
protected: protected:
QString trackFile(const QString &repository) override FilePath trackFile(const FilePath &repository) override
{ {
const QString gitDir = m_client->findGitDirForRepository(repository); const QString gitDir = m_client->findGitDirForRepository(repository.toString());
return gitDir.isEmpty() ? QString() : (gitDir + "/HEAD"); return gitDir.isEmpty() ? FilePath() : FilePath::fromString(gitDir + "/HEAD");
} }
QString refreshTopic(const QString &repository) override QString refreshTopic(const FilePath &repository) override
{ {
return m_client->synchronousTopic(repository); return m_client->synchronousTopic(repository.toString());
} }
private: private:
@@ -234,23 +236,23 @@ public:
QString displayName() const final; QString displayName() const final;
Utils::Id id() const final; Utils::Id id() const final;
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final; bool isVcsFileOrDirectory(const FilePath &filePath) const final;
bool managesDirectory(const QString &directory, QString *topLevel) const final; bool managesDirectory(const FilePath &directory, FilePath *topLevel) const final;
bool managesFile(const QString &workingDirectory, const QString &fileName) const final; bool managesFile(const FilePath &workingDirectory, const QString &fileName) const final;
QStringList unmanagedFiles(const QStringList &filePaths) const final; FilePaths unmanagedFiles(const FilePaths &filePaths) const final;
bool isConfigured() const final; bool isConfigured() const final;
bool supportsOperation(Operation operation) const final; bool supportsOperation(Operation operation) const final;
bool vcsOpen(const QString &fileName) final; bool vcsOpen(const FilePath &fileName) final;
bool vcsAdd(const QString &fileName) final; bool vcsAdd(const FilePath &fileName) final;
bool vcsDelete(const QString &filename) final; bool vcsDelete(const FilePath &filename) final;
bool vcsMove(const QString &from, const QString &to) final; bool vcsMove(const FilePath &from, const FilePath &to) final;
bool vcsCreateRepository(const QString &directory) final; bool vcsCreateRepository(const FilePath &directory) final;
void vcsAnnotate(const QString &file, int line) final; void vcsAnnotate(const FilePath &file, int line) final;
void vcsDescribe(const QString &source, const QString &id) final { m_gitClient.show(source, id); }; void vcsDescribe(const FilePath &source, const QString &id) final { m_gitClient.show(source.toString(), id); };
QString vcsTopic(const QString &directory) final; QString vcsTopic(const FilePath &directory) final;
Core::ShellCommand *createInitialCheckoutCommand(const QString &url, Core::ShellCommand *createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory, const Utils::FilePath &baseDirectory,
@@ -258,7 +260,7 @@ public:
const QStringList &extraArgs) final; const QStringList &extraArgs) final;
void fillLinkContextMenu(QMenu *menu, void fillLinkContextMenu(QMenu *menu,
const QString &workingDirectory, const FilePath &workingDirectory,
const QString &reference) final const QString &reference) final
{ {
menu->addAction(tr("&Copy \"%1\"").arg(reference), menu->addAction(tr("&Copy \"%1\"").arg(reference),
@@ -266,15 +268,15 @@ public:
QAction *action = menu->addAction(tr("&Describe Change %1").arg(reference), QAction *action = menu->addAction(tr("&Describe Change %1").arg(reference),
[=] { vcsDescribe(workingDirectory, reference); }); [=] { vcsDescribe(workingDirectory, reference); });
menu->setDefaultAction(action); menu->setDefaultAction(action);
GitClient::addChangeActions(menu, workingDirectory, reference); GitClient::addChangeActions(menu, workingDirectory.toString(), reference);
} }
bool handleLink(const QString &workingDirectory, const QString &reference) final bool handleLink(const FilePath &workingDirectory, const QString &reference) final
{ {
if (reference.contains("..")) if (reference.contains(".."))
GitClient::instance()->log(workingDirectory, {}, false, {reference}); GitClient::instance()->log(workingDirectory.toString(), {}, false, {reference});
else else
GitClient::instance()->show(workingDirectory, reference); GitClient::instance()->show(workingDirectory.toString(), reference);
return true; return true;
} }
@@ -1836,13 +1838,13 @@ Utils::Id GitPluginPrivate::id() const
return Utils::Id(VcsBase::Constants::VCS_ID_GIT); return Utils::Id(VcsBase::Constants::VCS_ID_GIT);
} }
bool GitPluginPrivate::isVcsFileOrDirectory(const Utils::FilePath &fileName) const bool GitPluginPrivate::isVcsFileOrDirectory(const FilePath &filePath) const
{ {
if (fileName.fileName().compare(".git", Utils::HostOsInfo::fileNameCaseSensitivity())) if (filePath.fileName().compare(".git", Utils::HostOsInfo::fileNameCaseSensitivity()))
return false; return false;
if (fileName.isDir()) if (filePath.isDir())
return true; return true;
QFile file(fileName.toString()); QFile file(filePath.toString());
if (!file.open(QFile::ReadOnly)) if (!file.open(QFile::ReadOnly))
return false; return false;
return file.read(8) == "gitdir: "; return file.read(8) == "gitdir: ";
@@ -1871,39 +1873,39 @@ bool GitPluginPrivate::supportsOperation(Operation operation) const
return false; return false;
} }
bool GitPluginPrivate::vcsOpen(const QString & /*fileName*/) bool GitPluginPrivate::vcsOpen(const FilePath & /*filePath*/)
{ {
return false; return false;
} }
bool GitPluginPrivate::vcsAdd(const QString &fileName) bool GitPluginPrivate::vcsAdd(const FilePath &filePath)
{ {
const QFileInfo fi(fileName); const QFileInfo fi = filePath.toFileInfo();
return m_gitClient.synchronousAdd(fi.absolutePath(), {fi.fileName()}, {"--intent-to-add"}); return m_gitClient.synchronousAdd(fi.absolutePath(), {fi.fileName()}, {"--intent-to-add"});
} }
bool GitPluginPrivate::vcsDelete(const QString &fileName) bool GitPluginPrivate::vcsDelete(const FilePath &filePath)
{ {
const QFileInfo fi(fileName); const QFileInfo fi = filePath.toFileInfo();
return m_gitClient.synchronousDelete(fi.absolutePath(), true, {fi.fileName()}); return m_gitClient.synchronousDelete(fi.absolutePath(), true, {fi.fileName()});
} }
bool GitPluginPrivate::vcsMove(const QString &from, const QString &to) bool GitPluginPrivate::vcsMove(const FilePath &from, const FilePath &to)
{ {
const QFileInfo fromInfo(from); const QFileInfo fromInfo = from.toFileInfo();
const QFileInfo toInfo(to); const QFileInfo toInfo = to.toFileInfo();
return m_gitClient.synchronousMove(fromInfo.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath()); return m_gitClient.synchronousMove(fromInfo.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath());
} }
bool GitPluginPrivate::vcsCreateRepository(const QString &directory) bool GitPluginPrivate::vcsCreateRepository(const FilePath &directory)
{ {
return m_gitClient.synchronousInit(directory); return m_gitClient.synchronousInit(directory.toString());
} }
QString GitPluginPrivate::vcsTopic(const QString &directory) QString GitPluginPrivate::vcsTopic(const FilePath &directory)
{ {
QString topic = Core::IVersionControl::vcsTopic(directory); QString topic = Core::IVersionControl::vcsTopic(directory);
const QString commandInProgress = m_gitClient.commandInProgressDescription(directory); const QString commandInProgress = m_gitClient.commandInProgressDescription(directory.toString());
if (!commandInProgress.isEmpty()) if (!commandInProgress.isEmpty())
topic += " (" + commandInProgress + ')'; topic += " (" + commandInProgress + ')';
return topic; return topic;
@@ -1937,27 +1939,27 @@ QStringList GitPluginPrivate::additionalToolsPath() const
return res; return res;
} }
bool GitPluginPrivate::managesDirectory(const QString &directory, QString *topLevel) const bool GitPluginPrivate::managesDirectory(const FilePath &directory, FilePath *topLevel) const
{ {
const QString topLevelFound = m_gitClient.findRepositoryForDirectory(directory); const QString topLevelFound = m_gitClient.findRepositoryForDirectory(directory.toString());
if (topLevel) if (topLevel)
*topLevel = topLevelFound; *topLevel = FilePath::fromString(topLevelFound);
return !topLevelFound.isEmpty(); return !topLevelFound.isEmpty();
} }
bool GitPluginPrivate::managesFile(const QString &workingDirectory, const QString &fileName) const bool GitPluginPrivate::managesFile(const FilePath &workingDirectory, const QString &fileName) const
{ {
return m_gitClient.managesFile(workingDirectory, fileName); return m_gitClient.managesFile(workingDirectory.toString(), fileName);
} }
QStringList GitPluginPrivate::unmanagedFiles(const QStringList &filePaths) const FilePaths GitPluginPrivate::unmanagedFiles(const FilePaths &filePaths) const
{ {
return m_gitClient.unmanagedFiles(filePaths); return m_gitClient.unmanagedFiles(filePaths);
} }
void GitPluginPrivate::vcsAnnotate(const QString &file, int line) void GitPluginPrivate::vcsAnnotate(const FilePath &filePath, int line)
{ {
const QFileInfo fi(file); const QFileInfo fi = filePath.toFileInfo();
m_gitClient.annotate(fi.absolutePath(), fi.fileName(), QString(), line); m_gitClient.annotate(fi.absolutePath(), fi.fileName(), QString(), line);
} }

View File

@@ -80,14 +80,14 @@ public:
MercurialTopicCache(MercurialClient *client) : m_client(client) {} MercurialTopicCache(MercurialClient *client) : m_client(client) {}
protected: protected:
QString trackFile(const QString &repository) override FilePath trackFile(const FilePath &repository) override
{ {
return repository + QLatin1String("/.hg/branch"); return repository.pathAppended(".hg/branch");
} }
QString refreshTopic(const QString &repository) override QString refreshTopic(const FilePath &repository) override
{ {
return m_client->branchQuerySync(repository); return m_client->branchQuerySync(repository.toString());
} }
private: private:
@@ -132,19 +132,19 @@ public:
// IVersionControl // IVersionControl
QString displayName() const final; QString displayName() const final;
Utils::Id id() const final; Utils::Id id() const final;
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final; bool isVcsFileOrDirectory(const FilePath &filePath) const final;
bool managesDirectory(const QString &filename, QString *topLevel = nullptr) const final; bool managesDirectory(const FilePath &filePath, FilePath *topLevel = nullptr) const final;
bool managesFile(const QString &workingDirectory, const QString &fileName) const final; bool managesFile(const FilePath &workingDirectory, const QString &fileName) const final;
bool isConfigured() const final; bool isConfigured() const final;
bool supportsOperation(Operation operation) const final; bool supportsOperation(Operation operation) const final;
bool vcsOpen(const QString &fileName) final; bool vcsOpen(const FilePath &filePath) final;
bool vcsAdd(const QString &filename) final; bool vcsAdd(const FilePath &filePath) final;
bool vcsDelete(const QString &filename) final; bool vcsDelete(const FilePath &filePath) final;
bool vcsMove(const QString &from, const QString &to) final; bool vcsMove(const FilePath &from, const FilePath &to) final;
bool vcsCreateRepository(const QString &directory) final; bool vcsCreateRepository(const FilePath &directory) final;
void vcsAnnotate(const QString &file, int line) final; void vcsAnnotate(const FilePath &filePath, int line) final;
void vcsDescribe(const QString &source, const QString &id) final { m_client.view(source, id); } void vcsDescribe(const FilePath &source, const QString &id) final { m_client.view(source.toString(), id); }
Core::ShellCommand *createInitialCheckoutCommand(const QString &url, Core::ShellCommand *createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory, const Utils::FilePath &baseDirectory,
@@ -661,7 +661,7 @@ void MercurialPluginPrivate::showCommitWidget(const QList<VcsBaseClient::StatusI
arg(QDir::toNativeSeparators(m_submitRepository)); arg(QDir::toNativeSeparators(m_submitRepository));
commitEditor->document()->setPreferredDisplayName(msg); commitEditor->document()->setPreferredDisplayName(msg);
const QString branch = vcsTopic(m_submitRepository); const QString branch = vcsTopic(FilePath::fromString(m_submitRepository));
commitEditor->setFields(QFileInfo(m_submitRepository), branch, commitEditor->setFields(QFileInfo(m_submitRepository), branch,
m_settings.userName.value(), m_settings.userName.value(),
m_settings.userEmail.value(), status); m_settings.userEmail.value(), status);
@@ -747,23 +747,23 @@ Utils::Id MercurialPluginPrivate::id() const
return {VcsBase::Constants::VCS_ID_MERCURIAL}; return {VcsBase::Constants::VCS_ID_MERCURIAL};
} }
bool MercurialPluginPrivate::isVcsFileOrDirectory(const Utils::FilePath &fileName) const bool MercurialPluginPrivate::isVcsFileOrDirectory(const FilePath &filePath) const
{ {
return m_client.isVcsDirectory(fileName); return m_client.isVcsDirectory(filePath);
} }
bool MercurialPluginPrivate::managesDirectory(const QString &directory, QString *topLevel) const bool MercurialPluginPrivate::managesDirectory(const FilePath &filePath, FilePath *topLevel) const
{ {
QFileInfo dir(directory); QFileInfo dir = filePath.toFileInfo();
const QString topLevelFound = m_client.findTopLevelForFile(dir); const QString topLevelFound = m_client.findTopLevelForFile(dir);
if (topLevel) if (topLevel)
*topLevel = topLevelFound; *topLevel = FilePath::fromString(topLevelFound);
return !topLevelFound.isEmpty(); return !topLevelFound.isEmpty();
} }
bool MercurialPluginPrivate::managesFile(const QString &workingDirectory, const QString &fileName) const bool MercurialPluginPrivate::managesFile(const FilePath &workingDirectory, const QString &fileName) const
{ {
return m_client.managesFile(workingDirectory, fileName); return m_client.managesFile(workingDirectory.toString(), fileName);
} }
bool MercurialPluginPrivate::isConfigured() const bool MercurialPluginPrivate::isConfigured() const
@@ -793,41 +793,41 @@ bool MercurialPluginPrivate::supportsOperation(Operation operation) const
return supported; return supported;
} }
bool MercurialPluginPrivate::vcsOpen(const QString &filename) bool MercurialPluginPrivate::vcsOpen(const FilePath &filePath)
{ {
Q_UNUSED(filename) Q_UNUSED(filePath)
return true; return true;
} }
bool MercurialPluginPrivate::vcsAdd(const QString &filename) bool MercurialPluginPrivate::vcsAdd(const FilePath &filePath)
{ {
const QFileInfo fi(filename); const QFileInfo fi = filePath.toFileInfo();
return m_client.synchronousAdd(fi.absolutePath(), fi.fileName()); return m_client.synchronousAdd(fi.absolutePath(), fi.fileName());
} }
bool MercurialPluginPrivate::vcsDelete(const QString &filename) bool MercurialPluginPrivate::vcsDelete(const FilePath &filePath)
{ {
const QFileInfo fi(filename); const QFileInfo fi = filePath.toFileInfo();
return m_client.synchronousRemove(fi.absolutePath(), fi.fileName()); return m_client.synchronousRemove(fi.absolutePath(), fi.fileName());
} }
bool MercurialPluginPrivate::vcsMove(const QString &from, const QString &to) bool MercurialPluginPrivate::vcsMove(const FilePath &from, const FilePath &to)
{ {
const QFileInfo fromInfo(from); const QFileInfo fromInfo = from.toFileInfo();
const QFileInfo toInfo(to); const QFileInfo toInfo = to.toFileInfo();
return m_client.synchronousMove(fromInfo.absolutePath(), return m_client.synchronousMove(fromInfo.absolutePath(),
fromInfo.absoluteFilePath(), fromInfo.absoluteFilePath(),
toInfo.absoluteFilePath()); toInfo.absoluteFilePath());
} }
bool MercurialPluginPrivate::vcsCreateRepository(const QString &directory) bool MercurialPluginPrivate::vcsCreateRepository(const FilePath &directory)
{ {
return m_client.synchronousCreateRepository(directory); return m_client.synchronousCreateRepository(directory.toString());
} }
void MercurialPluginPrivate::vcsAnnotate(const QString &file, int line) void MercurialPluginPrivate::vcsAnnotate(const FilePath &filePath, int line)
{ {
const QFileInfo fi(file); const QFileInfo fi = filePath.toFileInfo();
m_client.annotate(fi.absolutePath(), fi.fileName(), QString(), line); m_client.annotate(fi.absolutePath(), fi.fileName(), QString(), line);
} }
@@ -847,12 +847,12 @@ Core::ShellCommand *MercurialPluginPrivate::createInitialCheckoutCommand(const Q
bool MercurialPluginPrivate::sccManaged(const QString &filename) bool MercurialPluginPrivate::sccManaged(const QString &filename)
{ {
const QFileInfo fi(filename); const QFileInfo fi(filename);
QString topLevel; FilePath topLevel;
const bool managed = managesDirectory(fi.absolutePath(), &topLevel); const bool managed = managesDirectory(FilePath::fromString(fi.absolutePath()), &topLevel);
if (!managed || topLevel.isEmpty()) if (!managed || topLevel.isEmpty())
return false; return false;
const QDir topLevelDir(topLevel); const QDir topLevelDir(topLevel.toString());
return m_client.manifestSync(topLevel, topLevelDir.relativeFilePath(filename)); return m_client.manifestSync(topLevel.toString(), topLevelDir.relativeFilePath(filename));
} }
void MercurialPluginPrivate::changed(const QVariant &v) void MercurialPluginPrivate::changed(const QVariant &v)

View File

@@ -212,20 +212,20 @@ public:
Id id() const final { return VcsBase::Constants::VCS_ID_PERFORCE; } Id id() const final { return VcsBase::Constants::VCS_ID_PERFORCE; }
bool isVcsFileOrDirectory(const FilePath &fileName) const final; bool isVcsFileOrDirectory(const FilePath &fileName) const final;
bool managesDirectory(const QString &directory, QString *topLevel = nullptr) const final; bool managesDirectory(const Utils::FilePath &directory, Utils::FilePath *topLevel = nullptr) const final;
bool managesFile(const QString &workingDirectory, const QString &fileName) const final; bool managesFile(const Utils::FilePath &workingDirectory, const QString &fileName) const final;
bool isConfigured() const final; bool isConfigured() const final;
bool supportsOperation(Operation operation) const final; bool supportsOperation(Operation operation) const final;
OpenSupportMode openSupportMode(const QString &fileName) const final; OpenSupportMode openSupportMode(const Utils::FilePath &filePath) const final;
bool vcsOpen(const QString &fileName) final; bool vcsOpen(const Utils::FilePath &filePath) final;
SettingsFlags settingsFlags() const final; SettingsFlags settingsFlags() const final;
bool vcsAdd(const QString &fileName) final; bool vcsAdd(const Utils::FilePath &filePath) final;
bool vcsDelete(const QString &filename) final; bool vcsDelete(const Utils::FilePath &filePath) final;
bool vcsMove(const QString &from, const QString &to) final; bool vcsMove(const Utils::FilePath &from, const Utils::FilePath &to) final;
bool vcsCreateRepository(const QString &directory) final; bool vcsCreateRepository(const Utils::FilePath &directory) final;
void vcsAnnotate(const QString &file, int line) final; void vcsAnnotate(const Utils::FilePath &filePath, int line) final;
void vcsDescribe(const QString &source, const QString &n) final; void vcsDescribe(const Utils::FilePath &source, const QString &n) final;
QString vcsOpenText() const final; QString vcsOpenText() const final;
QString vcsMakeWritableText() const final; QString vcsMakeWritableText() const final;
@@ -831,7 +831,7 @@ void PerforcePluginPrivate::describeChange()
{ {
ChangeNumberDialog dia; ChangeNumberDialog dia;
if (dia.exec() == QDialog::Accepted && dia.number() > 0) if (dia.exec() == QDialog::Accepted && dia.number() > 0)
vcsDescribe(QString(), QString::number(dia.number())); vcsDescribe(FilePath(), QString::number(dia.number()));
} }
void PerforcePluginPrivate::annotateCurrentFile() void PerforcePluginPrivate::annotateCurrentFile()
@@ -978,23 +978,23 @@ void PerforcePluginPrivate::updateActions(VcsBasePluginPrivate::ActionState as)
m_revertUnchangedAction->setParameter(projectName); m_revertUnchangedAction->setParameter(projectName);
} }
bool PerforcePluginPrivate::managesDirectory(const QString &directory, QString *topLevel /* = 0 */) const bool PerforcePluginPrivate::managesDirectory(const FilePath &directory, FilePath *topLevel /* = 0 */) const
{ {
const bool rc = const_cast<PerforcePluginPrivate *>(this)->managesDirectoryFstat(directory); const bool rc = const_cast<PerforcePluginPrivate *>(this)->managesDirectoryFstat(directory.toString());
if (topLevel) { if (topLevel) {
if (rc) if (rc)
*topLevel = m_settings.topLevelSymLinkTarget(); *topLevel = FilePath::fromString(m_settings.topLevelSymLinkTarget());
else else
topLevel->clear(); topLevel->clear();
} }
return rc; return rc;
} }
bool PerforcePluginPrivate::managesFile(const QString &workingDirectory, const QString &fileName) const bool PerforcePluginPrivate::managesFile(const FilePath &workingDirectory, const QString &fileName) const
{ {
QStringList args; QStringList args;
args << QLatin1String("fstat") << QLatin1String("-m1") << fileName; args << QLatin1String("fstat") << QLatin1String("-m1") << fileName;
const PerforceResponse result = runP4Cmd(workingDirectory, args, RunFullySynchronous); const PerforceResponse result = runP4Cmd(workingDirectory.toString(), args, RunFullySynchronous);
return result.stdOut.contains(QLatin1String("depotFile")); return result.stdOut.contains(QLatin1String("depotFile"));
} }
@@ -1126,9 +1126,9 @@ PerforcePluginPrivate::createTemporaryArgumentFile(const QStringList &extraArgs,
return rc; return rc;
} }
bool PerforcePluginPrivate::isVcsFileOrDirectory(const FilePath &fileName) const bool PerforcePluginPrivate::isVcsFileOrDirectory(const FilePath &FilePath) const
{ {
Q_UNUSED(fileName) Q_UNUSED(FilePath)
return false; // Perforce does not seem to litter its files into the source tree. return false; // Perforce does not seem to litter its files into the source tree.
} }
@@ -1158,15 +1158,15 @@ bool PerforcePluginPrivate::supportsOperation(Operation operation) const
return false; return false;
} }
IVersionControl::OpenSupportMode PerforcePluginPrivate::openSupportMode(const QString &fileName) const IVersionControl::OpenSupportMode PerforcePluginPrivate::openSupportMode(const FilePath &filePath) const
{ {
Q_UNUSED(fileName) Q_UNUSED(filePath)
return OpenOptional; return OpenOptional;
} }
bool PerforcePluginPrivate::vcsOpen(const QString &fileName) bool PerforcePluginPrivate::vcsOpen(const FilePath &filePath)
{ {
const QFileInfo fi(fileName); const QFileInfo fi = filePath.toFileInfo();
return vcsOpen(fi.absolutePath(), fi.fileName(), true); return vcsOpen(fi.absolutePath(), fi.fileName(), true);
} }
@@ -1178,33 +1178,33 @@ IVersionControl::SettingsFlags PerforcePluginPrivate::settingsFlags() const
return rc; return rc;
} }
bool PerforcePluginPrivate::vcsAdd(const QString &fileName) bool PerforcePluginPrivate::vcsAdd(const FilePath &filePath)
{ {
const QFileInfo fi(fileName); const QFileInfo fi = filePath.toFileInfo();
return vcsAdd(fi.absolutePath(), fi.fileName()); return vcsAdd(fi.absolutePath(), fi.fileName());
} }
bool PerforcePluginPrivate::vcsDelete(const QString &fileName) bool PerforcePluginPrivate::vcsDelete(const FilePath &filePath)
{ {
const QFileInfo fi(fileName); const QFileInfo fi = filePath.toFileInfo();
return vcsDelete(fi.absolutePath(), fi.fileName()); return vcsDelete(fi.absolutePath(), fi.fileName());
} }
bool PerforcePluginPrivate::vcsMove(const QString &from, const QString &to) bool PerforcePluginPrivate::vcsMove(const FilePath &from, const FilePath &to)
{ {
const QFileInfo fromInfo(from); const QFileInfo fromInfo = from.toFileInfo();
const QFileInfo toInfo(to); const QFileInfo toInfo = to.toFileInfo();
return vcsMove(fromInfo.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath()); return vcsMove(fromInfo.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath());
} }
bool PerforcePluginPrivate::vcsCreateRepository(const QString &) bool PerforcePluginPrivate::vcsCreateRepository(const FilePath &)
{ {
return false; return false;
} }
void PerforcePluginPrivate::vcsAnnotate(const QString &file, int line) void PerforcePluginPrivate::vcsAnnotate(const FilePath &filePath, int line)
{ {
const QFileInfo fi(file); const QFileInfo fi = filePath.toFileInfo();
annotate(fi.absolutePath(), fi.fileName(), QString(), line); annotate(fi.absolutePath(), fi.fileName(), QString(), line);
} }
@@ -1537,16 +1537,16 @@ void PerforcePluginPrivate::p4Diff(const PerforceDiffParameters &p)
diffEditorWidget->setEditorConfig(pw); diffEditorWidget->setEditorConfig(pw);
} }
void PerforcePluginPrivate::vcsDescribe(const QString & source, const QString &n) void PerforcePluginPrivate::vcsDescribe(const FilePath &source, const QString &n)
{ {
QTextCodec *codec = source.isEmpty() ? static_cast<QTextCodec *>(nullptr) QTextCodec *codec = source.isEmpty() ? static_cast<QTextCodec *>(nullptr)
: VcsBaseEditor::getCodec(source); : VcsBaseEditor::getCodec(source.toString());
QStringList args; QStringList args;
args << QLatin1String("describe") << QLatin1String("-du") << n; args << QLatin1String("describe") << QLatin1String("-du") << n;
const PerforceResponse result = runP4Cmd(m_settings.topLevel(), args, CommandToWindow|StdErrToWindow|ErrorToWindow, const PerforceResponse result = runP4Cmd(m_settings.topLevel(), args, CommandToWindow|StdErrToWindow|ErrorToWindow,
QStringList(), QByteArray(), codec); QStringList(), QByteArray(), codec);
if (!result.error) if (!result.error)
showOutputInEditor(tr("p4 describe %1").arg(n), result.stdOut, diffEditorParameters.id, source, codec); showOutputInEditor(tr("p4 describe %1").arg(n), result.stdOut, diffEditorParameters.id, source.toString(), codec);
} }
void PerforcePluginPrivate::commitFromEditor() void PerforcePluginPrivate::commitFromEditor()

View File

@@ -3868,7 +3868,7 @@ void ProjectExplorerPluginPrivate::deleteFile()
FileChangeBlocker changeGuard(currentNode->filePath()); FileChangeBlocker changeGuard(currentNode->filePath());
if (IVersionControl *vc = if (IVersionControl *vc =
VcsManager::findVersionControlForDirectory(filePath.absolutePath().toString())) { VcsManager::findVersionControlForDirectory(filePath.absolutePath().toString())) {
vc->vcsDelete(filePath.toString()); vc->vcsDelete(filePath);
} }
if (filePath.exists()) { if (filePath.exists()) {
if (!filePath.removeFile()) if (!filePath.removeFile())

View File

@@ -757,7 +757,7 @@ bool FlatModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int r
const FilePath targetFile = targetFilePath(sourceFile); const FilePath targetFile = targetFilePath(sourceFile);
if (sourceFile.copyFile(targetFile)) { if (sourceFile.copyFile(targetFile)) {
filesToAdd << targetFile; filesToAdd << targetFile;
if (addToVcs && !vcs->vcsAdd(targetFile.toString())) if (addToVcs && !vcs->vcsAdd(targetFile))
failedVcsOp << targetFile; failedVcsOp << targetFile;
} else { } else {
failedCopyOrMove << sourceFile; failedCopyOrMove << sourceFile;
@@ -780,7 +780,7 @@ bool FlatModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int r
const VcsInfo sourceVcs = vcsInfoForFile(sourceFile.toString()); const VcsInfo sourceVcs = vcsInfoForFile(sourceFile.toString());
if (sourceVcs.vcs && targetVcs.vcs && sourceVcs == targetVcs if (sourceVcs.vcs && targetVcs.vcs && sourceVcs == targetVcs
&& sourceVcs.vcs->supportsOperation(Core::IVersionControl::MoveOperation)) { && sourceVcs.vcs->supportsOperation(Core::IVersionControl::MoveOperation)) {
if (sourceVcs.vcs->vcsMove(sourceFile.toString(), targetFile.toString())) { if (sourceVcs.vcs->vcsMove(sourceFile, targetFile)) {
filesToAdd << targetFile; filesToAdd << targetFile;
filesToRemove << sourceFile; filesToRemove << sourceFile;
} else { } else {
@@ -797,12 +797,12 @@ bool FlatModel::dropMimeData(const QMimeData *data, Qt::DropAction action, int r
Core::FileChangeBlocker changeGuard(sourceFile); Core::FileChangeBlocker changeGuard(sourceFile);
if (sourceVcs.vcs && sourceVcs.vcs->supportsOperation( if (sourceVcs.vcs && sourceVcs.vcs->supportsOperation(
Core::IVersionControl::DeleteOperation) Core::IVersionControl::DeleteOperation)
&& !sourceVcs.vcs->vcsDelete(sourceFile.toString())) { && !sourceVcs.vcs->vcsDelete(sourceFile)) {
failedVcsOp << sourceFile; failedVcsOp << sourceFile;
} }
if (sourceFile.exists() && !sourceFile.removeFile()) if (sourceFile.exists() && !sourceFile.removeFile())
failedDelete << sourceFile; failedDelete << sourceFile;
if (vcsAddPossible && !targetVcs.vcs->vcsAdd(targetFile.toString())) if (vcsAddPossible && !targetVcs.vcs->vcsAdd(targetFile))
failedVcsOp << targetFile; failedVcsOp << targetFile;
} }
const RemovedFilesFromProject result const RemovedFilesFromProject result

View File

@@ -1003,7 +1003,7 @@ QString ContainerNode::displayName() const
const QFileInfo fi = m_project->projectFilePath().toFileInfo(); const QFileInfo fi = m_project->projectFilePath().toFileInfo();
const QString dir = fi.isDir() ? fi.absoluteFilePath() : fi.absolutePath(); const QString dir = fi.isDir() ? fi.absoluteFilePath() : fi.absolutePath();
if (Core::IVersionControl *vc = Core::VcsManager::findVersionControlForDirectory(dir)) { if (Core::IVersionControl *vc = Core::VcsManager::findVersionControlForDirectory(dir)) {
QString vcsTopic = vc->vcsTopic(dir); QString vcsTopic = vc->vcsTopic(FilePath::fromString(dir));
if (!vcsTopic.isEmpty()) if (!vcsTopic.isEmpty())
name += " [" + vcsTopic + ']'; name += " [" + vcsTopic + ']';
} }

View File

@@ -418,7 +418,7 @@ bool ProjectWizardPage::runVersionControl(const QList<GeneratedFile> &files, QSt
// Create repository? // Create repository?
if (!m_repositoryExists) { if (!m_repositoryExists) {
QTC_ASSERT(versionControl->supportsOperation(IVersionControl::CreateRepositoryOperation), return false); QTC_ASSERT(versionControl->supportsOperation(IVersionControl::CreateRepositoryOperation), return false);
if (!versionControl->vcsCreateRepository(m_commonDirectory)) { if (!versionControl->vcsCreateRepository(FilePath::fromString(m_commonDirectory))) {
*errorMessage = tr("A version control system repository could not be created in \"%1\".").arg(m_commonDirectory); *errorMessage = tr("A version control system repository could not be created in \"%1\".").arg(m_commonDirectory);
return false; return false;
} }
@@ -426,7 +426,7 @@ bool ProjectWizardPage::runVersionControl(const QList<GeneratedFile> &files, QSt
// Add files if supported. // Add files if supported.
if (versionControl->supportsOperation(IVersionControl::AddOperation)) { if (versionControl->supportsOperation(IVersionControl::AddOperation)) {
foreach (const GeneratedFile &generatedFile, files) { foreach (const GeneratedFile &generatedFile, files) {
if (!versionControl->vcsAdd(generatedFile.path())) { if (!versionControl->vcsAdd(generatedFile.filePath())) {
*errorMessage = tr("Failed to add \"%1\" to the version control system.").arg(generatedFile.path()); *errorMessage = tr("Failed to add \"%1\" to the version control system.").arg(generatedFile.path());
return false; return false;
} }

View File

@@ -35,6 +35,7 @@
#include <QFileInfo> #include <QFileInfo>
using namespace Core; using namespace Core;
using namespace Utils;
namespace ProjectExplorer { namespace ProjectExplorer {
namespace Internal { namespace Internal {
@@ -56,7 +57,7 @@ void VcsAnnotateTaskHandler::handle(const Task &task)
IVersionControl *vc = VcsManager::findVersionControlForDirectory(fi.absolutePath()); IVersionControl *vc = VcsManager::findVersionControlForDirectory(fi.absolutePath());
QTC_ASSERT(vc, return); QTC_ASSERT(vc, return);
QTC_ASSERT(vc->supportsOperation(IVersionControl::AnnotateOperation), return); QTC_ASSERT(vc->supportsOperation(IVersionControl::AnnotateOperation), return);
vc->vcsAnnotate(fi.absoluteFilePath(), task.movedLine); vc->vcsAnnotate(FilePath::fromString(fi.absoluteFilePath()), task.movedLine);
} }
QAction *VcsAnnotateTaskHandler::createAction(QObject *parent) const QAction *VcsAnnotateTaskHandler::createAction(QObject *parent) const

View File

@@ -353,7 +353,7 @@ bool QbsBuildSystem::ensureWriteableQbsFile(const QString &file)
// Try via vcs manager // Try via vcs manager
IVersionControl *versionControl = IVersionControl *versionControl =
VcsManager::findVersionControlForDirectory(fi.absolutePath()); VcsManager::findVersionControlForDirectory(fi.absolutePath());
if (!versionControl || !versionControl->vcsOpen(file)) { if (!versionControl || !versionControl->vcsOpen(FilePath::fromString(file))) {
bool makeWritable = QFile::setPermissions(file, fi.permissions() | QFile::WriteUser); bool makeWritable = QFile::setPermissions(file, fi.permissions() | QFile::WriteUser);
if (!makeWritable) { if (!makeWritable) {
QMessageBox::warning(ICore::dialogParent(), QMessageBox::warning(ICore::dialogParent(),

View File

@@ -746,7 +746,7 @@ bool QmakePriFile::ensureWriteableProFile(const QString &file)
if (!fi.isWritable()) { if (!fi.isWritable()) {
// Try via vcs manager // Try via vcs manager
Core::IVersionControl *versionControl = Core::VcsManager::findVersionControlForDirectory(fi.absolutePath()); Core::IVersionControl *versionControl = Core::VcsManager::findVersionControlForDirectory(fi.absolutePath());
if (!versionControl || !versionControl->vcsOpen(file)) { if (!versionControl || !versionControl->vcsOpen(FilePath::fromString(file))) {
bool makeWritable = QFile::setPermissions(file, fi.permissions() | QFile::WriteUser); bool makeWritable = QFile::setPermissions(file, fi.permissions() | QFile::WriteUser);
if (!makeWritable) { if (!makeWritable) {
QMessageBox::warning(Core::ICore::dialogParent(), QMessageBox::warning(Core::ICore::dialogParent(),

View File

@@ -52,6 +52,8 @@
#include <QMessageBox> #include <QMessageBox>
using namespace Utils;
namespace QmlDesigner { namespace QmlDesigner {
Q_LOGGING_CATEGORY(documentManagerLog, "qtc.qtquickdesigner.documentmanager", QtWarningMsg) Q_LOGGING_CATEGORY(documentManagerLog, "qtc.qtquickdesigner.documentmanager", QtWarningMsg)
@@ -315,7 +317,7 @@ void DocumentManager::addFileToVersionControl(const QString &directoryPath, cons
Core::VcsManager::msgPromptToAddToVcs(QStringList(newFilePath), Core::VcsManager::msgPromptToAddToVcs(QStringList(newFilePath),
versionControl), versionControl),
QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);
if (button == QMessageBox::Yes && !versionControl->vcsAdd(newFilePath)) { if (button == QMessageBox::Yes && !versionControl->vcsAdd(FilePath::fromString(newFilePath))) {
Core::AsynchronousMessageBox::warning(Core::VcsManager::msgAddToVcsFailedTitle(), Core::AsynchronousMessageBox::warning(Core::VcsManager::msgAddToVcsFailedTitle(),
Core::VcsManager::msgToAddToVcsFailed(QStringList(newFilePath), versionControl)); Core::VcsManager::msgToAddToVcsFailed(QStringList(newFilePath), versionControl));
} }

View File

@@ -224,7 +224,7 @@ public:
Core::VcsManager::msgAddToVcsTitle(), Core::VcsManager::msgAddToVcsTitle(),
Core::VcsManager::msgPromptToAddToVcs(QStringList(newFileName), versionControl), Core::VcsManager::msgPromptToAddToVcs(QStringList(newFileName), versionControl),
QMessageBox::Yes | QMessageBox::No); QMessageBox::Yes | QMessageBox::No);
if (button == QMessageBox::Yes && !versionControl->vcsAdd(newFileName)) { if (button == QMessageBox::Yes && !versionControl->vcsAdd(FilePath::fromString(newFileName))) {
QMessageBox::warning(Core::ICore::dialogParent(), QMessageBox::warning(Core::ICore::dialogParent(),
Core::VcsManager::msgAddToVcsFailedTitle(), Core::VcsManager::msgAddToVcsFailedTitle(),
Core::VcsManager::msgToAddToVcsFailed(QStringList(newFileName), Core::VcsManager::msgToAddToVcsFailed(QStringList(newFileName),

View File

@@ -187,9 +187,9 @@ public:
{ } { }
protected: protected:
QString trackFile(const QString &repository) override; FilePath trackFile(const FilePath &repository) override;
QString refreshTopic(const QString &repository) override; QString refreshTopic(const FilePath &repository) override;
private: private:
SubversionPluginPrivate *m_plugin; SubversionPluginPrivate *m_plugin;
@@ -206,21 +206,21 @@ public:
// IVersionControl // IVersionControl
QString displayName() const final; QString displayName() const final;
Utils::Id id() const final; Utils::Id id() const final;
bool isVcsFileOrDirectory(const Utils::FilePath &fileName) const final; bool isVcsFileOrDirectory(const FilePath &filePath) const final;
bool managesDirectory(const QString &directory, QString *topLevel) const final; bool managesDirectory(const FilePath &directory, FilePath *topLevel) const final;
bool managesFile(const QString &workingDirectory, const QString &fileName) const final; bool managesFile(const FilePath &workingDirectory, const QString &fileName) const final;
bool isConfigured() const final; bool isConfigured() const final;
bool supportsOperation(Operation operation) const final; bool supportsOperation(Operation operation) const final;
bool vcsOpen(const QString &fileName) final; bool vcsOpen(const FilePath &filePath) final;
bool vcsAdd(const QString &fileName) final; bool vcsAdd(const FilePath &filePath) final;
bool vcsDelete(const QString &filename) final; bool vcsDelete(const FilePath &filePath) final;
bool vcsMove(const QString &from, const QString &to) final; bool vcsMove(const FilePath &from, const FilePath &to) final;
bool vcsCreateRepository(const QString &directory) final; bool vcsCreateRepository(const FilePath &directory) final;
void vcsAnnotate(const QString &file, int line) final; void vcsAnnotate(const FilePath &file, int line) final;
void vcsDescribe(const QString &source, const QString &changeNr) final; void vcsDescribe(const FilePath &source, const QString &changeNr) final;
Core::ShellCommand *createInitialCheckoutCommand(const QString &url, Core::ShellCommand *createInitialCheckoutCommand(const QString &url,
const Utils::FilePath &baseDirectory, const Utils::FilePath &baseDirectory,
@@ -967,13 +967,13 @@ void SubversionPluginPrivate::projectStatus()
svnStatus(state.currentProjectTopLevel(), state.relativeCurrentProject()); svnStatus(state.currentProjectTopLevel(), state.relativeCurrentProject());
} }
void SubversionPluginPrivate::vcsDescribe(const QString &source, const QString &changeNr) void SubversionPluginPrivate::vcsDescribe(const FilePath &source, const QString &changeNr)
{ {
// To describe a complete change, find the top level and then do // To describe a complete change, find the top level and then do
//svn diff -r 472958:472959 <top level> //svn diff -r 472958:472959 <top level>
const QFileInfo fi(source); const QFileInfo fi = source.toFileInfo();
QString topLevel; FilePath topLevel;
const bool manages = managesDirectory(fi.isDir() ? source : fi.absolutePath(), &topLevel); const bool manages = managesDirectory(fi.isDir() ? source : FilePath::fromString(fi.absolutePath()), &topLevel);
if (!manages || topLevel.isEmpty()) if (!manages || topLevel.isEmpty())
return; return;
if (Subversion::Constants::debug) if (Subversion::Constants::debug)
@@ -987,7 +987,7 @@ void SubversionPluginPrivate::vcsDescribe(const QString &source, const QString &
const QString title = QString::fromLatin1("svn describe %1#%2").arg(fi.fileName(), changeNr); const QString title = QString::fromLatin1("svn describe %1#%2").arg(fi.fileName(), changeNr);
m_client->describe(topLevel, number, title); m_client->describe(topLevel.toString(), number, title);
} }
void SubversionPluginPrivate::slotDescribe() void SubversionPluginPrivate::slotDescribe()
@@ -1004,7 +1004,7 @@ void SubversionPluginPrivate::slotDescribe()
return; return;
const int revision = inputDialog.intValue(); const int revision = inputDialog.intValue();
vcsDescribe(state.topLevel(), QString::number(revision)); vcsDescribe(FilePath::fromString(state.topLevel()), QString::number(revision));
} }
void SubversionPluginPrivate::commitFromEditor() void SubversionPluginPrivate::commitFromEditor()
@@ -1155,9 +1155,9 @@ bool SubversionPluginPrivate::vcsCheckout(const QString &directory, const QByteA
} }
bool SubversionPluginPrivate::managesDirectory(const QString &directory, QString *topLevel /* = 0 */) const bool SubversionPluginPrivate::managesDirectory(const FilePath &directory, FilePath *topLevel /* = 0 */) const
{ {
const QDir dir(directory); const QDir dir(directory.toString());
if (topLevel) if (topLevel)
topLevel->clear(); topLevel->clear();
@@ -1168,7 +1168,7 @@ bool SubversionPluginPrivate::managesDirectory(const QString &directory, QString
while (!parentDir.isRoot()) { while (!parentDir.isRoot()) {
if (checkSVNSubDir(parentDir)) { if (checkSVNSubDir(parentDir)) {
if (topLevel) if (topLevel)
*topLevel = parentDir.absolutePath(); *topLevel = FilePath::fromString(parentDir.absolutePath());
return true; return true;
} }
if (!parentDir.cdUp()) if (!parentDir.cdUp())
@@ -1178,14 +1178,14 @@ bool SubversionPluginPrivate::managesDirectory(const QString &directory, QString
return false; return false;
} }
bool SubversionPluginPrivate::managesFile(const QString &workingDirectory, const QString &fileName) const bool SubversionPluginPrivate::managesFile(const FilePath &workingDirectory, const QString &fileName) const
{ {
QStringList args; QStringList args;
args << QLatin1String("status"); args << QLatin1String("status");
args << SubversionClient::addAuthenticationOptions(m_settings) args << SubversionClient::addAuthenticationOptions(m_settings)
<< QDir::toNativeSeparators(SubversionClient::escapeFile(fileName)); << QDir::toNativeSeparators(SubversionClient::escapeFile(fileName));
SubversionResponse response SubversionResponse response
= runSvn(workingDirectory, args, m_settings.timeout.value(), 0); = runSvn(workingDirectory.toString(), args, m_settings.timeout.value(), 0);
return response.stdOut.isEmpty() || response.stdOut.at(0) != QLatin1Char('?'); return response.stdOut.isEmpty() || response.stdOut.at(0) != QLatin1Char('?');
} }
@@ -1214,9 +1214,9 @@ Utils::Id SubversionPluginPrivate::id() const
return Utils::Id(VcsBase::Constants::VCS_ID_SUBVERSION); return Utils::Id(VcsBase::Constants::VCS_ID_SUBVERSION);
} }
bool SubversionPluginPrivate::isVcsFileOrDirectory(const Utils::FilePath &fileName) const bool SubversionPluginPrivate::isVcsFileOrDirectory(const FilePath &filePath) const
{ {
return isVcsDirectory(fileName); return isVcsDirectory(filePath);
} }
bool SubversionPluginPrivate::isConfigured() const bool SubversionPluginPrivate::isConfigured() const
@@ -1246,39 +1246,39 @@ bool SubversionPluginPrivate::supportsOperation(Operation operation) const
return rc; return rc;
} }
bool SubversionPluginPrivate::vcsOpen(const QString & /* fileName */) bool SubversionPluginPrivate::vcsOpen(const FilePath & /* filePath */)
{ {
// Open for edit: N/A // Open for edit: N/A
return true; return true;
} }
bool SubversionPluginPrivate::vcsAdd(const QString &fileName) bool SubversionPluginPrivate::vcsAdd(const FilePath &filePath)
{ {
const QFileInfo fi(fileName); const QFileInfo fi = filePath.toFileInfo();
return vcsAdd(fi.absolutePath(), fi.fileName()); return vcsAdd(fi.absolutePath(), fi.fileName());
} }
bool SubversionPluginPrivate::vcsDelete(const QString &fileName) bool SubversionPluginPrivate::vcsDelete(const FilePath &filePath)
{ {
const QFileInfo fi(fileName); const QFileInfo fi = filePath.toFileInfo();
return vcsDelete(fi.absolutePath(), fi.fileName()); return vcsDelete(fi.absolutePath(), fi.fileName());
} }
bool SubversionPluginPrivate::vcsMove(const QString &from, const QString &to) bool SubversionPluginPrivate::vcsMove(const FilePath &from, const FilePath &to)
{ {
const QFileInfo fromInfo(from); const QFileInfo fromInfo = from.toFileInfo();
const QFileInfo toInfo(to); const QFileInfo toInfo = to.toFileInfo();
return vcsMove(fromInfo.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath()); return vcsMove(fromInfo.absolutePath(), fromInfo.absoluteFilePath(), toInfo.absoluteFilePath());
} }
bool SubversionPluginPrivate::vcsCreateRepository(const QString &) bool SubversionPluginPrivate::vcsCreateRepository(const FilePath &)
{ {
return false; return false;
} }
void SubversionPluginPrivate::vcsAnnotate(const QString &file, int line) void SubversionPluginPrivate::vcsAnnotate(const FilePath &filePath, int line)
{ {
const QFileInfo fi(file); const QFileInfo fi = filePath.toFileInfo();
vcsAnnotateHelper(fi.absolutePath(), fi.fileName(), QString(), line); vcsAnnotateHelper(fi.absolutePath(), fi.fileName(), QString(), line);
} }
@@ -1298,14 +1298,14 @@ Core::ShellCommand *SubversionPluginPrivate::createInitialCheckoutCommand(const
return command; return command;
} }
QString SubversionTopicCache::trackFile(const QString &repository) FilePath SubversionTopicCache::trackFile(const FilePath &repository)
{ {
return m_plugin->monitorFile(repository); return FilePath::fromString(m_plugin->monitorFile(repository.toString()));
} }
QString SubversionTopicCache::refreshTopic(const QString &repository) QString SubversionTopicCache::refreshTopic(const FilePath &repository)
{ {
return m_plugin->synchronousTopic(repository); return m_plugin->synchronousTopic(repository.toString());
} }

View File

@@ -52,7 +52,7 @@ namespace VcsBase {
VcsEditorFactory::VcsEditorFactory(const VcsBaseEditorParameters *parameters, VcsEditorFactory::VcsEditorFactory(const VcsBaseEditorParameters *parameters,
// Force copy, see QTCREATORBUG-13218 // Force copy, see QTCREATORBUG-13218
const EditorWidgetCreator editorWidgetCreator, const EditorWidgetCreator editorWidgetCreator,
std::function<void(const QString &, const QString &)> describeFunc) std::function<void (const Utils::FilePath &, const QString &)> describeFunc)
{ {
setId(parameters->id); setId(parameters->id);
setDisplayName(QCoreApplication::translate("VCS", parameters->displayName)); setDisplayName(QCoreApplication::translate("VCS", parameters->displayName));

View File

@@ -40,7 +40,7 @@ class VCSBASE_EXPORT VcsEditorFactory : public TextEditor::TextEditorFactory
public: public:
VcsEditorFactory(const VcsBaseEditorParameters *parameters, VcsEditorFactory(const VcsBaseEditorParameters *parameters,
const EditorWidgetCreator editorWidgetCreator, const EditorWidgetCreator editorWidgetCreator,
std::function<void(const QString &, const QString &)> describeFunc); std::function<void(const Utils::FilePath &, const QString &)> describeFunc);
}; };
} // namespace VcsBase } // namespace VcsBase

View File

@@ -329,7 +329,8 @@ QString ChangeTextCursorHandler::currentContents() const
void ChangeTextCursorHandler::slotDescribe() void ChangeTextCursorHandler::slotDescribe()
{ {
emit editorWidget()->describeRequested(editorWidget()->source(), m_currentChange); emit editorWidget()->describeRequested(FilePath::fromString(editorWidget()->source()),
m_currentChange);
} }
void ChangeTextCursorHandler::slotCopyRevision() void ChangeTextCursorHandler::slotCopyRevision()

View File

@@ -157,7 +157,7 @@ protected:
int lineNumberDigits() const override; int lineNumberDigits() const override;
public: public:
typedef std::function<void(const QString &, const QString &)> DescribeFunc; typedef std::function<void(const Utils::FilePath &, const QString &)> DescribeFunc;
void finalizeInitialization() override; void finalizeInitialization() override;
// FIXME: Consolidate these into finalizeInitialization // FIXME: Consolidate these into finalizeInitialization
@@ -219,7 +219,7 @@ signals:
// These signals also exist in the opaque editable (IEditor) that is // These signals also exist in the opaque editable (IEditor) that is
// handled by the editor manager for convenience. They are emitted // handled by the editor manager for convenience. They are emitted
// for LogOutput/AnnotateOutput content types. // for LogOutput/AnnotateOutput content types.
void describeRequested(const QString &source, const QString &change); void describeRequested(const Utils::FilePath &source, const QString &change);
void annotateRevisionRequested(const QString &workingDirectory, const QString &file, void annotateRevisionRequested(const QString &workingDirectory, const QString &file,
const QString &change, int lineNumber); const QString &change, int lineNumber);
void diffChunkApplied(const VcsBase::DiffChunk &dc); void diffChunkApplied(const VcsBase::DiffChunk &dc);

View File

@@ -241,7 +241,7 @@ QString StateListener::windowTitleVcsTopic(const QString &filePath)
QString topLevelPath; QString topLevelPath;
IVersionControl *vc = VcsManager::findVersionControlForDirectory( IVersionControl *vc = VcsManager::findVersionControlForDirectory(
searchPath, &topLevelPath); searchPath, &topLevelPath);
return (vc && !topLevelPath.isEmpty()) ? vc->vcsTopic(topLevelPath) : QString(); return (vc && !topLevelPath.isEmpty()) ? vc->vcsTopic(FilePath::fromString(topLevelPath)) : QString();
} }
static inline QString displayNameOfEditor(const QString &fileName) static inline QString displayNameOfEditor(const QString &fileName)
@@ -657,7 +657,7 @@ void VcsBasePluginPrivate::createRepository()
return; return;
} while (true); } while (true);
// Create // Create
const bool rc = vcsCreateRepository(directory); const bool rc = vcsCreateRepository(FilePath::fromString(directory));
const QString nativeDir = QDir::toNativeSeparators(directory); const QString nativeDir = QDir::toNativeSeparators(directory);
if (rc) { if (rc) {
QMessageBox::information(mw, tr("Repository Created"), QMessageBox::information(mw, tr("Repository Created"),

View File

@@ -34,6 +34,8 @@
#include <QTextCursor> #include <QTextCursor>
#include <QUrl> #include <QUrl>
using namespace Utils;
namespace VcsBase { namespace VcsBase {
VcsOutputLineParser::VcsOutputLineParser() : VcsOutputLineParser::VcsOutputLineParser() :
@@ -73,7 +75,7 @@ bool VcsOutputLineParser::handleVcsLink(const QString &workingDirectory, const Q
return true; return true;
} }
if (IVersionControl *vcs = VcsManager::findVersionControlForDirectory(workingDirectory)) if (IVersionControl *vcs = VcsManager::findVersionControlForDirectory(workingDirectory))
return vcs->handleLink(workingDirectory, href); return vcs->handleLink(FilePath::fromString(workingDirectory), href);
return false; return false;
} }
@@ -89,7 +91,7 @@ void VcsOutputLineParser::fillLinkContextMenu(
return; return;
} }
if (Core::IVersionControl *vcs = Core::VcsManager::findVersionControlForDirectory(workingDirectory)) if (Core::IVersionControl *vcs = Core::VcsManager::findVersionControlForDirectory(workingDirectory))
vcs->fillLinkContextMenu(menu, workingDirectory, href); vcs->fillLinkContextMenu(menu, FilePath::fromString(workingDirectory), href);
} }
} }

View File

@@ -52,6 +52,7 @@
using namespace Core; using namespace Core;
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils;
namespace VcsBase { namespace VcsBase {
namespace Internal { namespace Internal {
@@ -122,7 +123,7 @@ bool VcsPlugin::initialize(const QStringList &arguments, QString *errorMessage)
QString topLevel; QString topLevel;
if (Project *project = ProjectTree::currentProject()) if (Project *project = ProjectTree::currentProject())
vc = VcsManager::findVersionControlForDirectory(project->projectDirectory().toString(), &topLevel); vc = VcsManager::findVersionControlForDirectory(project->projectDirectory().toString(), &topLevel);
return vc ? vc->vcsTopic(topLevel) : QString(); return vc ? vc->vcsTopic(FilePath::fromString(topLevel)) : QString();
}); });
expander->registerVariable(Constants::VAR_VCS_TOPLEVELPATH, expander->registerVariable(Constants::VAR_VCS_TOPLEVELPATH,