Commit fa2c24d9 authored by Tobias Hunger's avatar Tobias Hunger

SVN: Refactor SVN detection code

Reviewed-by: default avatarJonathan Liu <net147@gmail.com>
Change-Id: Ib78251b69a89ee503bb78ab122c6e37a6ec7aacb
Reviewed-by: default avatarTobias Hunger <tobias.hunger@nokia.com>
parent 67ac492c
......@@ -1357,58 +1357,43 @@ QString SubversionPlugin::vcsGetRepositoryURL(const QString &directory)
return QString();
}
/* Subversion < 1.7 has ".svn" directory in each directory
* it manages. The top level is the first directory
* under the directory that does not have a ".svn".
*
* Subversion >= 1.7 has ".svn" directory in the root of the
* working copy. The top level is the root of the working copy
* containg ".svn". */
bool SubversionPlugin::managesDirectory(const QString &directory, QString *topLevel /* = 0 */) const
{
const QDir dir(directory);
if (!dir.exists())
return false;
if (topLevel)
topLevel->clear();
bool manages = false;
// Subversion >= 1.7: Check for furthest parent containing
// ".svn/wc.db". Need to check for furthest parent as closer
// parents may be svn:externals.
if (dir.exists()) {
QDir parentDir = dir;
while (parentDir.cdUp()) {
if (checkSVNSubDir(parentDir, QLatin1String("wc.db"))) {
manages = true;
if (topLevel)
*topLevel = parentDir.absolutePath();
}
/* Subversion >= 1.7 has ".svn" directory in the root of the working copy. Check for
* furthest parent containing ".svn/wc.db". Need to check for furthest parent as closer
* parents may be svn:externals. */
QDir parentDir = dir;
while (parentDir.cdUp()) {
if (checkSVNSubDir(parentDir, QLatin1String("wc.db"))) {
if (topLevel)
*topLevel = parentDir.absolutePath();
return true;
}
}
do {
if (manages)
break;
if (!dir.exists() || !checkSVNSubDir(dir))
break;
manages = true;
if (!topLevel)
break;
/* Recursing up, the top level is a child of the first directory that does
* not have a ".svn" directory. The starting directory must be a managed
* one. Go up and try to find the first unmanaged parent dir. */
QDir lastDirectory = dir;
for (QDir parentDir = lastDirectory; parentDir.cdUp() ; lastDirectory = parentDir) {
if (!checkSVNSubDir(parentDir)) {
*topLevel = lastDirectory.absolutePath();
break;
/* Subversion < 1.7 has ".svn" directory in each directory
* it manages. The top level is the first directory
* under the directory that does not have a ".svn".*/
if (!checkSVNSubDir(dir))
return false;
if (topLevel) {
QDir lastDirectory = dir;
for (parentDir = lastDirectory; parentDir.cdUp() ; lastDirectory = parentDir) {
if (!checkSVNSubDir(parentDir)) {
*topLevel = lastDirectory.absolutePath();
break;
}
}
} while (false);
if (Subversion::Constants::debug) {
QDebug nsp = qDebug().nospace();
nsp << "SubversionPlugin::managesDirectory" << directory << manages;
if (topLevel)
nsp << *topLevel;
}
return manages;
return false;
}
// Check whether SVN management subdirs exist.
......
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