Rev 459: Cope with reversed externals values. in file:///data/jelmer/bzr-svn/nestedtrees/

Jelmer Vernooij jelmer at samba.org
Tue Jul 8 04:02:17 BST 2008


At file:///data/jelmer/bzr-svn/nestedtrees/

------------------------------------------------------------
revno: 459
revision-id: jelmer at samba.org-20080708030215-x3gbq2lu9rdanmfs
parent: jelmer at samba.org-20080708015748-l572h74tazsw9izi
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: nestedtrees
timestamp: Tue 2008-07-08 05:02:15 +0200
message:
  Cope with reversed externals values.
modified:
  properties.py                  util.py-20080502170127-o220e9py99vt69s6-1
  tests/test_properties.py       test_properties.py-20080703215223-t5ydp87wwi7dtyas-1
=== modified file 'properties.py'
--- a/properties.py	2008-07-04 08:54:31 +0000
+++ b/properties.py	2008-07-08 03:02:15 +0000
@@ -56,6 +56,8 @@
               as value. revnum is the revision number and is 
               set to None if not applicable.
     """
+    def is_url(u):
+        return ("://" in u)
     ret = {}
     for l in val.splitlines():
         if l == "" or l[0] == "#":
@@ -64,15 +66,28 @@
         if len(pts) == 3:
             if not pts[1].startswith("-r"):
                 raise InvalidExternalsDescription()
-            ret[pts[0]] = (int(pts[1][2:]), urlutils.join(base_url, pts[2]))
+            revno = int(pts[1][2:])
+            if not is_url(pts[0]):
+                relurl = pts[2]
+                path = pts[0]
+            else:
+                relurl = pts[0]
+                path = pts[2]
         elif len(pts) == 2:
-            if pts[1].startswith("//"):
-                raise NotImplementedError("Relative to the scheme externals not yet supported")
-            if pts[1].startswith("^/"):
-                raise NotImplementedError("Relative to the repository root externals not yet supported")
-            ret[pts[0]] = (None, urlutils.join(base_url, pts[1]))
+            if not is_url(pts[0]):
+                relurl = pts[1]
+                path = pts[0]
+            else:
+                relurl = pts[0]
+                path = pts[1]
+            revno = None
         else:
             raise InvalidExternalsDescription()
+        if relurl.startswith("//"):
+            raise NotImplementedError("Relative to the scheme externals not yet supported")
+        if relurl.startswith("^/"):
+            raise NotImplementedError("Relative to the repository root externals not yet supported")
+        ret[path] = (revno, urlutils.join(base_url, relurl))
     return ret
 
 

=== modified file 'tests/test_properties.py'
--- a/tests/test_properties.py	2008-07-04 08:54:31 +0000
+++ b/tests/test_properties.py	2008-07-08 03:02:15 +0000
@@ -48,6 +48,12 @@
 third-party/skins              http://skins.red-bean.com/repositories/skinproj
 third-party/skins/toolkit -r21 http://svn.red-bean.com/repos/skin-maker"""))
 
+    def test_parse_externals_swapped(self):
+        self.assertEqual({'third-party/sounds': (None, "http://sounds.red-bean.com/repos")},
+            properties.parse_externals_description("http://example.com",
+"""http://sounds.red-bean.com/repos         third-party/sounds
+"""))
+
     def test_parse_comment(self):
         self.assertEqual({
             'third-party/sounds': (None, "http://sounds.red-bean.com/repos")




More information about the bazaar-commits mailing list