Rev 1453: Merge properties code improvements. in http://people.samba.org/bzr/jelmer/bzr-svn/trunk
Jelmer Vernooij
jelmer at samba.org
Tue Jul 8 14:21:44 BST 2008
At http://people.samba.org/bzr/jelmer/bzr-svn/trunk
------------------------------------------------------------
revno: 1453
revision-id: jelmer at samba.org-20080708132143-ge6ulosbu931e1gc
parent: jelmer at samba.org-20080708005739-cvii1sajo4edx4zx
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Tue 2008-07-08 15:21:43 +0200
message:
Merge properties code improvements.
modified:
format.py format.py-20070917005147-94kb7zysotf82kqw-1
properties.py util.py-20080502170127-o220e9py99vt69s6-1
tests/test_properties.py test_properties.py-20080703215223-t5ydp87wwi7dtyas-1
=== modified file 'format.py'
--- a/format.py 2008-06-30 13:38:04 +0000
+++ b/format.py 2008-07-08 13:21:43 +0000
@@ -34,12 +34,23 @@
if format.repository_format.rich_root_data:
return format
# Default format does not support rich root data,
- # fall back to rich-root
+ # fall back to rich-root-pack
format = format_registry.make_bzrdir('rich-root-pack')
assert format.repository_format.rich_root_data
return format
+def get_nested_tree_format():
+ format = BzrDirFormat.get_default_format()
+ if format.repository_format.supports_tree_reference:
+ return format
+ # Default format does not support rich root data,
+ # fall back to pack-0.92-subtree
+ format = format_registry.make_bzrdir('pack-0.92-subtree')
+ assert format.repository_format.supports_tree_reference
+ return format
+
+
class SvnRemoteFormat(BzrDirFormat):
"""Format for the Subversion smart server."""
_lock_class = TransportLock
=== modified file 'properties.py'
--- a/properties.py 2008-07-04 08:54:31 +0000
+++ b/properties.py 2008-07-08 13:21:43 +0000
@@ -56,23 +56,50 @@
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] == "#":
continue
- pts = l.rsplit(None, 2)
- 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]))
+ pts = l.rsplit(None, 3)
+ if len(pts) == 4:
+ if pts[0] == "-r": # -r X URL DIR
+ revno = int(pts[1])
+ path = pts[3]
+ relurl = pts[2]
+ elif pts[1] == "-r": # DIR -r X URL
+ revno = int(pts[2])
+ path = pts[0]
+ relurl = pts[3]
+ else:
+ raise InvalidExternalsDescription()
+ elif len(pts) == 3:
+ if pts[1].startswith("-r"): # DIR -rX URL
+ revno = int(pts[1][2:])
+ path = pts[0]
+ relurl = pts[2]
+ elif pts[0].startswith("-r"): # -rX URL DIR
+ revno = int(pts[0][2:])
+ path = pts[2]
+ relurl = pts[1]
+ else:
+ raise InvalidExternalsDescription()
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 13:21:43 +0000
@@ -48,6 +48,18 @@
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_space_revno(self):
+ self.assertEqual({
+ 'third-party/skins/toolkit': (21, "http://svn.red-bean.com/repos/skin-maker")},
+ properties.parse_externals_description("http://example.com",
+"""third-party/skins/toolkit -r 21 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