SVN: zpkgtools/trunk/zpkgtools/ remove repository: URL scheme; it just was not useful after all

"Fred L. Drake, Jr." <[email protected]>
Newsgroups gmane.comp.web.zope.public-cvs
Message-ID <[email protected]>
Log message for revision 37877:
  remove repository: URL scheme; it just was not useful after all

Changed:
  U   zpkgtools/trunk/zpkgtools/cvsloader.py
  U   zpkgtools/trunk/zpkgtools/locationmap.py
  U   zpkgtools/trunk/zpkgtools/tests/test_cvsloader.py
  U   zpkgtools/trunk/zpkgtools/tests/test_loader.py
  U   zpkgtools/trunk/zpkgtools/tests/test_locationmap.py
  U   zpkgtools/trunk/zpkgtools/tests/test_svnloader.py

-=-
Modified: zpkgtools/trunk/zpkgtools/cvsloader.py
===================================================================
--- zpkgtools/trunk/zpkgtools/cvsloader.py	2005-08-11 20:26:33 UTC (rev 37876)
+++ zpkgtools/trunk/zpkgtools/cvsloader.py	2005-08-11 20:26:45 UTC (rev 37877)
@@ -47,20 +47,10 @@
     """,
     re.IGNORECASE | re.VERBOSE).match
 
-_repository_url_match = re.compile(
-    """
-    repository:(?P<path>[^:]*)
-    (:(?P<tag>[^:]*))?$
-    """,
-    re.IGNORECASE | re.VERBOSE).match
-
 def parse(cvsurl):
     m = _cvs_url_match(cvsurl)
     if m is None:
-        m = _repository_url_match(cvsurl)
-        if m is None:
-            raise ValueError("not a valid CVS url: %r" % cvsurl)
-        return RepositoryUrl(m.group("path"), m.group("tag"))
+        raise ValueError("not a valid CVS url: %r" % cvsurl)
     host = m.group("host")
     cvsroot = "/" + m.group("cvsroot")
     path = m.group("path")
@@ -256,44 +246,9 @@
         return url
 
     def join(self, relurl):
-        assert isinstance(relurl, RepositoryUrl)
-        cvsurl = copy.copy(self)
-        if relurl.path:
-            path = posixpath.normpath(relurl.path)
-            if path[:1] == "/":
-                newpath = path[1:]
-            else:
-                newpath = posixpath.join(cvsurl.path, relurl.path)
-            cvsurl.path = posixpath.normpath(newpath)
-        if relurl.tag:
-            cvsurl.tag = relurl.tag
-        return cvsurl
+        raise TypeError("this makes no sense!")
 
 
-class RepositoryUrl(UrlBase):
-    """Parsed representation of a ``repository:`` URL.
-
-    :ivar path: Path the the identified resource.  This may be either
-      an absolute path (starting with ``/``) or a relative path.  The
-      path is written using POSIX notation.
-    :type path: `str` or `None`
-
-    :ivar tag: Tag that should be referenced in the repository.
-    :type tag: `str` or `None`
-
-    """
-
-    def __init__(self, path, tag=None):
-        self.path = path or None
-        self.tag = tag or None
-
-    def getUrl(self):
-        url = "repository:" + (self.path or '')
-        if self.tag:
-            url = "%s:%s" % (url, self.tag)
-        return url
-
-
 class CvsLoader:
 
     def load(self, cvsurl, workdir):

Modified: zpkgtools/trunk/zpkgtools/locationmap.py
===================================================================
--- zpkgtools/trunk/zpkgtools/locationmap.py	2005-08-11 20:26:33 UTC (rev 37876)
+++ zpkgtools/trunk/zpkgtools/locationmap.py	2005-08-11 20:26:45 UTC (rev 37877)
@@ -132,8 +132,11 @@
                         parts[2] = posixpath.join("", suffix)
                     return urlparse.urlunsplit(parts)
                 else:
-                    pathpart = cvsloader.RepositoryUrl(suffix)
-                    parsed = parsed.join(pathpart)
+                    if isinstance(parsed, cvsloader.CvsUrl):
+                        parsed.path = posixpath.join(parsed.path, suffix)
+                    else:
+                        pathpart = RelativePath(suffix)
+                        parsed = parsed.join(pathpart)
                     return get_template_url(parsed)
         return None
 
@@ -141,7 +144,12 @@
         """Return true iff we already have a wildcard for key."""
         return key in self._wildcards
 
+class RelativePath:
+    def __init__(self, path):
+        self.tag = None
+        self.path = path
 
+
 class MapLoader:
 
     def __init__(self, base, filename, mapping):
@@ -166,15 +174,6 @@
             # conventional URL
             if self.cvsbase is None:
                 url = urlparse.urljoin(self.base, url)
-        else:
-            if isinstance(cvsurl, cvsloader.RepositoryUrl):
-                if self.cvsbase is None:
-                    raise MapLoadingError(
-                        "repository: URLs are not supported"
-                        " without a cvs: or Subversion base URL",
-                        self.filename)
-                cvsurl = self.cvsbase.join(cvsurl)
-                url = get_template_url(cvsurl)
 
         if resource in self.local_entries:
             _logger.warn(

Modified: zpkgtools/trunk/zpkgtools/tests/test_cvsloader.py
===================================================================
--- zpkgtools/trunk/zpkgtools/tests/test_cvsloader.py	2005-08-11 20:26:33 UTC (rev 37876)
+++ zpkgtools/trunk/zpkgtools/tests/test_cvsloader.py	2005-08-11 20:26:45 UTC (rev 37877)
@@ -65,103 +65,6 @@
         self.assertEqual(cvsurl.getUrl(),
                          "cvs://myuser:[email protected]/cvsroot:module:TAG")
 
-    def test_repository_getUrl(self):
-        repo = cvsloader.RepositoryUrl("/absolute/path")
-        self.assertEqual(repo.getUrl(), "repository:/absolute/path")
-        repo.tag = "TAG"
-        self.assertEqual(repo.getUrl(), "repository:/absolute/path:TAG")
-        repo.path = None
-        self.assertEqual(repo.getUrl(), "repository::TAG")
-        repo.tag = None
-        self.assertEqual(repo.getUrl(), "repository:")
-
-    def test_repository_join_absolute_path(self):
-        repo = cvsloader.RepositoryUrl("/absolute/path")
-        cvsurl = cvsloader.CvsUrl("", "cvs.example.org", "/cvsroot",
-                                  "project/module")
-        result = cvsurl.join(repo)
-        self.assert_(not result.type)
-        self.assertEqual(result.host, "cvs.example.org")
-        self.assertEqual(result.cvsroot, "/cvsroot")
-        self.assertEqual(result.path, "absolute/path")
-        self.assert_(not result.tag)
-
-        cvsurl.tag = "TAG"
-        result = cvsurl.join(repo)
-        self.assert_(not result.type)
-        self.assertEqual(result.host, "cvs.example.org")
-        self.assertEqual(result.cvsroot, "/cvsroot")
-        self.assertEqual(result.path, "absolute/path")
-        self.assertEqual(result.tag, "TAG")
-
-        repo.tag = "FOO"
-        result = cvsurl.join(repo)
-        self.assertEqual(result.path, "absolute/path")
-        self.assertEqual(result.tag, "FOO")
-
-        cvsurl.tag = None
-        result = cvsurl.join(repo)
-        self.assertEqual(result.path, "absolute/path")
-        self.assertEqual(result.tag, "FOO")
-
-    def test_repository_join_relative_path(self):
-        repo = cvsloader.RepositoryUrl("relative/path")
-        cvsurl = cvsloader.CvsUrl("", "cvs.example.org", "/cvsroot",
-                                  "project/module")
-        result = cvsurl.join(repo)
-        self.assert_(not result.type)
-        self.assertEqual(result.host, "cvs.example.org")
-        self.assertEqual(result.cvsroot, "/cvsroot")
-        self.assertEqual(result.path, "project/module/relative/path")
-        self.assert_(not result.tag)
-
-        cvsurl.tag = "TAG"
-        result = cvsurl.join(repo)
-        self.assert_(not result.type)
-        self.assertEqual(result.host, "cvs.example.org")
-        self.assertEqual(result.cvsroot, "/cvsroot")
-        self.assertEqual(result.path, "project/module/relative/path")
-        self.assertEqual(result.tag, "TAG")
-
-        repo.tag = "FOO"
-        result = cvsurl.join(repo)
-        self.assertEqual(result.path, "project/module/relative/path")
-        self.assertEqual(result.tag, "FOO")
-
-        cvsurl.tag = None
-        result = cvsurl.join(repo)
-        self.assertEqual(result.path, "project/module/relative/path")
-        self.assertEqual(result.tag, "FOO")
-
-    def test_repository_join_without_path(self):
-        repo = cvsloader.RepositoryUrl(None)
-        cvsurl = cvsloader.CvsUrl("", "cvs.example.org", "/cvsroot",
-                                  "project/module")
-        result = cvsurl.join(repo)
-        self.assert_(not result.type)
-        self.assertEqual(result.host, "cvs.example.org")
-        self.assertEqual(result.cvsroot, "/cvsroot")
-        self.assertEqual(result.path, "project/module")
-        self.assert_(not result.tag)
-
-        cvsurl.tag = "TAG"
-        result = cvsurl.join(repo)
-        self.assert_(not result.type)
-        self.assertEqual(result.host, "cvs.example.org")
-        self.assertEqual(result.cvsroot, "/cvsroot")
-        self.assertEqual(result.path, "project/module")
-        self.assertEqual(result.tag, "TAG")
-
-        repo.tag = "FOO"
-        result = cvsurl.join(repo)
-        self.assertEqual(result.path, "project/module")
-        self.assertEqual(result.tag, "FOO")
-
-        cvsurl.tag = None
-        result = cvsurl.join(repo)
-        self.assertEqual(result.path, "project/module")
-        self.assertEqual(result.tag, "FOO")
-
     def test_parse_cvs(self):
         def check(url,
                   type, username, password, host, cvsroot, path, tag):
@@ -212,40 +115,8 @@
         self.assertRaises(ValueError,
                           cvsloader.parse, "cvs://")
 
-    def test_parse_repository(self):
-        def check(url, path, tag):
-            cvsurl = cvsloader.parse(url)
-            self.assert_(isinstance(cvsurl, cvsloader.RepositoryUrl))
-            self.assertEqual(cvsurl.path, path)
-            self.assertEqual(cvsurl.tag, tag)
-
-        check("repository:path/to/some/file.txt",
-              "path/to/some/file.txt", None)
-
-        check("repository:/some/path/",
-              "/some/path/", None)
-
-        check("repository:path/to/some/file.txt:TAG",
-              "path/to/some/file.txt", "TAG")
-
-        check("repository:/some/path/:TAG",
-              "/some/path/", "TAG")
-
-        check("repository::TAG",
-              None, "TAG")
-
-        check("repository::",
-              None, None)
-
-        check("repository:",
-              None, None)
-
-        # Too many parts:
-        self.assertRaises(ValueError,
-                          cvsloader.parse, "repository:path:TAG:junk")
-
     def test_parse_invalid(self):
-        # Scheme isn't "cvs" or "repository":
+        # Scheme isn't "cvs":
         self.assertRaises(ValueError,
                           cvsloader.parse, "http://www.example.org/")
 

Modified: zpkgtools/trunk/zpkgtools/tests/test_loader.py
===================================================================
--- zpkgtools/trunk/zpkgtools/tests/test_loader.py	2005-08-11 20:26:33 UTC (rev 37876)
+++ zpkgtools/trunk/zpkgtools/tests/test_loader.py	2005-08-11 20:26:45 UTC (rev 37877)
@@ -52,13 +52,6 @@
         # cvs:
         eq(convert("cvs://cvs.example.org/cvsroot:module"),
            "cvs://cvs.example.org/cvsroot:module:TAG")
-        # repository:
-        eq(convert("repository::"),
-           "repository::TAG")
-        eq(convert("repository:path"),
-           "repository:path:TAG")
-        eq(convert("repository:/some/path/:"),
-           "repository:/some/path/:TAG")
         # Subversion:
         self.check_changing_subversion_urls("svn", "svn.example.org")
         self.check_changing_subversion_urls("svn+ssh", "svn.example.org")
@@ -93,10 +86,6 @@
            "file:///path/to/somewhere.py")
         eq(convert("cvs://cvs.example.org/cvsroot:path/:tag"),
            "cvs://cvs.example.org/cvsroot:path/:tag")
-        eq(convert("repository:path/:tag"),
-           "repository:path/:tag")
-        eq(convert("repository:/some/path/:tag"),
-           "repository:/some/path/:tag")
         eq(convert("svn://example.org/path/to/svnroot/tags/foo/file.txt"),
            "svn://example.org/path/to/svnroot/tags/foo/file.txt")
         eq(convert("svn://example.org/path/to/svnroot/branches/foo/file.txt"),

Modified: zpkgtools/trunk/zpkgtools/tests/test_locationmap.py
===================================================================
--- zpkgtools/trunk/zpkgtools/tests/test_locationmap.py	2005-08-11 20:26:33 UTC (rev 37876)
+++ zpkgtools/trunk/zpkgtools/tests/test_locationmap.py	2005-08-11 20:26:45 UTC (rev 37877)
@@ -42,17 +42,6 @@
 
     """ % (PREFIX, PREFIX, PREFIX, PREFIX)
 
