[zpkg] SVN: zpkgtools/trunk/ patch to support Subversion http: and https: access from Brian Sutherland,

Fred L. Drake, Jr. fdrake at gmail.com
Tue Sep 20 15:15:40 EDT 2005


Log message for revision 38543:
  patch to support Subversion http: and https: access from Brian Sutherland,
  with only minor changes and documentation
  

Changed:
  U   zpkgtools/trunk/doc/resources.txt
  U   zpkgtools/trunk/zpkgtools/loader.py
  U   zpkgtools/trunk/zpkgtools/tests/test_loader.py

-=-
Modified: zpkgtools/trunk/doc/resources.txt
===================================================================
--- zpkgtools/trunk/doc/resources.txt	2005-09-20 18:25:38 UTC (rev 38542)
+++ zpkgtools/trunk/doc/resources.txt	2005-09-20 19:15:40 UTC (rev 38543)
@@ -82,8 +82,11 @@
 -----------------------------------------
 
 Currently, CVS is supported generally, and Subversion is supported for
-schemes other than ``http:`` and ``https:``.
+most schemes; for ``http:`` and ``https:``, add an ``svn:`` prefix so
+|zpkg|_ knows the URL is accessible via Subversion::
 
+    svn:http://codespeak.net/svn/user/fdrake/testpkg
+
 Support for additional systems hinges on creating new URL schemes for
 each system.
 

Modified: zpkgtools/trunk/zpkgtools/loader.py
===================================================================
--- zpkgtools/trunk/zpkgtools/loader.py	2005-09-20 18:25:38 UTC (rev 38542)
+++ zpkgtools/trunk/zpkgtools/loader.py	2005-09-20 19:15:40 UTC (rev 38543)
@@ -261,11 +261,15 @@
                          " appropriate revision-control base URL")
 
     def load_svn(self, url):
+        original_url = url
+        type, rest = urllib.splittype(url)
+        if type == "svn" and urllib.splittype(rest)[0]:
+            url = rest
         if self.svnloader is None:
             self.svnloader = svnloader.SubversionLoader()
         tmp = tempfile.mkdtemp(prefix="svnloader-")
         path = self.svnloader.load(url, tmp)
-        self.add_working_dir(url, tmp, path, True)
+        self.add_working_dir(original_url, tmp, path, True)
         return path
 
     def load_svn_ssh(self, url):

Modified: zpkgtools/trunk/zpkgtools/tests/test_loader.py
===================================================================
--- zpkgtools/trunk/zpkgtools/tests/test_loader.py	2005-09-20 18:25:38 UTC (rev 38542)
+++ zpkgtools/trunk/zpkgtools/tests/test_loader.py	2005-09-20 19:15:40 UTC (rev 38543)
@@ -54,6 +54,9 @@
            "cvs://cvs.example.org/cvsroot:module:TAG")
         # Subversion:
         self.check_changing_subversion_urls("svn", "svn.example.org")
+        self.check_changing_subversion_urls("svn:http", "svn.example.org")
+        self.check_changing_subversion_urls("svn:svn", "svn.example.org")
+        self.check_changing_subversion_urls("svn:svn+ssh", "svn.example.org")
         self.check_changing_subversion_urls("svn+ssh", "svn.example.org")
         repodir = urlutils.pathname2url(self.svnrepodir)
         self.check_changing_subversion_urls("file", "", repodir)
@@ -90,6 +93,18 @@
            "svn://example.org/path/to/svnroot/tags/foo/file.txt")
         eq(convert("svn://example.org/path/to/svnroot/branches/foo/file.txt"),
            "svn://example.org/path/to/svnroot/branches/foo/file.txt")
