Rev 448: Support relative urls. in file:///data/jelmer/bzr-svn/nestedtrees/
Jelmer Vernooij
jelmer at samba.org
Sat Jul 21 13:44:56 BST 2007
At file:///data/jelmer/bzr-svn/nestedtrees/
------------------------------------------------------------
revno: 448
revision-id: jelmer at samba.org-20070721124455-r5akzjt3vs70755w
parent: jelmer at samba.org-20070721123854-3h53w2qyfm6u3vqj
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: nestedtrees
timestamp: Sat 2007-07-21 14:44:55 +0200
message:
Support relative urls.
modified:
tests/test_tree.py test_tree.py-20070103204350-pr8nupes7e5sd2wr-1
tree.py tree.py-20060624222557-dudlwqcmkf22lt2s-1
=== modified file 'tests/test_tree.py'
--- a/tests/test_tree.py 2007-07-21 12:38:54 +0000
+++ b/tests/test_tree.py 2007-07-21 12:44:55 +0000
@@ -110,7 +110,7 @@
'third-party/sounds': (None, "http://sounds.red-bean.com/repos"),
'third-party/skins': (None, "http://skins.red-bean.com/repositories/skinproj"),
'third-party/skins/toolkit': (21, "http://svn.red-bean.com/repos/skin-maker")},
- parse_externals_description(
+ parse_externals_description("http://example.com",
"""third-party/sounds http://sounds.red-bean.com/repos
third-party/skins http://skins.red-bean.com/repositories/skinproj
third-party/skins/toolkit -r21 http://svn.red-bean.com/repos/skin-maker"""))
@@ -119,22 +119,29 @@
self.assertEqual({
'third-party/sounds': (None, "http://sounds.red-bean.com/repos")
},
- parse_externals_description(
+ parse_externals_description("http://example.com/",
"""
third-party/sounds http://sounds.red-bean.com/repos
#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_relative(self):
+ self.assertEqual({
+ 'third-party/sounds': (None, "http://example.com/branches/other"),
+ },
+ parse_externals_description("http://example.com/trunk",
+"third-party/sounds ../branches/other"))
+
def test_parse_invalid_missing_url(self):
"""No URL specified."""
self.assertRaises(errors.InvalidExternalsDescription,
- lambda: parse_externals_description("bla"))
+ lambda: parse_externals_description("http://example.com/", "bla"))
def test_parse_invalid_too_much_data(self):
"""No URL specified."""
self.assertRaises(errors.InvalidExternalsDescription,
- lambda: parse_externals_description("bla -R40 http://bla/"))
+ lambda: parse_externals_description(None, "bla -R40 http://bla/"))
class TestInventoryExternals(TestCaseWithSubversionRepository):
=== modified file 'tree.py'
--- a/tree.py 2007-07-21 12:38:54 +0000
+++ b/tree.py 2007-07-21 12:44:55 +0000
@@ -15,6 +15,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
"""Access to stored Subversion basis trees."""
+from bzrlib import urlutils
from bzrlib.branch import Branch
from bzrlib.inventory import Inventory, InventoryDirectory, TreeReference
@@ -32,9 +33,12 @@
import errors
-def parse_externals_description(val):
+def parse_externals_description(base_url, val):
"""Parse an svn:externals property value.
+ :param base_url: URL on which the property is set. Used for
+ relative externals.
+
:returns: dictionary with local names as keys, (revnum, url)
as value. revnum is the revision number and is
set to None if not applicable.
@@ -47,9 +51,9 @@
if len(pts) == 3:
if not pts[1].startswith("-r"):
raise errors.InvalidExternalsDescription()
- ret[pts[0]] = (int(pts[1][2:]), pts[2])
+ ret[pts[0]] = (int(pts[1][2:]), urlutils.join(base_url, pts[2]))
elif len(pts) == 2:
- ret[pts[0]] = (None, pts[1])
+ ret[pts[0]] = (None, urlutils.join(base_url, pts[1]))
else:
raise errors.InvalidExternalsDescription()
return ret
More information about the bazaar-commits
mailing list