diff options
author | Tobias Hunger <tobias.hunger@nokia.com> | 2011-10-19 14:07:26 +0000 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@nokia.com> | 2011-10-19 16:12:23 +0200 |
commit | fa2c24d92b23b23d0548c4cdcd653d7adc6326cc (patch) | |
tree | 7f6c8fe0d31419c96e1b110e190c3775557d9c05 | |
parent | 67ac492ca0aabcc53f5d5e024f5f45f598916117 (diff) |
SVN: Refactor SVN detection code
Reviewed-by: Jonathan Liu <net147@gmail.com>
Change-Id: Ib78251b69a89ee503bb78ab122c6e37a6ec7aacb
Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
-rw-r--r-- | src/plugins/subversion/subversionplugin.cpp | 69 |
1 files changed, 27 insertions, 42 deletions
diff --git a/src/plugins/subversion/subversionplugin.cpp b/src/plugins/subversion/subversionplugin.cpp index 3165f1de1f..955a8ccf7d 100644 --- a/src/plugins/subversion/subversionplugin.cpp +++ b/src/plugins/subversion/subversionplugin.cpp @@ -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. |