+        eq(convert("svn:http://example.org/path/to/svnroot/tags/foo/file.txt"),
+           "svn:http://example.org/path/to/svnroot/tags/foo/file.txt")
+        eq(convert("svn:http://example.org/path/to/svnroot/branches/foo/f.txt"),
+            "svn:http://example.org/path/to/svnroot/branches/foo/f.txt")
+        eq(convert("svn:svn://example.org/path/to/svnroot/tags/foo/f.txt"),
+           "svn:svn://example.org/path/to/svnroot/tags/foo/f.txt")
+        eq(convert("svn:svn://example.org/path/to/svnrt/branches/f/f.txt"),
+           "svn:svn://example.org/path/to/svnrt/branches/f/f.txt")
+        eq(convert("svn:svn+ssh://example.org/path/to/svnroot/tags/foo/f.txt"),
+           "svn:svn+ssh://example.org/path/to/svnroot/tags/foo/f.txt")
+        eq(convert("svn:svn+ssh://example.org/path/to/svnrt/branches/f/f.txt"),
+           "svn:svn+ssh://example.org/path/to/svnrt/branches/f/f.txt")
         eq(convert("svn+ssh://example.org/path/to/svnroot/tags/foo/file.txt"),
            "svn+ssh://example.org/path/to/svnroot/tags/foo/file.txt")
         eq(convert("svn+ssh://example.org/path/to/svnroot/branches/foo/file"),
@@ -116,6 +131,33 @@
                               "project/tags/SPLAT/file.txt"))
         else:
             self.fail("expected the general Subversion handler to be called")
+ 
+    def test_load_with_svn_prefix(self):
+        """Test loader with svn prefix.
+        
+        Ensure that:
+            1. load_svn handles all urls with an svn: prefix.
+            2. that the url is passed to the svn loader with the prefix stripped
+        """
+        PREFIX = 'svn:'
+        URL = ("bar+foo://svn.example.net/path/to/svnroot/"
+               "project/tags/*/file.txt")
+        class MyError(Exception):
+            def __init__(self, url):
+                self.url = url
+        class MySvnLoader:
+            def load(self, url, tmp):
+                raise MyError(url)
+        loader = self.createLoader(tag="SPLAT")
+        loader.svnloader = MySvnLoader()
+        try:
+            loader.load(PREFIX + URL)
+        except MyError, e:
+            self.assertEqual(e.url,
+                             ("bar+foo://svn.example.net/path/to/svnroot/"
+                              "project/tags/SPLAT/file.txt"))
+        else:
+            self.fail("subversion prefix handling failed")
 
     def test_load_with_file(self):
         filename = os.path.abspath(__file__)
@@ -280,6 +322,21 @@
     TYPE = "svn+ssh"
 
 
+class SvnSvnUrlFunctionTestCase(UrlFunctionTestCase):
+
+    TYPE = "svn:svn"
+
+
+class SvnSvnSshUrlFunctionTestCase(UrlFunctionTestCase):
+
+    TYPE = "svn:svn+ssh"
+
+
+class SvnHttpUrlFunctionTestCase(UrlFunctionTestCase):
+
+    TYPE = "svn:http"
+
+
 class SvnSpecialUrlFunctionTestCase(UrlFunctionTestCase):
 
     TYPE = "svn+other"
@@ -303,6 +360,9 @@
     suite.addTest(unittest.makeSuite(LoaderTestCase))
     suite.addTest(unittest.makeSuite(UrlFunctionTestCase))
     suite.addTest(unittest.makeSuite(SvnSshUrlFunctionTestCase))
+    suite.addTest(unittest.makeSuite(SvnSvnUrlFunctionTestCase))
+    suite.addTest(unittest.makeSuite(SvnSvnSshUrlFunctionTestCase))
+    suite.addTest(unittest.makeSuite(SvnHttpUrlFunctionTestCase))
     suite.addTest(unittest.makeSuite(SvnSpecialUrlFunctionTestCase))
     suite.addTest(unittest.makeSuite(SvnFileUrlFunctionTestCase))
     suite.addTest(unittest.makeSuite(SvnFileLocalhostUrlFunctionTestCase))



More information about the zpkg mailing list