Commit bb924266 authored by Bastian Holst's avatar Bastian Holst

add darcs support for kate project plugin

parent 8cfea140
......@@ -26,6 +26,7 @@
#include <QFile>
#include <QFileInfo>
#include <QProcess>
#include <QRegularExpression>
#include <QSet>
#include <QTime>
......@@ -229,6 +230,8 @@ QStringList KateProjectWorker::findFiles(const QDir &dir, const QVariantMap& fil
return filesFromMercurial(dir, recursive);
} else if (filesEntry[QStringLiteral("svn")].toBool()) {
return filesFromSubversion(dir, recursive);
} else if (filesEntry[QStringLiteral("darcs")].toBool()) {
return filesFromDarcs(dir, recursive);
} else {
QStringList files = filesEntry[QStringLiteral("list")].toStringList();
......@@ -354,6 +357,65 @@ QStringList KateProjectWorker::filesFromSubversion(const QDir& dir, bool recursi
return files;
}
QStringList KateProjectWorker::filesFromDarcs(const QDir& dir, bool recursive)
{
QStringList files;
const QString cmd = QStringLiteral("darcs");
QString root;
{
QProcess darcs;
darcs.setWorkingDirectory(dir.absolutePath());
QStringList args;
args << QStringLiteral("list") << QStringLiteral("repo");
darcs.start(cmd, args);
if (!darcs.waitForStarted() || !darcs.waitForFinished())
return files;
auto str = QString::fromLocal8Bit(darcs.readAllStandardOutput());
QRegularExpression exp(QStringLiteral("Root: ([^\\n\\r]*)"));
auto match = exp.match(str);
if(!match.hasMatch())
return files;
root = match.captured(1);
}
QStringList relFiles;
{
QProcess darcs;
QStringList args;
darcs.setWorkingDirectory(dir.absolutePath());
args << QStringLiteral("list") << QStringLiteral("files")
<< QStringLiteral("--no-directories") << QStringLiteral("--pending");
darcs.start(cmd, args);
if(!darcs.waitForStarted() || !darcs.waitForFinished())
return files;
relFiles = QString::fromLocal8Bit(darcs.readAllStandardOutput())
.split(QRegularExpression(QStringLiteral("[\n\r]")), QString::SkipEmptyParts);
}
Q_FOREACH(auto relFile, relFiles) {
const QString path = dir.relativeFilePath(root + QStringLiteral("/") + relFile);
if (!recursive && (relFile.indexOf(QStringLiteral("/")) != -1))
continue;
else if (recursive && (relFile.indexOf(QStringLiteral("..")) == 0))
continue;
files.append(dir.absoluteFilePath(path));
}
return files;
}
QStringList KateProjectWorker::filesFromDirectory(const QDir& _dir, bool recursive, const QStringList &filters)
{
QStringList files;
......
......@@ -92,6 +92,7 @@ private:
QStringList filesFromGit(const QDir &dir, bool recursive);
QStringList filesFromMercurial(const QDir &dir, bool recursive);
QStringList filesFromSubversion(const QDir &dir, bool recursive);
QStringList filesFromDarcs(const QDir &dir, bool recursive);
QStringList filesFromDirectory(const QDir &dir, bool recursive, const QStringList &filters);
private:
......
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