19
19
from bzrlib import urlutils
20
20
from bzrlib.branch import Branch
21
21
from bzrlib.bzrdir import BzrDir
22
from bzrlib.errors import NoSuchFile, NoSuchRevision, NotBranchError
22
from bzrlib.errors import NoSuchFile, NoSuchRevision, NotBranchError, NoSuchTag
23
23
from bzrlib.repository import Repository
24
24
from bzrlib.revision import NULL_REVISION
25
25
from bzrlib.trace import mutter
46
47
branch = Branch.open(repos_url)
47
48
self.assertEqual("", branch.get_branch_path())
50
def test_tags_dict(self):
51
repos_url = self.make_repository("a")
53
dc = self.get_commit_editor(repos_url)
54
tags = dc.add_dir("tags")
55
tags.add_dir("tags/foo")
59
b = Branch.open(repos_url + "/trunk")
60
self.assertEquals(["foo"], b.tags.get_tag_dict().keys())
62
def test_tag_set(self):
63
repos_url = self.make_repository('a')
65
dc = self.get_commit_editor(repos_url)
70
dc = self.get_commit_editor(repos_url)
71
trunk = dc.open_dir("trunk")
72
trunk.add_file("trunk/bla").modify()
75
b = Branch.open(repos_url + "/trunk")
76
b.tags.set_tag("mytag", b.repository.generate_revision_id(1, "trunk", b.repository.get_mapping()))
78
self.assertEquals(core.NODE_DIR,
79
b.repository.transport.check_path("tags/mytag", 3))
81
def test_tags_delete(self):
82
repos_url = self.make_repository("a")
84
dc = self.get_commit_editor(repos_url)
85
tags = dc.add_dir("tags")
86
tags.add_dir("tags/foo")
90
b = Branch.open(repos_url + "/trunk")
91
self.assertEquals(["foo"], b.tags.get_tag_dict().keys())
92
b.tags.delete_tag("foo")
93
b = Branch.open(repos_url + "/trunk")
94
self.assertEquals([], b.tags.get_tag_dict().keys())
96
def test_tag_lookup(self):
97
repos_url = self.make_repository("a")
99
dc = self.get_commit_editor(repos_url)
100
tags = dc.add_dir("tags")
101
tags.add_dir("tags/foo")
105
b = Branch.open(repos_url + "/trunk")
106
self.assertEquals(b.repository.generate_revision_id(1, "tags/foo", b.repository.get_mapping()), b.tags.lookup_tag("foo"))
108
def test_tag_lookup_nonexistant(self):
109
repos_url = self.make_repository("a")
111
dc = self.get_commit_editor(repos_url)
115
b = Branch.open(repos_url + "/trunk")
116
self.assertRaises(NoSuchTag, b.tags.lookup_tag, "foo")
118
def test_tags_delete_nonexistent(self):
119
repos_url = self.make_repository("a")
121
dc = self.get_commit_editor(repos_url)
125
b = Branch.open(repos_url + "/trunk")
126
self.assertRaises(NoSuchTag, b.tags.delete_tag, "foo")
49
128
def test_get_branch_path_old(self):
50
129
repos_url = self.make_repository("a")