201
201
self.make_branch_and_tree('bar')
204
class TestBranch6(TestCaseWithTransport):
204
class TestBranch67(object):
205
"""Common tests for both branch 6 and 7 which are mostly the same."""
207
def get_format_name(self):
208
raise NotImplementedError(self.get_format_name)
210
def get_format_name_subtree(self):
211
raise NotImplementedError(self.get_format_name)
214
raise NotImplementedError(self.get_class)
206
216
def test_creation(self):
207
217
format = BzrDirMetaFormat1()
208
218
format.set_branch_format(_mod_branch.BzrBranchFormat6())
209
219
branch = self.make_branch('a', format=format)
210
self.assertIsInstance(branch, _mod_branch.BzrBranch6)
211
branch = self.make_branch('b', format='dirstate-tags')
212
self.assertIsInstance(branch, _mod_branch.BzrBranch6)
220
self.assertIsInstance(branch, self.get_class())
221
branch = self.make_branch('b', format=self.get_format_name())
222
self.assertIsInstance(branch, self.get_class())
213
223
branch = _mod_branch.Branch.open('a')
214
self.assertIsInstance(branch, _mod_branch.BzrBranch6)
224
self.assertIsInstance(branch, self.get_class())
216
226
def test_layout(self):
217
branch = self.make_branch('a', format='dirstate-tags')
227
branch = self.make_branch('a', format=self.get_format_name())
218
228
self.failUnlessExists('a/.bzr/branch/last-revision')
219
229
self.failIfExists('a/.bzr/branch/revision-history')
221
231
def test_config(self):
222
232
"""Ensure that all configuration data is stored in the branch"""
223
branch = self.make_branch('a', format='dirstate-tags')
233
branch = self.make_branch('a', format=self.get_format_name())
224
234
branch.set_parent('http://bazaar-vcs.org')
225
235
self.failIfExists('a/.bzr/branch/parent')
226
236
self.assertEqual('http://bazaar-vcs.org', branch.get_parent())
250
260
def do_checkout_test(self, lightweight=False):
251
tree = self.make_branch_and_tree('source', format='dirstate-with-subtree')
261
tree = self.make_branch_and_tree('source',
262
format=self.get_format_name_subtree())
252
263
subtree = self.make_branch_and_tree('source/subtree',
253
format='dirstate-with-subtree')
264
format=self.get_format_name_subtree())
254
265
subsubtree = self.make_branch_and_tree('source/subtree/subsubtree',
255
format='dirstate-with-subtree')
266
format=self.get_format_name_subtree())
256
267
self.build_tree(['source/subtree/file',
257
268
'source/subtree/subsubtree/file'])
258
269
subsubtree.add('file')
296
307
'locations.conf')
310
class TestBranch6(TestBranch67, TestCaseWithTransport):
313
return _mod_branch.BzrBranch6
315
def get_format_name(self):
316
return "dirstate-tags"
318
def get_format_name_subtree(self):
319
return "dirstate-with-subtree"
321
def test_set_stacked_on_errors(self):
322
branch = self.make_branch('a', format=self.get_format_name())
323
self.assertRaises(errors.UnstackableBranchFormat,
324
branch.set_stacked_on, None)
326
def test_default_stacked_location(self):
327
branch = self.make_branch('a', format=self.get_format_name())
328
self.assertRaises(errors.UnstackableBranchFormat, branch.get_stacked_on)
331
class TestBranch7(TestBranch67, TestCaseWithTransport):
334
return _mod_branch.BzrBranch7
336
def get_format_name(self):
339
def get_format_name_subtree(self):
340
return "development-subtree"
342
def test_set_stacked_on_unstackable_repo(self):
343
repo = self.make_repository('a', format='dirstate-tags')
344
control = repo.bzrdir
345
branch = _mod_branch.BzrBranchFormat7().initialize(control)
346
target = self.make_branch('b')
347
self.assertRaises(errors.UnstackableRepositoryFormat,
348
branch.set_stacked_on, target.base)
350
def _test_default_stacked_location(self):
351
branch = self.make_branch('a', format=self.get_format_name())
352
self.assertRaises(errors.NotStacked, branch.get_stacked_on)
354
def test_stack_and_unstack(self):
355
branch = self.make_branch('a', format=self.get_format_name())
356
target = self.make_branch_and_tree('b', format=self.get_format_name())
357
branch.set_stacked_on(target.branch.base)
358
self.assertEqual(target.branch.base, branch.get_stacked_on())
359
revid = target.commit('foo')
360
self.assertTrue(branch.repository.has_revision(revid))
361
branch.set_stacked_on(None)
362
self.assertRaises(errors.NotStacked, branch.get_stacked_on)
363
self.assertFalse(branch.repository.has_revision(revid))
365
def test_open_opens_stacked_reference(self):
366
branch = self.make_branch('a', format=self.get_format_name())
367
target = self.make_branch_and_tree('b', format=self.get_format_name())
368
branch.set_stacked_on(target.branch.base)
369
branch = branch.bzrdir.open_branch()
370
revid = target.commit('foo')
371
self.assertTrue(branch.repository.has_revision(revid))
299
374
class TestBranchReference(TestCaseWithTransport):
300
375
"""Tests for the branch reference facility."""