/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

Upgraded to the latest 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
48
49
from bzrlib.workingtree import WorkingTree
49
50
 
50
51
 
51
 
# TODO: Make a branch using basis branch, and check that it 
52
 
# doesn't request any files that could have been avoided, by 
53
 
# hooking into the Transport.
54
 
 
55
 
 
56
52
class TestCaseWithBranch(TestCaseWithBzrDir):
57
53
 
58
54
    def setUp(self):
163
159
        tree_b.branch.repository.fetch(tree_a.branch.repository)
164
160
        return tree_a, tree_b
165
161
 
166
 
    def test_clone_branch(self):
167
 
        """Copy the stores from one branch to another"""
168
 
        tree_a, tree_b = self.get_balanced_branch_pair()
169
 
        tree_b.commit("silly commit")
170
 
        os.mkdir('c')
171
 
        # this fails to test that the history from a was not used.
172
 
        dir_c = tree_a.bzrdir.clone('c', basis=tree_b.bzrdir)
173
 
        self.assertEqual(tree_a.branch.revision_history(),
174
 
                         dir_c.open_branch().revision_history())
175
 
 
176
162
    def test_clone_partial(self):
177
163
        """Copy only part of the history of a branch."""
178
164
        # TODO: RBC 20060208 test with a revision not on revision-history.
367
353
        # config file in the branch.
368
354
        branch.nick = "Aaron's branch"
369
355
        branch.nick = "Aaron's branch"
370
 
        try:
 
356
        if not isinstance(branch, remote.RemoteBranch):
371
357
            controlfilename = branch.control_files.controlfilename
372
 
        except AttributeError:
373
 
            # remote branches don't have control_files
374
 
            pass
375
 
        else:
376
 
            self.failUnless(
377
 
                t.has(t.relpath(controlfilename("branch.conf"))))
 
358
            self.failUnless(t.has(t.relpath(controlfilename("branch.conf"))))
378
359
        # Because the nick has been set explicitly, the nick is now always
379
360
        # "Aaron's branch", regardless of directory name.
380
361
        self.assertEqual(branch.nick, "Aaron's branch")
613
594
class TestFormat(TestCaseWithBranch):
614
595
    """Tests for the format itself."""
615
596
 
 
597
    def test_get_reference(self):
 
598
        """get_reference on all regular branches should return None."""
 
599
        if not self.branch_format.is_supported():
 
600
            # unsupported formats are not loopback testable
 
601
            # because the default open will not open them and
 
602
            # they may not be initializable.
 
603
            return
 
604
        made_branch = self.make_branch('.')
 
605
        self.assertEqual(None,
 
606
            made_branch._format.get_reference(made_branch.bzrdir))
 
607
 
616
608
    def test_format_initialize_find_open(self):
617
609
        # loopback test to check the current format initializes to itself.
618
610
        if not self.branch_format.is_supported():
645
637
        except NotImplementedError:
646
638
            return
647
639
        self.assertEqual(self.branch_format,
648
 
                         branch.BranchFormat.find_format(opened_control))
 
640
                         opened_control.find_branch_format())
649
641
 
650
642
 
651
643
class TestBound(TestCaseWithBranch):