~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bzrdir.py

Made changes to BzrDir.open_containing_tree_branch_or_repository suggested on list.

Show diffs side-by-side

added added

removed removed

Lines of Context:
452
452
        self.assertEqual('g/p/q', relpath)
453
453
 
454
454
    def test_open_containing_tree_branch_or_repository_empty(self):
455
 
        self.assertRaises(errors.NotVersionedError,
 
455
        self.assertRaises(errors.NotBranchError,
456
456
            bzrdir.BzrDir.open_containing_tree_branch_or_repository,
457
457
            self.get_readonly_url(''))
458
458
 
459
459
    def test_open_containing_tree_branch_or_repository_all(self):
460
460
        self.make_branch_and_tree('topdir')
461
 
        tree, branch, repo = \
 
461
        tree, branch, repo, relpath = \
462
462
            bzrdir.BzrDir.open_containing_tree_branch_or_repository(
463
463
                'topdir/foo')
464
464
        self.assertEqual(os.path.realpath('topdir'),
468
468
        self.assertEqual(
469
469
            os.path.realpath(os.path.join('topdir', '.bzr', 'repository')),
470
470
            repo.bzrdir.transport.local_abspath('repository'))
 
471
        self.assertEqual(relpath, 'foo')
471
472
 
472
473
    def test_open_containing_tree_branch_or_repository_no_tree(self):
473
474
        self.make_branch('branch')
474
 
        tree, branch, repo = \
 
475
        tree, branch, repo, relpath = \
475
476
            bzrdir.BzrDir.open_containing_tree_branch_or_repository(
476
477
                'branch/foo')
477
478
        self.assertEqual(tree, None)
480
481
        self.assertEqual(
481
482
            os.path.realpath(os.path.join('branch', '.bzr', 'repository')),
482
483
            repo.bzrdir.transport.local_abspath('repository'))
 
484
        self.assertEqual(relpath, 'foo')
483
485
 
484
486
    def test_open_containing_tree_branch_or_repository_repo(self):
485
487
        self.make_repository('repo')
486
 
        tree, branch, repo = \
 
488
        tree, branch, repo, relpath = \
487
489
            bzrdir.BzrDir.open_containing_tree_branch_or_repository(
488
490
                'repo')
489
491
        self.assertEqual(tree, None)
491
493
        self.assertEqual(
492
494
            os.path.realpath(os.path.join('repo', '.bzr', 'repository')),
493
495
            repo.bzrdir.transport.local_abspath('repository'))
 
496
        self.assertEqual(relpath, '')
494
497
 
495
498
    def test_open_containing_tree_branch_or_repository_shared_repo(self):
496
499
        self.make_repository('shared', shared=True)
497
500
        bzrdir.BzrDir.create_branch_convenience('shared/branch',
498
501
                                                force_new_tree=False)
499
 
        tree, branch, repo = \
 
502
        tree, branch, repo, relpath = \
500
503
            bzrdir.BzrDir.open_containing_tree_branch_or_repository(
501
504
                'shared/branch')
502
505
        self.assertEqual(tree, None)
505
508
        self.assertEqual(
506
509
            os.path.realpath(os.path.join('shared', '.bzr', 'repository')),
507
510
            repo.bzrdir.transport.local_abspath('repository'))
 
511
        self.assertEqual(relpath, '')
508
512
 
509
513
    def test_open_containing_tree_branch_or_repository_branch_subdir(self):
510
514
        self.make_branch_and_tree('foo')
511
515
        self.build_tree(['foo/bar/'])
512
 
        tree, branch, repo = \
 
516
        tree, branch, repo, relpath = \
513
517
            bzrdir.BzrDir.open_containing_tree_branch_or_repository(
514
518
                'foo/bar')
515
519
        self.assertEqual(os.path.realpath('foo'),
519
523
        self.assertEqual(
520
524
            os.path.realpath(os.path.join('foo', '.bzr', 'repository')),
521
525
            repo.bzrdir.transport.local_abspath('repository'))
 
526
        self.assertEqual(relpath, 'bar')
522
527
 
523
528
    def test_open_containing_tree_branch_or_repository_repo_subdir(self):
524
529
        self.make_repository('bar')
525
530
        self.build_tree(['bar/baz/'])
526
 
        tree, branch, repo = \
 
531
        tree, branch, repo, relpath = \
527
532
            bzrdir.BzrDir.open_containing_tree_branch_or_repository(
528
533
                'bar/baz')
529
534
        self.assertEqual(tree, None)
531
536
        self.assertEqual(
532
537
            os.path.realpath(os.path.join('bar', '.bzr', 'repository')),
533
538
            repo.bzrdir.transport.local_abspath('repository'))
 
539
        self.assertEqual(relpath, 'baz')
534
540
 
535
541
    def test_open_containing_from_transport(self):
536
542
        self.assertRaises(NotBranchError, bzrdir.BzrDir.open_containing_from_transport,