-SAMPLE_INPUT_WITH_REPOSITORY_URLS = """
-    # This is a comment.
-
-    zope             repository:/Zope3/src/zope
-    zope.app         repository:/Zope3/src/zope/app
-    ZConfig          repository:/Packages/ZConfig
-    NotReal          repository:something/relative:TAG
-    file:README.txt  http://www.example.com/README.txt
-
-    """
-
 EXPECTED_OUTPUT = {
     "zope":             PREFIX + "Zope3/src/zope",
     "zope.app":         PREFIX + "Zope3/src/zope/app",
@@ -91,13 +80,6 @@
         d["ZConfig"] = EXPECTED_OUTPUT["ZConfig"]
         self.check_sample_results(d)
 
-    def test_load_with_cvs_base(self):
-        sio = StringIO(SAMPLE_INPUT_WITH_REPOSITORY_URLS)
-        locationmap.load(
-            sio, "cvs://cvs.example.org:ext/cvsroot:module",
-            self.mapping)
-        self.check_sample_results(self.mapping)
-
     def test_fromPathOrUrl_with_url(self):
         dirname = os.path.dirname(os.path.abspath(__file__))
         dirname = os.path.join(dirname, "input")
@@ -136,9 +118,6 @@
         self.assertEqual(d, EXPECTED_OUTPUT)
         self.failIf("NotThere" in mapping)
 
-    def test_repository_without_cvsbase(self):
-        self.check_error("package.module  repository:yeah/right")
-
     def test_malformed_lines(self):
         self.check_error("package-without-location")
         self.check_error("package location junk")

Modified: zpkgtools/trunk/zpkgtools/tests/test_svnloader.py
===================================================================
--- zpkgtools/trunk/zpkgtools/tests/test_svnloader.py	2005-08-11 20:26:33 UTC (rev 37876)
+++ zpkgtools/trunk/zpkgtools/tests/test_svnloader.py	2005-08-11 20:26:45 UTC (rev 37877)
@@ -161,69 +161,6 @@
         eq(split("/tags/foo/file.txt"), ("", "file.txt", "foo"))
         eq(split("/tags/*/file.txt"),   ("", "file.txt", None))
 
-    def test_join_with_path(self):
-        URL = self.mkurl("/tags/*/path")
-        repo = cvsloader.parse("repository:more/path")
-        svnurl = svnloader.parse(URL)
-        newurl = svnurl.join(repo)
-        self.assertEqual(newurl.tag, None)
-        self.assertEqual(newurl.prefix, self.mkurl(""))
-        self.assertEqual(newurl.tail, "path/more/path")
-
-    def test_join_with_path_and_new_tag(self):
-        eq = self.assertEqual
-
-        URL = self.mkurl("/tags/*/path")
-        repo = cvsloader.parse("repository:more/path:TAG")
-        svnurl = svnloader.parse(URL)
-        newurl = svnurl.join(repo)
-        eq(newurl.tag, "TAG")
-        eq(newurl.prefix, self.mkurl(""))
-        eq(newurl.tail, "path/more/path")
-        eq(newurl.getUrl(), self.mkurl("/tags/TAG/path/more/path"))
-
-        repo = cvsloader.parse("repository:more/path:HEAD")
-        svnurl = svnloader.parse(URL)
-        newurl = svnurl.join(repo)
-        eq(newurl.tag, "HEAD")
-        eq(newurl.prefix, self.mkurl(""))
-        eq(newurl.tail, "path/more/path")
-        eq(newurl.getUrl(), self.mkurl("/trunk/path/more/path"))
-
-    def test_join_with_just_new_tag(self):
-        eq = self.assertEqual
-        svnroot = self.mkurl("")
-
-        # join with a changed tag:
-        URL = self.mkurl("/tags/*/file.txt")
-        repo = cvsloader.parse("repository::FOO")
-        svnurl = svnloader.parse(URL)
-        newurl = svnurl.join(repo)
-        eq(newurl.tag, "FOO")
-        eq(newurl.prefix, svnroot)
-        eq(newurl.tail, "file.txt")
-        eq(newurl.getUrl(), self.mkurl("/tags/FOO/file.txt"))
-
-        # join, changing the tag to the HEAD:
-        URL = self.mkurl("/tags/*/file.txt")
-        repo = cvsloader.parse("repository::HEAD")
-        svnurl = svnloader.parse(URL)
-        newurl = svnurl.join(repo)
-        eq(newurl.tag, "HEAD")
-        eq(newurl.prefix, svnroot)
-        eq(newurl.tail, "file.txt")
-        eq(newurl.getUrl(), self.mkurl("/trunk/file.txt"))
-
-        # join, changing the tag from the HEAD:
-        URL = self.mkurl("/trunk/file.txt")
-        repo = cvsloader.parse("repository::FOO")
-        svnurl = svnloader.parse(URL)
-        newurl = svnurl.join(repo)
-        eq(newurl.tag, "FOO")
-        eq(newurl.prefix, svnroot)
-        eq(newurl.tail, "file.txt")
-        eq(newurl.getUrl(), self.mkurl("/tags/FOO/file.txt"))
-
     def test_is_subversion_url(self):
         note = " (repo in %s)" % self.SVNROOT
         def check(path):

_______________________________________________
Zope-CVS maillist  -  [email protected]
http://mail.zope.org/mailman/listinfo/zope-cvs

Zope CVS instructions: http://dev.zope.org/CVS
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.