200
200
self.make_branch_and_tree('bar')
203
class TestBranch6(TestCaseWithTransport):
203
class TestBranch67(object):
204
"""Common tests for both branch 6 and 7 which are mostly the same."""
206
def get_format_name(self):
207
raise NotImplementedError(self.get_format_name)
209
def get_format_name_subtree(self):
210
raise NotImplementedError(self.get_format_name)
213
raise NotImplementedError(self.get_class)
205
215
def test_creation(self):
206
216
format = BzrDirMetaFormat1()
207
217
format.set_branch_format(_mod_branch.BzrBranchFormat6())
208
218
branch = self.make_branch('a', format=format)
209
self.assertIsInstance(branch, _mod_branch.BzrBranch6)
210
branch = self.make_branch('b', format='dirstate-tags')
211
self.assertIsInstance(branch, _mod_branch.BzrBranch6)
219
self.assertIsInstance(branch, self.get_class())
220
branch = self.make_branch('b', format=self.get_format_name())
221
self.assertIsInstance(branch, self.get_class())
212
222
branch = _mod_branch.Branch.open('a')
213
self.assertIsInstance(branch, _mod_branch.BzrBranch6)
223
self.assertIsInstance(branch, self.get_class())
215
225
def test_layout(self):
216
branch = self.make_branch('a', format='dirstate-tags')
226
branch = self.make_branch('a', format=self.get_format_name())
217
227
self.failUnlessExists('a/.bzr/branch/last-revision')
218
228
self.failIfExists('a/.bzr/branch/revision-history')
220
230
def test_config(self):
221
231
"""Ensure that all configuration data is stored in the branch"""
222
branch = self.make_branch('a', format='dirstate-tags')
232
branch = self.make_branch('a', format=self.get_format_name())
223
233
branch.set_parent('http://bazaar-vcs.org')
224
234
self.failIfExists('a/.bzr/branch/parent')
225
235
self.assertEqual('http://bazaar-vcs.org', branch.get_parent())
249
259
def do_checkout_test(self, lightweight=False):
250
tree = self.make_branch_and_tree('source', format='dirstate-with-subtree')
260
tree = self.make_branch_and_tree('source',
261
format=self.get_format_name_subtree())
251
262
subtree = self.make_branch_and_tree('source/subtree',
252
format='dirstate-with-subtree')
263
format=self.get_format_name_subtree())
253
264
subsubtree = self.make_branch_and_tree('source/subtree/subsubtree',
254
format='dirstate-with-subtree')
265
format=self.get_format_name_subtree())
255
266
self.build_tree(['source/subtree/file',
256
267
'source/subtree/subsubtree/file'])
257
268
subsubtree.add('file')
294
305
self.assertEqual(warnings[0], 'Value "new" is masked by "old" from '
295
306
'locations.conf')
309
class TestBranch6(TestBranch67, TestCaseWithTransport):
312
return _mod_branch.BzrBranch6
314
def get_format_name(self):
315
return "dirstate-tags"
317
def get_format_name_subtree(self):
318
return "dirstate-with-subtree"
320
def test_set_stacked_on_errors(self):
321
branch = self.make_branch('a', format=self.get_format_name())
322
self.assertRaises(errors.UnstackableBranchFormat,
323
branch.set_stacked_on, None)
325
def test_default_stacked_location(self):
326
branch = self.make_branch('a', format=self.get_format_name())
327
self.assertRaises(errors.UnstackableBranchFormat, branch.get_stacked_on)
330
class TestBranch7(TestBranch67, TestCaseWithTransport):
333
return _mod_branch.BzrBranch7
335
def get_format_name(self):
338
def get_format_name_subtree(self):
339
return "development-subtree"
341
def test_set_stacked_on_unstackable_repo(self):
342
repo = self.make_repository('a', format='dirstate-tags')
343
control = repo.bzrdir
344
branch = _mod_branch.BzrBranchFormat7().initialize(control)
345
target = self.make_branch('b')
346
self.assertRaises(errors.UnstackableRepositoryFormat,
347
branch.set_stacked_on, target.base)
349
def _test_default_stacked_location(self):
350
branch = self.make_branch('a', format=self.get_format_name())
351
self.assertRaises(errors.NotStacked, branch.get_stacked_on)
353
def test_stacked_location_file(self):
354
branch = self.make_branch('a', format=self.get_format_name())
355
self.assertFileEqual('\n', 'a/.bzr/branch/stacked-on')
357
def test_stack_and_unstack(self):
358
branch = self.make_branch('a', format=self.get_format_name())
359
target = self.make_branch_and_tree('b', format=self.get_format_name())
360
branch.set_stacked_on(target.branch.base)
361
self.assertEqual(target.branch.base, branch.get_stacked_on())
362
revid = target.commit('foo')
363
self.assertTrue(branch.repository.has_revision(revid))
364
branch.set_stacked_on(None)
365
self.assertRaises(errors.NotStacked, branch.get_stacked_on)
366
self.assertFalse(branch.repository.has_revision(revid))
368
def test_open_opens_stacked_reference(self):
369
branch = self.make_branch('a', format=self.get_format_name())
370
target = self.make_branch_and_tree('b', format=self.get_format_name())
371
branch.set_stacked_on(target.branch.base)
372
branch = branch.bzrdir.open_branch()
373
revid = target.commit('foo')
374
self.assertTrue(branch.repository.has_revision(revid))
297
377
class TestBranchReference(TestCaseWithTransport):
298
378
"""Tests for the branch reference facility."""