Rev 1546: Support obtaining tag and branch paths for trunk schemes where level > 0. in http://people.samba.org/bzr/jelmer/bzr-svn/trunk

Jelmer Vernooij jelmer at samba.org
Sun Aug 3 15:54:14 BST 2008


At http://people.samba.org/bzr/jelmer/bzr-svn/trunk

------------------------------------------------------------
revno: 1546
revision-id: jelmer at samba.org-20080803145412-rye8lxuww7orgh5m
parent: jelmer at samba.org-20080803002744-ldwouhqqbftwz5g8
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.4
timestamp: Sun 2008-08-03 16:54:12 +0200
message:
  Support obtaining tag and branch paths for trunk schemes where level > 0.
modified:
  mapping3/__init__.py           __init__.py-20080502174630-9324zh25kka98vlw-1
  mapping3/scheme.py             scheme.py-20060516195850-95181aae6b272f9e
  tests/test_scheme.py           test_scheme.py-20060621221855-va2xabhlxpmc9llx-1
=== modified file 'mapping3/__init__.py'
--- a/mapping3/__init__.py	2008-08-02 14:44:01 +0000
+++ b/mapping3/__init__.py	2008-08-03 14:54:12 +0000
@@ -110,7 +110,10 @@
         return self._get_root_paths(revnum, self.scheme.is_tag, project, pb)
 
     def get_tag_path(self, name, project=""):
-        return self.scheme.get_tag_path(name)
+        return self.scheme.get_tag_path(name, project)
+
+    def get_branch_path(self, name, project=""):
+        return self.scheme.get_branch_path(name, project)
 
     def is_branch_parent(self, path):
         # Na, na, na...

=== modified file 'mapping3/scheme.py'
--- a/mapping3/scheme.py	2008-07-23 00:35:03 +0000
+++ b/mapping3/scheme.py	2008-08-03 14:54:12 +0000
@@ -260,20 +260,23 @@
              "*/" * level + "branches/*",
              "*/" * level + "tags/*"])
 
-    def get_tag_path(self, name):
-        # Only implemented for level 0
-        if self.level == 0:
+    def get_tag_path(self, name, project=""):
+        if project == "":
             return urlutils.join("tags", name)
-        raise NotImplementedError
+        return urlutils.join(project, "tags", name)
 
-    def get_branch_path(self, name):
+    def get_branch_path(self, name, project=""):
         # Only implemented for level 0
-        if self.level == 0:
-            if name == "trunk":
+        if name == "trunk":
+            if project == "":
                 return "trunk"
             else:
+                return urlutils.join(project, "trunk")
+        else:
+            if project == "":
                 return urlutils.join("branches", name)
-        raise NotImplementedError
+            else:
+                return urlutils.join(project, "branches", name)
 
     def is_branch(self, path):
         """See BranchingScheme.is_branch()."""

=== modified file 'tests/test_scheme.py'
--- a/tests/test_scheme.py	2008-07-23 00:35:03 +0000
+++ b/tests/test_scheme.py	2008-08-03 14:54:12 +0000
@@ -451,8 +451,8 @@
                           TrunkBranchingScheme().get_tag_path("foo"))
 
     def test_get_tag_path_nonzero(self):
-        self.assertRaises(NotImplementedError,
-                          TrunkBranchingScheme(2).get_tag_path, "foo")
+        self.assertEquals("my/project/tags/foo",
+                          TrunkBranchingScheme(2).get_tag_path("foo", "my/project"))
 
     def test_get_branch_path_zero(self):
         self.assertEquals("branches/foo", 
@@ -463,8 +463,8 @@
                           TrunkBranchingScheme().get_branch_path("trunk"))
 
     def test_get_branch_path_nonzero(self):
-        self.assertRaises(NotImplementedError,
-                          TrunkBranchingScheme(2).get_branch_path, "foo")
+        self.assertEquals("my/project/branches/foo",
+                          TrunkBranchingScheme(2).get_branch_path("foo", "my/project"))
 
 
 




More information about the bazaar-commits mailing list