Commit 6b9caff2 authored by Méven Car's avatar Méven Car
Browse files

Allow git, hg and svn plugins to detect working copy root

BUG: 430024
parent e2e28647
......@@ -129,6 +129,17 @@ QString FileViewGitPlugin::fileName() const
return QLatin1String(".git");
}
QString FileViewGitPlugin::localRepositoryRoot(const QString& directory) const
{
QProcess process;
process.setWorkingDirectory(directory);
process.start("git", {"rev-parse", "--show-toplevel"});
if (process.waitForReadyRead(100) && process.exitCode() == 0) {
return QString::fromUtf8(process.readAll().chopped(1));
}
return QString();
}
int FileViewGitPlugin::readUntilZeroChar(QIODevice* device, char* buffer, const int maxChars) {
if (buffer == 0) { // discard until next \0
char c;
......@@ -253,7 +264,7 @@ bool FileViewGitPlugin::beginRetrieval(const QString& directory)
m_versionInfoHash.insert(absoluteDirName, state);
}
} else { //normal file, no directory
m_versionInfoHash.insert(directory + relativeFileName, state);
m_versionInfoHash.insert(directory + relativeFileName, state);
}
}
}
......
......@@ -44,6 +44,7 @@ public:
FileViewGitPlugin(QObject* parent, const QList<QVariant>& args);
~FileViewGitPlugin() override;
QString fileName() const override;
QString localRepositoryRoot(const QString& directory) const override;
bool beginRetrieval(const QString& directory) override;
void endRetrieval() override;
ItemVersion itemVersion(const KFileItem& item) const override;
......
......@@ -318,6 +318,17 @@ QString FileViewHgPlugin::fileName() const
return QLatin1String(".hg");
}
QString FileViewHgPlugin::localRepositoryRoot(const QString& directory) const
{
QProcess process;
process.setWorkingDirectory(directory);
process.start("hg", {"root"});
if (process.waitForReadyRead(100) && process.exitCode() == 0) {
return QString::fromUtf8(process.readAll().chopped(1));
}
return QString();
}
bool FileViewHgPlugin::beginRetrieval(const QString &directory)
{
clearMessages();
......
......@@ -39,6 +39,7 @@ public:
FileViewHgPlugin(QObject *parent, const QList<QVariant> &args);
~FileViewHgPlugin() override;
QString fileName() const override;
QString localRepositoryRoot(const QString& directory) const override;
bool beginRetrieval(const QString& directory) override;
void endRetrieval() override;
KVersionControlPlugin::ItemVersion itemVersion(const KFileItem& item) const override;
......
......@@ -152,6 +152,17 @@ QString FileViewSvnPlugin::fileName() const
return QLatin1String(".svn");
}
QString FileViewSvnPlugin::localRepositoryRoot(const QString& directory) const
{
QProcess process;
process.setWorkingDirectory(directory);
process.start("svn", {"info", "--show-item", "wc-root"});
if (process.waitForReadyRead(100) && process.exitCode() == 0) {
return QString::fromUtf8(process.readAll().chopped(1));
}
return QString();
}
bool FileViewSvnPlugin::beginRetrieval(const QString& directory)
{
Q_ASSERT(directory.endsWith(QLatin1Char('/')));
......
......@@ -39,6 +39,7 @@ public:
FileViewSvnPlugin(QObject* parent, const QList<QVariant>& args);
~FileViewSvnPlugin() override;
QString fileName() const override;
QString localRepositoryRoot(const QString& directory) const override;
bool beginRetrieval(const QString& directory) override;
void endRetrieval() override;
ItemVersion itemVersion(const KFileItem& item) const override;
......
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