forked from qt-creator/qt-creator
Vcs: Introduce IVersionControl::unmanagedFiles()
... and use it in VcsManager::promptToAdd(). This is purely a refactoring. The different IVersionControl subclasses can (and should) override the naive base class implementation in the future. Change-Id: Ifdf49852a98f53a95dad1a89131243b21052bc66 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
#include "iversioncontrol.h"
|
#include "iversioncontrol.h"
|
||||||
#include "vcsmanager.h"
|
#include "vcsmanager.h"
|
||||||
|
|
||||||
|
#include <utils/algorithm.h>
|
||||||
#include <utils/hostosinfo.h>
|
#include <utils/hostosinfo.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -147,6 +148,14 @@ IVersionControl::~IVersionControl()
|
|||||||
delete m_topicCache;
|
delete m_topicCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QStringList IVersionControl::unmanagedFiles(const QString &workingDir,
|
||||||
|
const QStringList &filePaths) const
|
||||||
|
{
|
||||||
|
return Utils::filtered(filePaths, [wd = QDir(workingDir), this](const QString &f) {
|
||||||
|
return !managesFile(wd.path(), wd.relativeFilePath(f));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
IVersionControl::OpenSupportMode IVersionControl::openSupportMode(const QString &fileName) const
|
IVersionControl::OpenSupportMode IVersionControl::openSupportMode(const QString &fileName) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(fileName)
|
Q_UNUSED(fileName)
|
||||||
|
@@ -123,6 +123,15 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual bool managesFile(const QString &workingDirectory, const QString &fileName) const = 0;
|
virtual bool managesFile(const QString &workingDirectory, const QString &fileName) const = 0;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* Returns the subset of \a filePaths that is not managed by this version control.
|
||||||
|
*
|
||||||
|
* \a workingDirectory is assumed to be part of a valid repository (not necessarily its
|
||||||
|
* top level). The \a filePaths are expected to be absolute paths.
|
||||||
|
*/
|
||||||
|
virtual QStringList unmanagedFiles(const QString &workingDir,
|
||||||
|
const QStringList &filePaths) const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Returns true is the VCS is configured to run.
|
* Returns true is the VCS is configured to run.
|
||||||
*/
|
*/
|
||||||
|
@@ -400,12 +400,7 @@ void VcsManager::promptToAdd(const QString &directory, const QStringList &fileNa
|
|||||||
if (!vc || !vc->supportsOperation(IVersionControl::AddOperation))
|
if (!vc || !vc->supportsOperation(IVersionControl::AddOperation))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QStringList unmanagedFiles;
|
const QStringList unmanagedFiles = vc->unmanagedFiles(directory, fileNames);
|
||||||
QDir dir(directory);
|
|
||||||
foreach (const QString &fileName, fileNames) {
|
|
||||||
if (!vc->managesFile(directory, dir.relativeFilePath(fileName)))
|
|
||||||
unmanagedFiles << fileName;
|
|
||||||
}
|
|
||||||
if (unmanagedFiles.isEmpty())
|
if (unmanagedFiles.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user