/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/per_branch/test_branch.py

  • Committer: Neil Martinsen-Burrell
  • Date: 2010-09-26 02:27:37 UTC
  • mfrom: (5424 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5461.
  • Revision ID: nmb@wartburg.edu-20100926022737-cj2qvebm2mhpjzak
mergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
from bzrlib import (
20
20
    branch as _mod_branch,
21
21
    bzrdir,
 
22
    config,
22
23
    delta as _mod_delta,
23
24
    errors,
24
25
    gpg,
379
380
        self.assertEqual(committed.properties["branch-nick"],
380
381
                         "My happy branch")
381
382
 
 
383
    def test_create_colocated(self):
 
384
        try:
 
385
            repo = self.make_repository('.', shared=True)
 
386
        except errors.IncompatibleFormat:
 
387
            return
 
388
        self.assertEquals(0, len(repo.bzrdir.list_branches()))
 
389
        try:
 
390
            child_branch1 = self.branch_format.initialize(repo.bzrdir, 
 
391
                name='branch1')
 
392
        except (errors.UninitializableFormat, errors.NoColocatedBranchSupport):
 
393
            # branch references are not default init'able and
 
394
            # not all bzrdirs support colocated branches.
 
395
            return
 
396
        self.assertEquals(1, len(repo.bzrdir.list_branches()))
 
397
        self.branch_format.initialize(repo.bzrdir, name='branch2')
 
398
        self.assertEquals(2, len(repo.bzrdir.list_branches()))
 
399
 
382
400
    def test_create_open_branch_uses_repository(self):
383
401
        try:
384
402
            repo = self.make_repository('.', shared=True)
600
618
        self.assertEqual(None, self.get_branch().get_push_location())
601
619
 
602
620
    def test_get_push_location_exact(self):
603
 
        from bzrlib.config import (locations_config_filename,
604
 
                                   ensure_config_dir_exists)
605
 
        ensure_config_dir_exists()
606
 
        fn = locations_config_filename()
607
 
        open(fn, 'wt').write(("[%s]\n"
608
 
                                  "push_location=foo\n" %
609
 
                                  self.get_branch().base[:-1]))
 
621
        b = self.get_branch()
 
622
        config.LocationConfig.from_string(
 
623
            '[%s]\npush_location=foo\n' % (b.base,), b.base, save=True)
610
624
        self.assertEqual("foo", self.get_branch().get_push_location())
611
625
 
612
626
    def test_set_push_location(self):
651
665
        this_branch = self.make_branch('this')
652
666
        other_branch = self.make_branch('other')
653
667
        try:
654
 
            this_branch._format.set_reference(this_branch.bzrdir, other_branch)
 
668
            this_branch._format.set_reference(this_branch.bzrdir, None,
 
669
                other_branch)
655
670
        except NotImplementedError:
656
671
            # that's ok
657
672
            pass
971
986
        merger.do_merge()
972
987
        self.assertEqual('../branch/reference',
973
988
                         tree.branch.get_reference_info('file-id')[1])
 
989
 
 
990
 
 
991
class TestBranchControlComponent(per_branch.TestCaseWithBranch):
 
992
    """Branch implementations adequately implement ControlComponent."""
 
993
    
 
994
    def test_urls(self):
 
995
        br = self.make_branch('branch')
 
996
        self.assertIsInstance(br.user_url, str)
 
997
        self.assertEqual(br.user_url, br.user_transport.base)
 
998
        # for all current bzrdir implementations the user dir must be 
 
999
        # above the control dir but we might need to relax that?
 
1000
        self.assertEqual(br.control_url.find(br.user_url), 0)
 
1001
        self.assertEqual(br.control_url, br.control_transport.base)