/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/bzrdir_implementations/test_bzrdir.py

  • Committer: Robert Collins
  • Date: 2006-02-14 11:23:07 UTC
  • mto: (1534.5.2 bzr-dir)
  • mto: This revision was merged to the branch mainline in revision 1554.
  • Revision ID: robertc@robertcollins.net-20060214112307-824f0b126b3c70a9
sprouting into shared repositories

Show diffs side-by-side

added added

removed removed

Lines of Context:
111
111
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport)
112
112
    
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)
150
150
        
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()
 
340
 
 
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')
 
344
        try:
 
345
            self.make_repository('target', shared=True)
 
346
        except errors.IncompatibleFormat:
 
347
            return
 
348
        target = dir.sprout(self.get_url('target/child'))
 
349
        self.assertRaises(errors.NoRepositoryPresent, target.open_repository)
 
350
        target.open_branch()
 
351
        target.open_workingtree()
 
352
 
 
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')
 
357
        try:
 
358
            self.make_repository('target', shared=True)
 
359
        except errors.IncompatibleFormat:
 
360
            return
 
361
        target = dir.sprout(self.get_url('target/child'), force_new_repo=True)
 
362
        target.open_repository()
 
363
        target.open_branch()
 
364
        target.open_workingtree()
340
365
    
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)
353
378
 
 
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('..'))
 
382
        tree.add('foo')
 
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)
 
389
        dir = source.bzrdir
 
390
        try:
 
391
            shared_repo = self.make_repository('target', shared=True)
 
392
        except errors.IncompatibleFormat:
 
393
            return
 
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'))
 
397
 
 
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('..'))
 
401
        tree.add('foo')
 
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)
 
408
        dir = source.bzrdir
 
409
        try:
 
410
            shared_repo = self.make_repository('target', shared=True)
 
411
        except errors.IncompatibleFormat:
 
412
            return
 
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'))
 
416
 
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)
384
447
 
 
448
    def test_sprout_bzrdir_branch_and_repo_shared(self):
 
449
        # sprouting a branch with a repo into a shared repo uses the shared
 
450
        # repo
 
451
        tree = self.make_branch_and_tree('commit_tree')
 
452
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
 
453
        tree.add('foo')
 
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)
 
458
        dir = source.bzrdir
 
459
        try:
 
460
            shared_repo = self.make_repository('target', shared=True)
 
461
        except errors.IncompatibleFormat:
 
462
            return
 
463
        target = dir.sprout(self.get_url('target/child'))
 
464
        self.assertTrue(shared_repo.has_revision('1'))
 
465
 
 
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
 
468
        # repo
 
469
        tree = self.make_branch_and_tree('commit_tree')
 
470
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
 
471
        tree.add('foo')
 
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)
 
476
        dir = source.bzrdir
 
477
        try:
 
478
            shared_repo = self.make_repository('target', shared=True)
 
479
        except errors.IncompatibleFormat:
 
480
            return
 
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'))
 
484
 
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')
401
501
        # place
402
502
        target.open_repository()
403
503
 
 
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')
 
509
        try:
 
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.
 
514
            return
 
515
        self.assertRaises(errors.NoRepositoryPresent, dir.open_repository)
 
516
        try:
 
517
            shared_repo = self.make_repository('target', shared=True)
 
518
        except errors.IncompatibleFormat:
 
519
            return
 
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'))
 
529
 
 
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')
 
535
        try:
 
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.
 
540
            return
 
541
        self.assertRaises(errors.NoRepositoryPresent, dir.open_repository)
 
542
        try:
 
543
            shared_repo = self.make_repository('target', shared=True)
 
544
        except errors.IncompatibleFormat:
 
545
            return
 
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'))
 
554
 
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,