111
111
self.assertDirectoriesEqual(dir.root_transport, target.root_transport)
113
113
def test_clone_bzrdir_empty_force_new_ignored(self):
114
# the force_new parameter should have no effect on an empty
114
# the force_new_repo parameter should have no effect on an empty
115
115
# bzrdir's clone logic
116
116
dir = self.make_bzrdir('source')
117
117
target = dir.clone(self.get_url('target'), force_new_repo=True)
148
148
self.assertNotEqual(dir.transport.base, target.transport.base)
149
149
self.assertRaises(errors.NoRepositoryPresent, target.open_repository)
151
def test_clone_bzrdir_repository_under_shared_force_new(self):
151
def test_clone_bzrdir_repository_under_shared_force_new_repo(self):
152
152
dir = self.make_bzrdir('source')
153
153
repo = dir.create_repository()
154
154
# add some content to differentiate from an empty repository.
337
337
target.open_repository()
338
338
target.open_branch()
339
339
target.open_workingtree()
341
def test_sprout_bzrdir_empty_under_shared_repo(self):
342
# sprouting an empty dir into a repo uses the repo
343
dir = self.make_bzrdir('source')
345
self.make_repository('target', shared=True)
346
except errors.IncompatibleFormat:
348
target = dir.sprout(self.get_url('target/child'))
349
self.assertRaises(errors.NoRepositoryPresent, target.open_repository)
351
target.open_workingtree()
353
def test_sprout_bzrdir_empty_under_shared_repo(self):
354
# the force_new_repo parameter should force use of a new repo in an empty
355
# bzrdir's sprout logic
356
dir = self.make_bzrdir('source')
358
self.make_repository('target', shared=True)
359
except errors.IncompatibleFormat:
361
target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
362
target.open_repository()
364
target.open_workingtree()
341
366
def test_sprout_bzrdir_repository(self):
342
367
dir = self.make_bzrdir('source')
351
376
self.assertNotEqual(dir.transport.base, target.transport.base)
352
377
self.assertDirectoriesEqual(dir.root_transport, target.root_transport)
379
def test_sprout_bzrdir_repository_under_shared(self):
380
tree = self.make_branch_and_tree('commit_tree')
381
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
383
tree.commit('revision 1', rev_id='1')
384
tree.bzrdir.open_branch().set_revision_history([])
385
tree.set_last_revision(None)
386
tree.commit('revision 2', rev_id='2')
387
source = self.make_repository('source')
388
tree.bzrdir.open_repository().copy_content_into(source)
391
shared_repo = self.make_repository('target', shared=True)
392
except errors.IncompatibleFormat:
394
target = dir.sprout(self.get_url('target/child'))
395
self.assertNotEqual(dir.transport.base, target.transport.base)
396
self.assertTrue(shared_repo.has_revision('1'))
398
def test_sprout_bzrdir_repository_under_shared_force_new_repo(self):
399
tree = self.make_branch_and_tree('commit_tree')
400
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
402
tree.commit('revision 1', rev_id='1')
403
tree.bzrdir.open_branch().set_revision_history([])
404
tree.set_last_revision(None)
405
tree.commit('revision 2', rev_id='2')
406
source = self.make_repository('source')
407
tree.bzrdir.open_repository().copy_content_into(source)
410
shared_repo = self.make_repository('target', shared=True)
411
except errors.IncompatibleFormat:
413
target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
414
self.assertNotEqual(dir.transport.base, target.transport.base)
415
self.assertFalse(shared_repo.has_revision('1'))
354
417
def test_sprout_bzrdir_repository_revision(self):
355
418
# test for revision limiting, [smoke test, not corner case checks].
356
419
# make a repository with some revisions,
382
445
self.assertNotEqual(dir.transport.base, target.transport.base)
383
446
self.assertDirectoriesEqual(dir.root_transport, target.root_transport)
448
def test_sprout_bzrdir_branch_and_repo_shared(self):
449
# sprouting a branch with a repo into a shared repo uses the shared
451
tree = self.make_branch_and_tree('commit_tree')
452
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
454
tree.commit('revision 1', rev_id='1')
455
source = self.make_branch('source')
456
tree.bzrdir.open_repository().copy_content_into(source.repository)
457
tree.bzrdir.open_branch().copy_content_into(source)
460
shared_repo = self.make_repository('target', shared=True)
461
except errors.IncompatibleFormat:
463
target = dir.sprout(self.get_url('target/child'))
464
self.assertTrue(shared_repo.has_revision('1'))
466
def test_sprout_bzrdir_branch_and_repo_shared_force_new_repo(self):
467
# sprouting a branch with a repo into a shared repo uses the shared
469
tree = self.make_branch_and_tree('commit_tree')
470
self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
472
tree.commit('revision 1', rev_id='1')
473
source = self.make_branch('source')
474
tree.bzrdir.open_repository().copy_content_into(source.repository)
475
tree.bzrdir.open_branch().copy_content_into(source)
478
shared_repo = self.make_repository('target', shared=True)
479
except errors.IncompatibleFormat:
481
target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
482
self.assertNotEqual(dir.transport.base, target.transport.base)
483
self.assertFalse(shared_repo.has_revision('1'))
385
485
def test_sprout_bzrdir_branch_reference(self):
386
486
# sprouting should create a repository if needed and a sprouted branch.
387
487
referenced_branch = self.make_branch('referencced')
402
502
target.open_repository()
504
def test_sprout_bzrdir_branch_reference_shared(self):
505
# sprouting should create a repository if needed and a sprouted branch.
506
referenced_tree = self.make_branch_and_tree('referenced')
507
referenced_tree.commit('1', rev_id='1', allow_pointless=True)
508
dir = self.make_bzrdir('source')
510
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
511
referenced_tree.branch)
512
except errors.IncompatibleFormat:
513
# this is ok too, not all formats have to support references.
515
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository)
517
shared_repo = self.make_repository('target', shared=True)
518
except errors.IncompatibleFormat:
520
target = dir.sprout(self.get_url('target/child'))
521
self.assertNotEqual(dir.transport.base, target.transport.base)
522
# we want target to have a branch that is in-place.
523
self.assertEqual(target, target.open_branch().bzrdir)
524
# and we want no repository as the target is shared
525
self.assertRaises(errors.NoRepositoryPresent,
526
target.open_repository)
527
# and we want revision '1' in the shared repo
528
self.assertTrue(shared_repo.has_revision('1'))
530
def test_sprout_bzrdir_branch_reference_shared_force_new_repo(self):
531
# sprouting should create a repository if needed and a sprouted branch.
532
referenced_tree = self.make_branch_and_tree('referenced')
533
referenced_tree.commit('1', rev_id='1', allow_pointless=True)
534
dir = self.make_bzrdir('source')
536
reference = bzrlib.branch.BranchReferenceFormat().initialize(dir,
537
referenced_tree.branch)
538
except errors.IncompatibleFormat:
539
# this is ok too, not all formats have to support references.
541
self.assertRaises(errors.NoRepositoryPresent, dir.open_repository)
543
shared_repo = self.make_repository('target', shared=True)
544
except errors.IncompatibleFormat:
546
target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
547
self.assertNotEqual(dir.transport.base, target.transport.base)
548
# we want target to have a branch that is in-place.
549
self.assertEqual(target, target.open_branch().bzrdir)
550
# and we want revision '1' in the new repo
551
self.assertTrue(target.open_repository().has_revision('1'))
552
# but not the shared one
553
self.assertFalse(shared_repo.has_revision('1'))
404
555
def test_sprout_bzrdir_branch_revision(self):
405
556
# test for revision limiting, [smoke test, not corner case checks].
406
557
# make a repository with some revisions,