OSDN Git Service

SVN: Fix handling of svn:externals for Subversion 1.7
authorJonathan Liu <net147@gmail.com>
Wed, 19 Oct 2011 14:06:40 +0000 (14:06 +0000)
committerTobias Hunger <tobias.hunger@nokia.com>
Wed, 19 Oct 2011 14:12:08 +0000 (16:12 +0200)
Change-Id: I3f869fd316d2f2a3a41c622321cebb79575c423f
Merge-request: 409
Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com>
src/plugins/subversion/subversionplugin.cpp
src/plugins/subversion/subversionplugin.h

index eccf134..3165f1d 100644 (file)
@@ -1370,7 +1370,22 @@ bool SubversionPlugin::managesDirectory(const QString &directory, QString *topLe
     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();
+            }
+        }
+    }
     do {
+        if (manages)
+            break;
         if (!dir.exists() || !checkSVNSubDir(dir))
             break;
         manages = true;
@@ -1387,18 +1402,6 @@ bool SubversionPlugin::managesDirectory(const QString &directory, QString *topLe
             }
         }
     } while (false);
-    // Subversion >= 1.7: Check for first parent containing ".svn"
-    if (!manages) {
-        QDir parentDir = dir;
-        while (parentDir.cdUp()) {
-            if (checkSVNSubDir(parentDir)) {
-                manages = true;
-                if (topLevel)
-                    *topLevel = parentDir.absolutePath();
-                break;
-            }
-        }
-    }
     if (Subversion::Constants::debug) {
         QDebug nsp = qDebug().nospace();
         nsp << "SubversionPlugin::managesDirectory" << directory << manages;
@@ -1409,13 +1412,16 @@ bool SubversionPlugin::managesDirectory(const QString &directory, QString *topLe
 }
 
 // Check whether SVN management subdirs exist.
-bool SubversionPlugin::checkSVNSubDir(const QDir &directory) const
+bool SubversionPlugin::checkSVNSubDir(const QDir &directory, const QString &fileName) const
 {
     const int dirCount = m_svnDirectories.size();
     for (int i = 0; i < dirCount; i++) {
         const QString svnDir = directory.absoluteFilePath(m_svnDirectories.at(i));
-        if (QFileInfo(svnDir).isDir())
-            return true;
+        if (!QFileInfo(svnDir).isDir())
+            continue;
+        if (!fileName.isEmpty() && !QDir(svnDir).exists(fileName))
+            continue;
+        return true;
     }
     return false;
 }
index ddadc78..14d582d 100644 (file)
@@ -163,7 +163,7 @@ private:
                  bool enableAnnotationContextMenu = false);
     void svnStatus(const QString &workingDir, const QStringList &relativePath = QStringList());
     void svnUpdate(const QString &workingDir, const QStringList &relativePaths = QStringList());
-    bool checkSVNSubDir(const QDir &directory) const;
+    bool checkSVNSubDir(const QDir &directory, const QString &fileName = QString()) const;
     void startCommit(const QString &workingDir, const QStringList &files = QStringList());
     bool commit(const QString &messageFile, const QStringList &subVersionFileList);
     void cleanCommitMessageFile();