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

  • Committer: Martin Pool
  • Date: 2007-04-26 05:28:49 UTC
  • mfrom: (2458 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2461.
  • Revision ID: mbp@sourcefrog.net-20070426052849-ffc06nlmkpbvqata
merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
    gpg,
27
27
    urlutils,
28
28
    transactions,
 
29
    remote,
29
30
    repository,
30
31
    )
31
32
from bzrlib.branch import Branch, needs_read_lock, needs_write_lock
39
40
from bzrlib.osutils import getcwd
40
41
import bzrlib.revision
41
42
from bzrlib.tests import TestCase, TestCaseWithTransport, TestSkipped
42
 
from bzrlib.tests.bzrdir_implementations.test_bzrdir import TestCaseWithBzrDir
 
43
from bzrlib.tests.branch_implementations import TestCaseWithBranch
43
44
from bzrlib.tests.HttpServer import HttpServer
44
45
from bzrlib.trace import mutter
45
46
from bzrlib.transport import get_transport
48
49
from bzrlib.workingtree import WorkingTree
49
50
 
50
51
 
51
 
class TestCaseWithBranch(TestCaseWithBzrDir):
52
 
 
53
 
    def setUp(self):
54
 
        super(TestCaseWithBranch, self).setUp()
55
 
        self.branch = None
56
 
 
57
 
    def get_branch(self):
58
 
        if self.branch is None:
59
 
            self.branch = self.make_branch('')
60
 
        return self.branch
61
 
 
62
 
    def make_branch(self, relpath, format=None):
63
 
        repo = self.make_repository(relpath, format=format)
64
 
        # fixme RBC 20060210 this isnt necessarily a fixable thing,
65
 
        # Skipped is the wrong exception to raise.
66
 
        try:
67
 
            return self.branch_format.initialize(repo.bzrdir)
68
 
        except errors.UninitializableFormat:
69
 
            raise TestSkipped('Uninitializable branch format')
70
 
 
71
 
    def make_repository(self, relpath, shared=False, format=None):
72
 
        made_control = self.make_bzrdir(relpath, format=format)
73
 
        return made_control.create_repository(shared=shared)
74
 
 
75
 
 
76
52
class TestBranch(TestCaseWithBranch):
77
53
 
78
54
    def test_append_revisions(self):
90
66
        self.assertEquals(br.revision_history(), ["rev1", "rev2", "rev3"])
91
67
        self.assertRaises(errors.ReservedId, br.append_revision, 'current:')
92
68
 
 
69
    def test_create_tree_with_merge(self):
 
70
        tree = self.create_tree_with_merge()
 
71
        ancestry_graph = tree.branch.repository.get_revision_graph('rev-3')
 
72
        self.assertEqual({'rev-1':[],
 
73
                          'rev-2':['rev-1'],
 
74
                          'rev-1.1.1':['rev-1'],
 
75
                          'rev-3':['rev-2', 'rev-1.1.1'],
 
76
                         }, ancestry_graph)
 
77
 
93
78
    def test_revision_ids_are_utf8(self):
94
79
        wt = self.make_branch_and_tree('tree')
95
80
        wt.commit('f', rev_id='rev1')
352
337
        # config file in the branch.
353
338
        branch.nick = "Aaron's branch"
354
339
        branch.nick = "Aaron's branch"
355
 
        try:
 
340
        if not isinstance(branch, remote.RemoteBranch):
356
341
            controlfilename = branch.control_files.controlfilename
357
 
        except AttributeError:
358
 
            # remote branches don't have control_files
359
 
            pass
360
 
        else:
361
 
            self.failUnless(
362
 
                t.has(t.relpath(controlfilename("branch.conf"))))
 
342
            self.failUnless(t.has(t.relpath(controlfilename("branch.conf"))))
363
343
        # Because the nick has been set explicitly, the nick is now always
364
344
        # "Aaron's branch", regardless of directory name.
365
345
        self.assertEqual(branch.nick, "Aaron's branch")
598
578
class TestFormat(TestCaseWithBranch):
599
579
    """Tests for the format itself."""
600
580
 
 
581
    def test_get_reference(self):
 
582
        """get_reference on all regular branches should return None."""
 
583
        if not self.branch_format.is_supported():
 
584
            # unsupported formats are not loopback testable
 
585
            # because the default open will not open them and
 
586
            # they may not be initializable.
 
587
            return
 
588
        made_branch = self.make_branch('.')
 
589
        self.assertEqual(None,
 
590
            made_branch._format.get_reference(made_branch.bzrdir))
 
591
 
601
592
    def test_format_initialize_find_open(self):
602
593
        # loopback test to check the current format initializes to itself.
603
594
        if not self.branch_format.is_supported():
630
621
        except NotImplementedError:
631
622
            return
632
623
        self.assertEqual(self.branch_format,
633
 
                         branch.BranchFormat.find_format(opened_control))
 
624
                         opened_control.find_branch_format())
634
625
 
635
626
 
636
627
class TestBound(TestCaseWithBranch):