127
127
def test_format_registry(self):
128
128
my_format_registry = self.make_format_registry()
129
my_bzrdir = my_format_registry.make_bzrdir('lazy')
130
self.assertIsInstance(my_bzrdir, DeprecatedBzrDirFormat)
131
my_bzrdir = my_format_registry.make_bzrdir('deprecated')
132
self.assertIsInstance(my_bzrdir, DeprecatedBzrDirFormat)
133
my_bzrdir = my_format_registry.make_bzrdir('default')
134
self.assertIsInstance(my_bzrdir.repository_format,
135
knitrepo.RepositoryFormatKnit1)
136
my_bzrdir = my_format_registry.make_bzrdir('knit')
137
self.assertIsInstance(my_bzrdir.repository_format,
138
knitrepo.RepositoryFormatKnit1)
139
my_bzrdir = my_format_registry.make_bzrdir('branch6')
129
my_bzrdir = my_format_registry.make_controldir('lazy')
130
self.assertIsInstance(my_bzrdir, DeprecatedBzrDirFormat)
131
my_bzrdir = my_format_registry.make_controldir('deprecated')
132
self.assertIsInstance(my_bzrdir, DeprecatedBzrDirFormat)
133
my_bzrdir = my_format_registry.make_controldir('default')
134
self.assertIsInstance(my_bzrdir.repository_format,
135
knitrepo.RepositoryFormatKnit1)
136
my_bzrdir = my_format_registry.make_controldir('knit')
137
self.assertIsInstance(my_bzrdir.repository_format,
138
knitrepo.RepositoryFormatKnit1)
139
my_bzrdir = my_format_registry.make_controldir('branch6')
140
140
self.assertIsInstance(my_bzrdir.get_branch_format(),
141
141
breezy.bzrbranch.BzrBranchFormat6)
338
338
def test_create_branch_and_repo_under_shared(self):
339
339
# creating a branch and repo in a shared repo uses the
340
340
# shared repository
341
format = controldir.format_registry.make_bzrdir('knit')
341
format = controldir.format_registry.make_controldir('knit')
342
342
self.make_repository('.', shared=True, format=format)
343
343
branch = bzrdir.BzrDir.create_branch_and_repo(
344
344
self.get_url('child'), format=format)
348
348
def test_create_branch_and_repo_under_shared_force_new(self):
349
349
# creating a branch and repo in a shared repo can be forced to
350
350
# make a new repo
351
format = controldir.format_registry.make_bzrdir('knit')
351
format = controldir.format_registry.make_controldir('knit')
352
352
self.make_repository('.', shared=True, format=format)
353
353
branch = bzrdir.BzrDir.create_branch_and_repo(self.get_url('child'),
354
354
force_new_repo=True,
369
369
def test_create_standalone_working_tree_under_shared_repo(self):
370
370
# create standalone working tree always makes a repo.
371
format = controldir.format_registry.make_bzrdir('knit')
371
format = controldir.format_registry.make_controldir('knit')
372
372
self.make_repository('.', shared=True, format=format)
373
373
# note this is deliberately readonly, as this failure should
374
374
# occur before any writes.
382
382
def test_create_branch_convenience(self):
383
383
# outside a repo the default convenience output is a repo+branch_tree
384
format = controldir.format_registry.make_bzrdir('knit')
384
format = controldir.format_registry.make_controldir('knit')
385
385
branch = bzrdir.BzrDir.create_branch_convenience('.', format=format)
386
386
branch.controldir.open_workingtree()
387
387
branch.controldir.open_repository()
389
389
def test_create_branch_convenience_possible_transports(self):
390
390
"""Check that the optional 'possible_transports' is recognized"""
391
format = controldir.format_registry.make_bzrdir('knit')
391
format = controldir.format_registry.make_controldir('knit')
392
392
t = self.get_transport()
393
393
branch = bzrdir.BzrDir.create_branch_convenience(
394
394
'.', format=format, possible_transports=[t])
399
399
"""Creating a branch at the root of a fs should work."""
400
400
self.vfs_transport_factory = memory.MemoryServer
401
401
# outside a repo the default convenience output is a repo+branch_tree
402
format = controldir.format_registry.make_bzrdir('knit')
402
format = controldir.format_registry.make_controldir('knit')
403
403
branch = bzrdir.BzrDir.create_branch_convenience(self.get_url(),
405
405
self.assertRaises(errors.NoWorkingTree,
409
409
def test_create_branch_convenience_under_shared_repo(self):
410
410
# inside a repo the default convenience output is a branch+ follow the
411
411
# repo tree policy
412
format = controldir.format_registry.make_bzrdir('knit')
412
format = controldir.format_registry.make_controldir('knit')
413
413
self.make_repository('.', shared=True, format=format)
414
414
branch = bzrdir.BzrDir.create_branch_convenience('child',
420
420
def test_create_branch_convenience_under_shared_repo_force_no_tree(self):
421
421
# inside a repo the default convenience output is a branch+ follow the
422
422
# repo tree policy but we can override that
423
format = controldir.format_registry.make_bzrdir('knit')
423
format = controldir.format_registry.make_controldir('knit')
424
424
self.make_repository('.', shared=True, format=format)
425
425
branch = bzrdir.BzrDir.create_branch_convenience('child',
426
426
force_new_tree=False, format=format)
432
432
def test_create_branch_convenience_under_shared_repo_no_tree_policy(self):
433
433
# inside a repo the default convenience output is a branch+ follow the
434
434
# repo tree policy
435
format = controldir.format_registry.make_bzrdir('knit')
435
format = controldir.format_registry.make_controldir('knit')
436
436
repo = self.make_repository('.', shared=True, format=format)
437
437
repo.set_make_working_trees(False)
438
438
branch = bzrdir.BzrDir.create_branch_convenience('child',
445
445
def test_create_branch_convenience_under_shared_repo_no_tree_policy_force_tree(self):
446
446
# inside a repo the default convenience output is a branch+ follow the
447
447
# repo tree policy but we can override that
448
format = controldir.format_registry.make_bzrdir('knit')
448
format = controldir.format_registry.make_controldir('knit')
449
449
repo = self.make_repository('.', shared=True, format=format)
450
450
repo.set_make_working_trees(False)
451
451
branch = bzrdir.BzrDir.create_branch_convenience('child',
457
457
def test_create_branch_convenience_under_shared_repo_force_new_repo(self):
458
458
# inside a repo the default convenience output is overridable to give
459
459
# repo+branch+tree
460
format = controldir.format_registry.make_bzrdir('knit')
460
format = controldir.format_registry.make_controldir('knit')
461
461
self.make_repository('.', shared=True, format=format)
462
462
branch = bzrdir.BzrDir.create_branch_convenience('child',
463
463
force_new_repo=True, format=format)
470
470
def test_acquire_repository_standalone(self):
471
471
"""The default acquisition policy should create a standalone branch."""
472
my_bzrdir = self.make_bzrdir('.')
472
my_bzrdir = self.make_controldir('.')
473
473
repo_policy = my_bzrdir.determine_repository_policy()
474
474
repo, is_new = repo_policy.acquire_repository()
475
475
self.assertEqual(repo.controldir.root_transport.base,
477
477
self.assertFalse(repo.is_shared())
479
479
def test_determine_stacking_policy(self):
480
parent_bzrdir = self.make_bzrdir('.')
481
child_bzrdir = self.make_bzrdir('child')
480
parent_bzrdir = self.make_controldir('.')
481
child_bzrdir = self.make_controldir('child')
482
482
parent_bzrdir.get_config().set_default_stack_on('http://example.org')
483
483
repo_policy = child_bzrdir.determine_repository_policy()
484
484
self.assertEqual('http://example.org', repo_policy._stack_on)
486
486
def test_determine_stacking_policy_relative(self):
487
parent_bzrdir = self.make_bzrdir('.')
488
child_bzrdir = self.make_bzrdir('child')
487
parent_bzrdir = self.make_controldir('.')
488
child_bzrdir = self.make_controldir('child')
489
489
parent_bzrdir.get_config().set_default_stack_on('child2')
490
490
repo_policy = child_bzrdir.determine_repository_policy()
491
491
self.assertEqual('child2', repo_policy._stack_on)
493
493
repo_policy._stack_on_pwd)
495
495
def prepare_default_stacking(self, child_format='1.6'):
496
parent_bzrdir = self.make_bzrdir('.')
496
parent_bzrdir = self.make_controldir('.')
497
497
child_branch = self.make_branch('child', format=child_format)
498
498
parent_bzrdir.get_config().set_default_stack_on(child_branch.base)
499
499
new_child_transport = parent_bzrdir.transport.clone('child2')
508
508
def test_default_stacking_with_stackable_branch_unstackable_repo(self):
509
509
# Make stackable source branch with an unstackable repo format.
510
source_bzrdir = self.make_bzrdir('source')
510
source_bzrdir = self.make_controldir('source')
511
511
knitpack_repo.RepositoryFormatKnitPack1().initialize(source_bzrdir)
512
512
source_branch = breezy.bzrbranch.BzrBranchFormat7().initialize(
514
514
# Make a directory with a default stacking policy
515
parent_bzrdir = self.make_bzrdir('parent')
515
parent_bzrdir = self.make_controldir('parent')
516
516
stacked_on = self.make_branch('parent/stacked-on', format='pack-0.92')
517
517
parent_bzrdir.get_config().set_default_stack_on(stacked_on.base)
518
518
# Clone source into directory
525
525
trunk = self.make_branch('trunk', format='1.9')
526
526
t = self.get_transport('stacked')
527
old_fmt = controldir.format_registry.make_bzrdir('pack-0.92')
527
old_fmt = controldir.format_registry.make_controldir('pack-0.92')
528
528
repo_name = old_fmt.repository_format.network_name()
529
529
# Should end up with a 1.9 format (stackable)
530
530
repo, control, require_stacking, repo_policy = \
842
842
def test_cloning_metadir(self):
843
843
"""Ensure that cloning metadir is suitable"""
844
bzrdir = self.make_bzrdir('bzrdir')
844
bzrdir = self.make_controldir('bzrdir')
845
845
bzrdir.cloning_metadir()
846
846
branch = self.make_branch('branch', format='knit')
847
847
format = branch.controldir.cloning_metadir()
956
956
def test_find_branches(self):
957
957
root = self.make_repository('', shared=True)
958
958
foo, bar, baz = self.make_foo_bar_baz()
959
qux = self.make_bzrdir('foo/qux')
959
qux = self.make_controldir('foo/qux')
960
960
t = self.get_transport()
961
961
branches = bzrdir.BzrDir.find_branches(t)
962
962
self.assertEqual(baz.root_transport.base, branches[0].base)
1016
1016
Metadirs should compare equal iff they have the same repo, branch and
1019
mydir = controldir.format_registry.make_bzrdir('knit')
1019
mydir = controldir.format_registry.make_controldir('knit')
1020
1020
self.assertEqual(mydir, mydir)
1021
1021
self.assertFalse(mydir != mydir)
1022
otherdir = controldir.format_registry.make_bzrdir('knit')
1022
otherdir = controldir.format_registry.make_controldir('knit')
1023
1023
self.assertEqual(otherdir, mydir)
1024
1024
self.assertFalse(otherdir != mydir)
1025
otherdir2 = controldir.format_registry.make_bzrdir('development-subtree')
1025
otherdir2 = controldir.format_registry.make_controldir('development-subtree')
1026
1026
self.assertNotEqual(otherdir2, mydir)
1027
1027
self.assertFalse(otherdir2 == mydir)
1041
1041
def test_needs_conversion_different_working_tree(self):
1042
1042
# meta1dirs need an conversion if any element is not the default.
1043
new_format = controldir.format_registry.make_bzrdir('dirstate')
1043
new_format = controldir.format_registry.make_controldir('dirstate')
1044
1044
tree = self.make_branch_and_tree('tree', format='knit')
1045
1045
self.assertTrue(tree.controldir.needs_format_conversion(
1048
1048
def test_initialize_on_format_uses_smart_transport(self):
1049
1049
self.setup_smart_server_with_call_log()
1050
new_format = controldir.format_registry.make_bzrdir('dirstate')
1050
new_format = controldir.format_registry.make_controldir('dirstate')
1051
1051
transport = self.get_transport('target')
1052
1052
transport.ensure_base()
1053
1053
self.reset_smart_call_log()
1072
1072
def test_create_branch_convenience(self):
1073
1073
# outside a repo the default convenience output is a repo+branch_tree
1074
format = controldir.format_registry.make_bzrdir('knit')
1074
format = controldir.format_registry.make_controldir('knit')
1075
1075
branch = bzrdir.BzrDir.create_branch_convenience(
1076
1076
self.get_url('foo'), format=format)
1077
1077
self.assertRaises(errors.NoWorkingTree,
1081
1081
def test_create_branch_convenience_force_tree_not_local_fails(self):
1082
1082
# outside a repo the default convenience output is a repo+branch_tree
1083
format = controldir.format_registry.make_bzrdir('knit')
1083
format = controldir.format_registry.make_controldir('knit')
1084
1084
self.assertRaises(errors.NotLocalUrl,
1085
1085
bzrdir.BzrDir.create_branch_convenience,
1086
1086
self.get_url('foo'),
1092
1092
def test_clone(self):
1093
1093
# clone into a nonlocal path works
1094
format = controldir.format_registry.make_bzrdir('knit')
1094
format = controldir.format_registry.make_controldir('knit')
1095
1095
branch = bzrdir.BzrDir.create_branch_convenience('local',
1097
1097
branch.controldir.open_workingtree()