Commit 2361af90 authored by Javier Guerra's avatar Javier Guerra
Browse files

Add basic Fossil support to Autoload Repositories

Use Fossil-SCM to create projects, just like existing functionality for
Git, Subversioin and Mercurial (and Darcs?)
parent 4cae287c
Pipeline #112596 passed with stage
in 4 minutes and 19 seconds
......@@ -30,6 +30,9 @@ struct
/// If "svn" is set to "1", the list of files is retrieved by running svn (subversion) in the files directory.
bool svn;
/// If "fossil" is set to "1", the list of files is retrieved by running fossil in the files directory.
bool fossil;
/// "list" can be set to a list of files.
vector< string > list;
......
......@@ -34,6 +34,8 @@ KateProjectConfigPage::KateProjectConfigPage(QWidget *parent, KateProjectPlugin
vbox->addWidget(m_cbAutoSubversion);
m_cbAutoMercurial = new QCheckBox(i18n("&Mercurial"), this);
vbox->addWidget(m_cbAutoMercurial);
m_cbAutoFossil = new QCheckBox(i18n("&Fossil"), this);
vbox->addWidget(m_cbAutoFossil);
vbox->addStretch(1);
group->setLayout(vbox);
......@@ -104,6 +106,7 @@ KateProjectConfigPage::KateProjectConfigPage(QWidget *parent, KateProjectPlugin
connect(m_cbAutoGit, &QCheckBox::stateChanged, this, &KateProjectConfigPage::slotMyChanged);
connect(m_cbAutoSubversion, &QCheckBox::stateChanged, this, &KateProjectConfigPage::slotMyChanged);
connect(m_cbAutoMercurial, &QCheckBox::stateChanged, this, &KateProjectConfigPage::slotMyChanged);
connect(m_cbAutoFossil, &QCheckBox::stateChanged, this, &KateProjectConfigPage::slotMyChanged);
connect(m_cbIndexEnabled, &QCheckBox::stateChanged, this, &KateProjectConfigPage::slotMyChanged);
connect(m_indexPath, &KUrlRequester::textChanged, this, &KateProjectConfigPage::slotMyChanged);
connect(m_indexPath, &KUrlRequester::urlSelected, this, &KateProjectConfigPage::slotMyChanged);
......@@ -142,7 +145,8 @@ void KateProjectConfigPage::apply()
m_plugin->setAutoRepository(m_cbAutoGit->checkState() == Qt::Checked,
m_cbAutoSubversion->checkState() == Qt::Checked,
m_cbAutoMercurial->checkState() == Qt::Checked);
m_cbAutoMercurial->checkState() == Qt::Checked,
m_cbAutoFossil->checkState() == Qt::Checked);
m_plugin->setIndex(m_cbIndexEnabled->checkState() == Qt::Checked, m_indexPath->url());
m_plugin->setMultiProject(m_cbMultiProjectCompletion->checkState() == Qt::Checked, m_cbMultiProjectGoto->checkState() == Qt::Checked);
......@@ -156,6 +160,7 @@ void KateProjectConfigPage::reset()
m_cbAutoGit->setCheckState(m_plugin->autoGit() ? Qt::Checked : Qt::Unchecked);
m_cbAutoSubversion->setCheckState(m_plugin->autoSubversion() ? Qt::Checked : Qt::Unchecked);
m_cbAutoMercurial->setCheckState(m_plugin->autoMercurial() ? Qt::Checked : Qt::Unchecked);
m_cbAutoFossil->setCheckState(m_plugin->autoFossil() ? Qt::Checked : Qt::Unchecked);
m_cbIndexEnabled->setCheckState(m_plugin->getIndexEnabled() ? Qt::Checked : Qt::Unchecked);
m_indexPath->setUrl(m_plugin->getIndexDirectory());
m_cbMultiProjectCompletion->setCheckState(m_plugin->multiProjectCompletion() ? Qt::Checked : Qt::Unchecked);
......
......@@ -41,6 +41,7 @@ private:
QCheckBox *m_cbAutoGit;
QCheckBox *m_cbAutoSubversion;
QCheckBox *m_cbAutoMercurial;
QCheckBox *m_cbAutoFossil;
QCheckBox *m_cbIndexEnabled;
KUrlRequester *m_indexPath;
QCheckBox *m_cbMultiProjectCompletion;
......
......@@ -48,10 +48,12 @@ const QString ProjectFileName = QStringLiteral(".kateproject");
const QString GitFolderName = QStringLiteral(".git");
const QString SubversionFolderName = QStringLiteral(".svn");
const QString MercurialFolderName = QStringLiteral(".hg");
const QString FossilCheckoutFileName = QStringLiteral(".fslckout");
const QString GitConfig = QStringLiteral("git");
const QString SubversionConfig = QStringLiteral("subversion");
const QString MercurialConfig = QStringLiteral("mercurial");
const QString FossilConfig = QStringLiteral("fossil");
const QStringList DefaultConfig = QStringList() << GitConfig << SubversionConfig << MercurialConfig;
}
......@@ -206,7 +208,7 @@ KateProject *KateProjectPlugin::projectForDir(QDir dir, bool userSpecified)
for (const QString &dir : directoryStack) {
// try to invent project based on version control stuff
KateProject *project = nullptr;
if ((project = detectGit(dir)) || (project = detectSubversion(dir)) || (project = detectMercurial(dir))) {
if ((project = detectGit(dir)) || (project = detectSubversion(dir)) || (project = detectMercurial(dir)) || (project = detectFossil(dir))) {
return project;
}
}
......@@ -346,6 +348,15 @@ KateProject *KateProjectPlugin::detectMercurial(const QDir &dir)
return nullptr;
}
KateProject *KateProjectPlugin::detectFossil(const QDir &dir)
{
if (m_autoFossil && dir.exists(FossilCheckoutFileName) && QFileInfo(dir, FossilCheckoutFileName).isReadable()) {
return createProjectForRepository(QStringLiteral("fossil"), dir);
}
return nullptr;
}
KateProject *KateProjectPlugin::createProjectForRepository(const QString &type, const QDir &dir)
{
QVariantMap cnf, files;
......@@ -378,11 +389,12 @@ KateProject *KateProjectPlugin::createProjectForDirectory(const QDir &dir)
return project;
}
void KateProjectPlugin::setAutoRepository(bool onGit, bool onSubversion, bool onMercurial)
void KateProjectPlugin::setAutoRepository(bool onGit, bool onSubversion, bool onMercurial, bool onFossil)
{
m_autoGit = onGit;
m_autoSubversion = onSubversion;
m_autoMercurial = onMercurial;
m_autoFossil = onFossil;
writeConfig();
}
......@@ -401,6 +413,11 @@ bool KateProjectPlugin::autoMercurial() const
return m_autoMercurial;
}
bool KateProjectPlugin::autoFossil() const
{
return m_autoFossil;
}
void KateProjectPlugin::setIndex(bool enabled, const QUrl &directory)
{
m_indexEnabled = enabled;
......@@ -476,6 +493,7 @@ void KateProjectPlugin::readConfig()
m_autoGit = autorepository.contains(GitConfig);
m_autoSubversion = autorepository.contains(SubversionConfig);
m_autoMercurial = autorepository.contains(MercurialConfig);
m_autoFossil = autorepository.contains(FossilConfig);
m_indexEnabled = config.readEntry("index", false);
m_indexDirectory = config.readEntry("indexDirectory", QUrl());
......@@ -507,6 +525,10 @@ void KateProjectPlugin::writeConfig()
repos << MercurialConfig;
}
if (m_autoFossil) {
repos << FossilConfig;
}
config.writeEntry("autorepository", repos);
config.writeEntry("index", m_indexEnabled);
......
......@@ -105,10 +105,11 @@ public:
return m_document2Project.value(document);
}
void setAutoRepository(bool onGit, bool onSubversion, bool onMercurial);
void setAutoRepository(bool onGit, bool onSubversion, bool onMercurial, bool onFossil);
bool autoGit() const;
bool autoSubversion() const;
bool autoMercurial() const;
bool autoFossil() const;
void setIndex(bool enabled, const QUrl &directory);
bool getIndexEnabled() const;
......@@ -183,6 +184,7 @@ private:
KateProject *detectGit(const QDir &dir);
KateProject *detectSubversion(const QDir &dir);
KateProject *detectMercurial(const QDir &dir);
KateProject *detectFossil(const QDir &dir);
void readConfig();
void writeConfig();
......@@ -216,6 +218,7 @@ private:
bool m_autoGit = true;
bool m_autoSubversion = true;
bool m_autoMercurial = true;
bool m_autoFossil = true;
// indexing is expensive, default off
bool m_indexEnabled = false;
......
......@@ -380,6 +380,10 @@ QVector<QString> KateProjectWorker::findFiles(const QDir &dir, const QVariantMap
return filesFromDarcs(dir, recursive);
}
if (filesEntry[QStringLiteral("fossil")].toBool()) {
return filesFromFossil(dir, recursive);
}
/**
* if we arrive here, we have some manual specification of files, no VCS
*/
......@@ -613,6 +617,33 @@ QVector<QString> KateProjectWorker::filesFromDarcs(const QDir &dir, bool recursi
return files;
}
QVector<QString> KateProjectWorker::filesFromFossil(const QDir &dir, bool recursive)
{
QVector<QString> files;
QProcess fossil;
fossil.setWorkingDirectory(dir.absolutePath());
QStringList args;
args << QStringLiteral("ls");
fossil.start(QStringLiteral("fossil"), args, QProcess::ReadOnly);
if (!fossil.waitForStarted() || !fossil.waitForFinished(-1)) {
return files;
}
const QStringList relFiles = QString::fromLocal8Bit(fossil.readAllStandardOutput()).split(QRegularExpression(QStringLiteral("[\n\r]")), Qt::SkipEmptyParts);
files.reserve(relFiles.size());
for (const QString &relFile : relFiles) {
if (!recursive && (relFile.indexOf(QLatin1Char('/')) != -1)) {
continue;
}
files.append(relFile);
}
return files;
}
QVector<QString> KateProjectWorker::filesFromDirectory(const QDir &_dir, bool recursive, const QStringList &filters)
{
/**
......
......@@ -65,6 +65,7 @@ private:
static QVector<QString> filesFromMercurial(const QDir &dir, bool recursive);
static QVector<QString> filesFromSubversion(const QDir &dir, bool recursive);
static QVector<QString> filesFromDarcs(const QDir &dir, bool recursive);
static QVector<QString> filesFromFossil(const QDir &dir, bool recursive);
static QVector<QString> filesFromDirectory(const QDir &dir, bool recursive, const QStringList &filters);
static QVector<QString> gitFiles(const QDir &dir, bool recursive, const QStringList &args);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment