[meld] Use more robust check for Subversion repository version support



commit daa682b4986c2be428eb79ea8a1699983de3da32
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Tue Oct 23 06:20:08 2012 +1000

    Use more robust check for Subversion repository version support
    
    This commit removes the hack where we made sure that only one of the
    two subversion modules was listed, since now only one of them will be
    valid.

 meld/vc/__init__.py |    5 -----
 meld/vc/svn.py      |   19 +++++++++++++++++--
 meld/vc/svn_17.py   |    2 ++
 3 files changed, 19 insertions(+), 7 deletions(-)
---
diff --git a/meld/vc/__init__.py b/meld/vc/__init__.py
index f9c07c8..f78dd53 100644
--- a/meld/vc/__init__.py
+++ b/meld/vc/__init__.py
@@ -94,9 +94,4 @@ def get_vcs(location):
     vc_sort_key = lambda v: vc_sort_order.index(v.NAME)
     vcs.sort(key=vc_sort_key)
 
-    # Simplistic hack so that we don't offer both 1.7 and <1.6 SVN
-    vc_names = [plugin.NAME for plugin in vcs]
-    if "Subversion" in vc_names and "Subversion 1.7" in vc_names:
-        vcs = [plugin for plugin in vcs if plugin.NAME != "Subversion 1.7"]
-
     return vcs
diff --git a/meld/vc/svn.py b/meld/vc/svn.py
index 440e778..99e277f 100644
--- a/meld/vc/svn.py
+++ b/meld/vc/svn.py
@@ -1,5 +1,5 @@
 ### Copyright (C) 2002-2005 Stephen Kennedy <stevek gnome org>
-### Copyright (C) 2011 Kai Willadsen <kai willadsen gmail com>
+### Copyright (C) 2011-2012 Kai Willadsen <kai willadsen gmail com>
 
 ### Redistribution and use in source and binary forms, with or without
 ### modification, are permitted provided that the following conditions
@@ -85,11 +85,26 @@ class Vc(_vc.CachedVc):
 
         return tmp_path
 
+    def _repo_version_support(self, version):
+        return version < 12
+
     def valid_repo(self):
         if _vc.call([self.CMD, "info"], cwd=self.root):
             return False
+
+        # Check for repository version, trusting format file then entries file
+        format_path = os.path.join(self.root, self.VC_DIR, "format")
+        entries_path = os.path.join(self.root, self.VC_DIR, "entries")
+        if os.path.exists(format_path):
+            version_file = format_path
+        elif os.path.exists(entries_path):
+            version_file = entries_path
         else:
-            return True
+            return False
+
+        with open(version_file) as f:
+            content = f.readline().strip()
+        return self._repo_version_support(int(content))
 
     def switch_to_external_diff(self):
         self.external_diff = "diff"
diff --git a/meld/vc/svn_17.py b/meld/vc/svn_17.py
index 3feb4da..09c5014 100644
--- a/meld/vc/svn_17.py
+++ b/meld/vc/svn_17.py
@@ -29,3 +29,5 @@ class Vc(svn.Vc):
     NAME = "Subversion 1.7"
     VC_ROOT_WALK = True
 
+    def _repo_version_support(self, version):
+        return version >= 12



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]