~jelmer/bzr-svn/svn-1.5

« back to all changes in this revision

Viewing changes to tests/test_branch.py

  • Committer: Jelmer Vernooij
  • Date: 2008-07-07 11:29:11 UTC
  • mfrom: (1196.1.245 0.4)
  • Revision ID: jelmer@samba.org-20080707112911-fca6wpxr457n690x
MergeĀ 0.4.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
27
27
import os
28
28
from unittest import TestCase
29
29
 
 
30
from bzrlib.plugins.svn import core
30
31
from bzrlib.plugins.svn.branch import FakeControlFiles, SvnBranchFormat
31
32
from bzrlib.plugins.svn.convert import load_dumpfile
32
33
from bzrlib.plugins.svn.mapping import SVN_PROP_BZR_REVISION_ID
46
47
        branch = Branch.open(repos_url)
47
48
        self.assertEqual("", branch.get_branch_path())
48
49
 
 
50
    def test_tags_dict(self):
 
51
        repos_url = self.make_repository("a")
 
52
       
 
53
        dc = self.get_commit_editor(repos_url)
 
54
        tags = dc.add_dir("tags")
 
55
        tags.add_dir("tags/foo")
 
56
        dc.add_dir("trunk")
 
57
        dc.close()
 
58
 
 
59
        b = Branch.open(repos_url + "/trunk")
 
60
        self.assertEquals(["foo"], b.tags.get_tag_dict().keys())
 
61
 
 
62
    def test_tag_set(self):
 
63
        repos_url = self.make_repository('a')
 
64
 
 
65
        dc = self.get_commit_editor(repos_url)
 
66
        dc.add_dir("trunk")
 
67
        dc.add_dir("tags")
 
68
        dc.close()
 
69
 
 
70
        dc = self.get_commit_editor(repos_url)
 
71
        trunk = dc.open_dir("trunk")
 
72
        trunk.add_file("trunk/bla").modify()
 
73
        dc.close()
 
74
 
 
75
        b = Branch.open(repos_url + "/trunk")
 
76
        b.tags.set_tag("mytag", b.repository.generate_revision_id(1, "trunk", b.repository.get_mapping()))
 
77
 
 
78
        self.assertEquals(core.NODE_DIR, 
 
79
                b.repository.transport.check_path("tags/mytag", 3))
 
80
 
 
81
    def test_tags_delete(self):
 
82
        repos_url = self.make_repository("a")
 
83
       
 
84
        dc = self.get_commit_editor(repos_url)
 
85
        tags = dc.add_dir("tags")
 
86
        tags.add_dir("tags/foo")
 
87
        dc.add_dir("trunk")
 
88
        dc.close()
 
89
 
 
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())
 
95
 
 
96
    def test_tag_lookup(self):
 
97
        repos_url = self.make_repository("a")
 
98
       
 
99
        dc = self.get_commit_editor(repos_url)
 
100
        tags = dc.add_dir("tags")
 
101
        tags.add_dir("tags/foo")
 
102
        dc.add_dir("trunk")
 
103
        dc.close()
 
104
 
 
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"))
 
107
 
 
108
    def test_tag_lookup_nonexistant(self):
 
109
        repos_url = self.make_repository("a")
 
110
 
 
111
        dc = self.get_commit_editor(repos_url)
 
112
        dc.add_dir("trunk")
 
113
        dc.close()
 
114
       
 
115
        b = Branch.open(repos_url + "/trunk")
 
116
        self.assertRaises(NoSuchTag, b.tags.lookup_tag, "foo")
 
117
 
 
118
    def test_tags_delete_nonexistent(self):
 
119
        repos_url = self.make_repository("a")
 
120
 
 
121
        dc = self.get_commit_editor(repos_url)
 
122
        dc.add_dir("trunk")
 
123
        dc.close()
 
124
       
 
125
        b = Branch.open(repos_url + "/trunk")
 
126
        self.assertRaises(NoSuchTag, b.tags.delete_tag, "foo")
 
127
 
49
128
    def test_get_branch_path_old(self):
50
129
        repos_url = self.make_repository("a")
51
130