Rev 2265: Fix assertion error when pushing tags to a repository layout that doesn't support them. in http://people.samba.org/bzr/jelmer/bzr-svn/0.5

Jelmer Vernooij jelmer at samba.org
Mon Dec 15 23:51:38 GMT 2008


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

------------------------------------------------------------
revno: 2265
revision-id: jelmer at samba.org-20081215235135-wl13bpw13bqo4gvy
parent: jelmer at samba.org-20081214053411-yqie8jclpthvm1ny
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: 0.5
timestamp: Tue 2008-12-16 00:51:35 +0100
message:
  Fix assertion error when pushing tags to a repository layout that doesn't support them.
modified:
  branch.py                      svnbranch.py-20051017135706-11c749eb0dab04a7
  tests/test_branch.py           test_branch.py-20060508162215-74ffeb5d608f8e20
=== modified file 'branch.py'
--- a/branch.py	2008-12-07 20:36:39 +0000
+++ b/branch.py	2008-12-15 23:51:35 +0000
@@ -77,12 +77,12 @@
         """
         self.repository = repository
         self._format = SvnBranchFormat()
+        self.layout = self.repository.get_layout()
         assert isinstance(self.repository, SvnRepository)
         super(SvnBranch, self).__init__(mapping or self.repository.get_mapping())
         self.control_files = FakeControlFiles()
         self._lock_mode = None
         self._lock_count = 0
-        self.layout = self.repository.get_layout()
         self._branch_path = branch_path.strip("/")
         self.base = urlutils.join(self.repository.base, 
                         self._branch_path).rstrip("/")
@@ -106,6 +106,12 @@
         if type not in ('branch', 'tag') or ip != '':
             raise NotBranchError(branch_path)
 
+    def supports_tags(self):
+        """See Branch.supports_tags()."""
+        return (self._format.supports_tags() and 
+                self.mapping.supports_tags() and
+                self.layout.supports_tags())
+
     def _make_tags(self):
         if self.supports_tags():
             return SubversionTags(self)

=== modified file 'tests/test_branch.py'
--- a/tests/test_branch.py	2008-11-12 19:49:51 +0000
+++ b/tests/test_branch.py	2008-12-15 23:51:35 +0000
@@ -19,7 +19,7 @@
 from bzrlib import urlutils
 from bzrlib.branch import Branch
 from bzrlib.bzrdir import BzrDir
-from bzrlib.errors import NoSuchFile, NoSuchRevision, NotBranchError, NoSuchTag
+from bzrlib.errors import NoSuchFile, NoSuchRevision, NotBranchError, NoSuchTag, TagsNotSupported
 from bzrlib.repository import Repository
 from bzrlib.revision import NULL_REVISION
 from bzrlib.trace import mutter
@@ -91,6 +91,19 @@
         b = Branch.open(repos_url + "/trunk")
         self.assertEquals([], b.tags.get_tag_dict().keys())
 
+    def test_tag_set_not_supported(self):
+        repos_url = self.make_repository('a')
+
+        dc = self.get_commit_editor(repos_url)
+        trunk = dc.add_dir("trunk")
+        trunk.add_dir("trunk/gui")
+        dc.close()
+
+        b = Branch.open(repos_url + "/trunk/gui")
+        self.assertRaises(TagsNotSupported,
+                b.tags.set_tag, u"mytag", 
+                b.repository.generate_revision_id(1, "trunk/gui", b.repository.get_mapping()))
+
     def test_tag_lookup(self):
         repos_url = self.make_repository("a")
        




More information about the bazaar-commits mailing list