53
56
except errors.UninitializableFormat:
54
57
raise tests.TestNotApplicable(
55
58
'Control dir does not support creating new branches.')
56
made_repo = made_control.create_repository()
59
made_control.create_repository()
57
60
made_branch = made_control.create_branch("colo")
58
self.assertIsInstance(made_branch, bzrlib.branch.Branch)
59
self.assertEqual(made_control, made_branch.bzrdir)
61
self.assertIsInstance(made_branch, Branch)
62
self.assertEquals("colo", made_branch.name)
63
self.assertEqual(made_control, made_branch.bzrdir)
65
def test_open_by_url(self):
66
# a bzrdir can construct a branch and repository for itself.
67
if not self.bzrdir_format.is_supported():
68
# unsupported formats are not loopback testable
69
# because the default open will not open them and
70
# they may not be initializable.
71
raise tests.TestNotApplicable('Control dir format not supported')
72
t = self.get_transport()
74
made_control = self.bzrdir_format.initialize(t.base)
75
except errors.UninitializableFormat:
76
raise tests.TestNotApplicable(
77
'Control dir does not support creating new branches.')
78
made_control.create_repository()
79
made_branch = made_control.create_branch(name="colo")
80
other_branch = made_control.create_branch(name="othercolo")
81
self.assertIsInstance(made_branch, Branch)
82
self.assertEqual(made_control, made_branch.bzrdir)
83
self.assertNotEqual(made_branch.user_url, other_branch.user_url)
84
self.assertNotEqual(made_branch.control_url, other_branch.control_url)
85
re_made_branch = Branch.open(made_branch.user_url)
86
self.assertEquals(re_made_branch.name, "colo")
87
self.assertEqual(made_branch.control_url, re_made_branch.control_url)
88
self.assertEqual(made_branch.user_url, re_made_branch.user_url)
90
def test_sprout_into_colocated(self):
91
# a bzrdir can construct a branch and repository for itself.
92
if not self.bzrdir_format.is_supported():
93
# unsupported formats are not loopback testable
94
# because the default open will not open them and
95
# they may not be initializable.
96
raise tests.TestNotApplicable('Control dir format not supported')
97
from_tree = self.make_branch_and_tree('from')
98
revid = from_tree.commit("rev1")
100
other_branch = self.make_branch("to")
101
except errors.UninitializableFormat:
102
raise tests.TestNotApplicable(
103
'Control dir does not support creating new branches.')
104
to_dir = from_tree.bzrdir.sprout(
105
urlutils.join_segment_parameters(
106
other_branch.bzrdir.user_url, {"branch": "target"}))
107
to_branch = to_dir.open_branch(name="target")
108
self.assertEquals(revid, to_branch.last_revision())
110
def test_unicode(self):
111
self.requireFeature(UnicodeFilenameFeature)
112
if not self.bzrdir_format.is_supported():
113
# unsupported formats are not loopback testable
114
# because the default open will not open them and
115
# they may not be initializable.
116
raise tests.TestNotApplicable('Control dir format not supported')
117
t = self.get_transport()
119
made_control = self.bzrdir_format.initialize(t.base)
120
except errors.UninitializableFormat:
121
raise tests.TestNotApplicable(
122
'Control dir does not support creating new branches.')
123
made_control.create_repository()
124
made_branch = made_control.create_branch(name=u"col\xe9")
126
u"col\xe9" in [b.name for b in made_control.list_branches()])
127
made_branch = Branch.open(made_branch.user_url)
128
self.assertEquals(u"col\xe9", made_branch.name)
129
made_control.destroy_branch(u"col\xe9")
131
def test_get_branches(self):
132
repo = self.make_repository('branch-1')
133
target_branch = repo.bzrdir.create_branch(name='foo')
134
self.assertEqual(['foo'], repo.bzrdir.get_branches().keys())
135
self.assertEqual(target_branch.base,
136
repo.bzrdir.get_branches()['foo'].base)
138
def test_branch_name_with_slash(self):
139
repo = self.make_repository('branch-1')
141
target_branch = repo.bzrdir.create_branch(name='foo/bar')
142
except errors.InvalidBranchName:
143
raise tests.TestNotApplicable(
144
"format does not support branches with / in their name")
145
self.assertEqual(['foo/bar'], repo.bzrdir.get_branches().keys())
147
target_branch.base, repo.bzrdir.open_branch(name='foo/bar').base)
149
def test_branch_reference(self):
150
referenced = self.make_branch('referenced')
151
repo = self.make_repository('repo')
153
repo.bzrdir.set_branch_reference(referenced, name='foo')
154
except errors.IncompatibleFormat:
155
raise tests.TestNotApplicable(
156
'Control dir does not support creating branch references.')
157
self.assertEquals(referenced.base,
158
repo.bzrdir.get_branch_reference('foo'))