Support for the versionable .fossil-settings/ignore-glob file
FossilOrigin-Name: 511954d6d9c5a74454ffe3bc3e552b93e1cbf985
This commit is contained in:
@@ -700,11 +700,35 @@ bool MainWindow::refresh()
|
||||
void MainWindow::scanWorkspace()
|
||||
{
|
||||
setBusy(true);
|
||||
|
||||
static const QRegExp REGEX_GLOB_LIST(",|\\n", Qt::CaseSensitive);
|
||||
|
||||
QStringList ignore_patterns;
|
||||
|
||||
// Determine ignored file patterns
|
||||
{
|
||||
QString ignore_list = settings.GetFossilValue(FOSSIL_SETTING_IGNORE_GLOB).toString().trimmed();
|
||||
|
||||
// Read patterns from versionable file if it exists
|
||||
QFile ignored_file(getWorkspace().getPath() + PATH_SEPARATOR ".fossil-settings" PATH_SEPARATOR "ignore-glob");
|
||||
|
||||
if(ignored_file.open(QFile::ReadOnly))
|
||||
{
|
||||
ignore_list = ignored_file.readAll();
|
||||
ignored_file.close();
|
||||
}
|
||||
|
||||
if(!ignore_list.isEmpty())
|
||||
ignore_patterns = ignore_list.split(REGEX_GLOB_LIST, QString::SkipEmptyParts);
|
||||
|
||||
TrimStringList(ignore_patterns);
|
||||
}
|
||||
|
||||
getWorkspace().scanWorkspace(ui->actionViewUnknown->isChecked(),
|
||||
ui->actionViewIgnored->isChecked(),
|
||||
ui->actionViewModified->isChecked(),
|
||||
ui->actionViewUnchanged->isChecked(),
|
||||
settings.GetFossilValue(FOSSIL_SETTING_IGNORE_GLOB).toString(),
|
||||
ignore_patterns,
|
||||
uiCallback,
|
||||
operationAborted
|
||||
);
|
||||
|
@@ -636,3 +636,10 @@ bool SpawnExternalProcess(QObject *processParent, const QString& command, const
|
||||
QProcess proc(processParent);
|
||||
return proc.startDetached(cmd, params);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void TrimStringList(QStringList& list)
|
||||
{
|
||||
for(int i=0; i<list.length(); ++i)
|
||||
list[i] = list[i].trimmed();
|
||||
}
|
||||
|
@@ -64,6 +64,7 @@ QString UrlToStringDisplay(const QUrl &url);
|
||||
QString UrlToStringNoCredentials(const QUrl& url);
|
||||
void SplitCommandLine(const QString &commandLine, QString &command, QString &extraParams);
|
||||
bool SpawnExternalProcess(QObject *processParent, const QString& command, const QStringList& fileList, const stringset_t& pathSet, const QString &workspaceDir, UICallback &uiCallback);
|
||||
void TrimStringList(QStringList &list);
|
||||
|
||||
typedef QMap<QString, QString> QStringMap;
|
||||
void ParseProperties(QStringMap &properties, const QStringList &lines, QChar separator=' ');
|
||||
|
@@ -120,7 +120,7 @@ bool Workspace::switchWorkspace(const QString& workspace, QSettings &store)
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
bool Workspace::scanDirectory(QFileInfoList &entries, const QString& dirPath, const QString &baseDir, const QString ignoreSpec, const bool &abort, UICallback &uiCallback)
|
||||
bool Workspace::scanDirectory(QFileInfoList &entries, const QString& dirPath, const QString &baseDir, const QStringList &ignorePatterns, const bool &abort, UICallback &uiCallback)
|
||||
{
|
||||
QDir dir(dirPath);
|
||||
|
||||
@@ -138,12 +138,12 @@ bool Workspace::scanDirectory(QFileInfoList &entries, const QString& dirPath, co
|
||||
rel_path.remove(baseDir+PATH_SEPARATOR);
|
||||
|
||||
// Skip ignored files
|
||||
if(!ignoreSpec.isEmpty() && QDir::match(ignoreSpec, rel_path))
|
||||
if(!ignorePatterns.isEmpty() && QDir::match(ignorePatterns, rel_path))
|
||||
continue;
|
||||
|
||||
if (info.isDir())
|
||||
{
|
||||
if(!scanDirectory(entries, filepath, baseDir, ignoreSpec, abort, uiCallback))
|
||||
if(!scanDirectory(entries, filepath, baseDir, ignorePatterns, abort, uiCallback))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
@@ -159,7 +159,7 @@ static bool StringLengthDescending(const QString &l, const QString &r)
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModified, bool scanUnchanged, const QString &ignoreGlob, UICallback &uiCallback, bool &operationAborted)
|
||||
void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModified, bool scanUnchanged, const QStringList &ignorePatterns, UICallback &uiCallback, bool &operationAborted)
|
||||
{
|
||||
// Scan all workspace files
|
||||
QFileInfoList all_files;
|
||||
@@ -186,14 +186,9 @@ void Workspace::scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModifie
|
||||
{
|
||||
QCoreApplication::processEvents();
|
||||
|
||||
QString ignore;
|
||||
// If we should not be showing ignored files, fill in the ignored spec
|
||||
QStringList ignore;
|
||||
if(!scanIgnored)
|
||||
{
|
||||
// QDir expects multiple specs being separated by a semicolon
|
||||
ignore = ignoreGlob;
|
||||
ignore.replace(',',';');
|
||||
}
|
||||
ignore = ignorePatterns;
|
||||
|
||||
if(!scanDirectory(all_files, wkdir, wkdir, ignore, operationAborted, uiCallback))
|
||||
goto _done;
|
||||
|
@@ -134,7 +134,7 @@ public:
|
||||
|
||||
const QString & getPath() const { return fossil().getWorkspacePath(); }
|
||||
bool switchWorkspace(const QString &workspace, QSettings &store);
|
||||
void scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModified, bool scanUnchanged, const QString &ignoreGlob, UICallback &uiCallback, bool &operationAborted);
|
||||
void scanWorkspace(bool scanLocal, bool scanIgnored, bool scanModified, bool scanUnchanged, const QStringList& ignorePatterns, UICallback &uiCallback, bool &operationAborted);
|
||||
|
||||
QStandardItemModel &getFileModel() { return repoFileModel; }
|
||||
QStandardItemModel &getTreeModel() { return repoTreeModel; }
|
||||
@@ -160,7 +160,7 @@ public:
|
||||
|
||||
void storeWorkspace(QSettings &store);
|
||||
private:
|
||||
static bool scanDirectory(QFileInfoList &entries, const QString& dirPath, const QString &baseDir, const QString ignoreSpec, const bool& abort, UICallback &uiCallback);
|
||||
static bool scanDirectory(QFileInfoList &entries, const QString& dirPath, const QString &baseDir, const QStringList& ignorePatterns, const bool& abort, UICallback &uiCallback);
|
||||
|
||||
private:
|
||||
Fossil bridge;
|
||||
|
Reference in New Issue
Block a user