~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bzrdir.py

  • Committer: Andrew Bennetts
  • Date: 2008-07-28 06:53:44 UTC
  • mfrom: (3581 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3583.
  • Revision ID: andrew.bennetts@canonical.com-20080728065344-ocndjoycs903q6fz
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
424
424
        self.assertFalse(repo.is_shared())
425
425
 
426
426
 
 
427
    def test_determine_stacking_policy(self):
 
428
        parent_bzrdir = self.make_bzrdir('.')
 
429
        child_bzrdir = self.make_bzrdir('child')
 
430
        parent_bzrdir.get_config().set_default_stack_on('http://example.org')
 
431
        repo_policy = child_bzrdir.determine_repository_policy()
 
432
        self.assertEqual('http://example.org', repo_policy._stack_on)
 
433
 
 
434
    def test_determine_stacking_policy_relative(self):
 
435
        parent_bzrdir = self.make_bzrdir('.')
 
436
        child_bzrdir = self.make_bzrdir('child')
 
437
        parent_bzrdir.get_config().set_default_stack_on('child2')
 
438
        repo_policy = child_bzrdir.determine_repository_policy()
 
439
        self.assertEqual('child2', repo_policy._stack_on)
 
440
        self.assertEqual(parent_bzrdir.root_transport.base,
 
441
                         repo_policy._stack_on_pwd)
 
442
 
 
443
    def prepare_default_stacking(self):
 
444
        parent_bzrdir = self.make_bzrdir('.')
 
445
        child_branch = self.make_branch('child', format='development1')
 
446
        parent_bzrdir.get_config().set_default_stack_on(child_branch.base)
 
447
        new_child_transport = parent_bzrdir.transport.clone('child2')
 
448
        return child_branch, new_child_transport
 
449
 
 
450
    def test_clone_on_transport_obeys_stacking_policy(self):
 
451
        child_branch, new_child_transport = self.prepare_default_stacking()
 
452
        new_child = child_branch.bzrdir.clone_on_transport(new_child_transport)
 
453
        self.assertEqual(child_branch.base,
 
454
                         new_child.open_branch().get_stacked_on_url())
 
455
 
 
456
    def test_sprout_obeys_stacking_policy(self):
 
457
        child_branch, new_child_transport = self.prepare_default_stacking()
 
458
        new_child = child_branch.bzrdir.sprout(new_child_transport.base)
 
459
        self.assertEqual(child_branch.base,
 
460
                         new_child.open_branch().get_stacked_on_url())
 
461
 
 
462
    def test_add_fallback_repo_handles_absolute_urls(self):
 
463
        stack_on = self.make_branch('stack_on', format='development1')
 
464
        repo = self.make_repository('repo', format='development1')
 
465
        policy = bzrdir.UseExistingRepository(repo, stack_on.base)
 
466
        policy._add_fallback(repo)
 
467
 
 
468
    def test_add_fallback_repo_handles_relative_urls(self):
 
469
        stack_on = self.make_branch('stack_on', format='development1')
 
470
        repo = self.make_repository('repo', format='development1')
 
471
        policy = bzrdir.UseExistingRepository(repo, '.', stack_on.base)
 
472
        policy._add_fallback(repo)
 
473
 
 
474
    def test_configure_relative_branch_stacking_url(self):
 
475
        stack_on = self.make_branch('stack_on', format='development1')
 
476
        stacked = self.make_branch('stack_on/stacked', format='development1')
 
477
        policy = bzrdir.UseExistingRepository(stacked.repository,
 
478
            '.', stack_on.base)
 
479
        policy.configure_branch(stacked)
 
480
        self.assertEqual('..', stacked.get_stacked_on_url())
 
481
 
 
482
    def test_relative_branch_stacking_to_absolute(self):
 
483
        stack_on = self.make_branch('stack_on', format='development1')
 
484
        stacked = self.make_branch('stack_on/stacked', format='development1')
 
485
        policy = bzrdir.UseExistingRepository(stacked.repository,
 
486
            '.', self.get_readonly_url('stack_on'))
 
487
        policy.configure_branch(stacked)
 
488
        self.assertEqual(self.get_readonly_url('stack_on'),
 
489
                         stacked.get_stacked_on_url())
 
490
 
 
491
 
427
492
class ChrootedTests(TestCaseWithTransport):
428
493
    """A support class that provides readonly urls outside the local namespace.
429
494