83
83
    def test_append_revisions(self):
 
84
84
        """Test appending more than one revision"""
 
 
85
        wt = self.make_branch_and_tree('tree')
 
 
86
        wt.commit('f', rev_id='rev1')
 
 
87
        wt.commit('f', rev_id='rev2')
 
 
88
        wt.commit('f', rev_id='rev3')
 
85
90
        br = self.get_branch()
 
86
92
        br.append_revision("rev1")
 
87
93
        self.assertEquals(br.revision_history(), ["rev1",])
 
88
94
        br.append_revision("rev2", "rev3")
 
 
213
219
        branch_d = branch_b.clone(repo_d.bzrdir)
 
214
220
        self.assertEqual(random_parent, branch_d.get_parent())
 
 
222
    def test_copy_content_incomplete(self):
 
 
223
        tree = self.make_branch_and_tree('commit_tree')
 
 
224
        self.build_tree(['foo'], transport=tree.bzrdir.root_transport)
 
 
226
        tree.commit('revision 1', rev_id='1')
 
 
227
        source = self.make_branch_and_tree('source')
 
 
228
        # this gives us an incomplete repository
 
 
229
        tree.bzrdir.open_repository().copy_content_into(
 
 
230
            source.branch.repository)
 
 
231
        tree.commit('revision 2', rev_id='2', allow_pointless=True)
 
 
232
        tree.bzrdir.open_branch().copy_content_into(source.branch)
 
216
235
    def test_sprout_branch_nickname(self):
 
217
236
        # test the nick name is reset always
 
218
237
        raise TestSkipped('XXX branch sprouting is not yet tested..')
 
 
577
596
        self.assertEqual("foo", self.get_branch().get_push_location())
 
579
598
    def test_set_push_location(self):
 
580
 
        from bzrlib.config import (locations_config_filename,
 
581
 
                                   ensure_config_dir_exists)
 
582
 
        ensure_config_dir_exists()
 
583
 
        fn = locations_config_filename()
 
584
599
        branch = self.get_branch()
 
585
600
        branch.set_push_location('foo')
 
586
 
        local_path = urlutils.local_path_from_url(branch.base[:-1])
 
587
 
        self.assertFileEqual("[%s]\n"
 
588
 
                             "push_location = foo\n"
 
589
 
                             "push_location:policy = norecurse" % local_path,
 
592
 
    # TODO RBC 20051029 test getting a push location from a branch in a 
 
593
 
    # recursive section - that is, it appends the branch name.
 
 
601
        self.assertEqual('foo', branch.get_push_location())
 
596
604
class TestFormat(TestCaseWithBranch):
 
 
631
639
                         branch.BranchFormat.find_format(opened_control))
 
 
642
class TestBound(TestCaseWithBranch):
 
 
644
    def test_bind_unbind(self):
 
 
645
        branch = self.make_branch('1')
 
 
646
        branch2 = self.make_branch('2')
 
 
649
        except errors.UpgradeRequired:
 
 
650
            raise TestSkipped('Format does not support binding')
 
 
651
        self.assertTrue(branch.unbind())
 
 
652
        self.assertFalse(branch.unbind())
 
 
653
        self.assertIs(None, branch.get_bound_location())
 
 
655
    def test_old_bound_location(self):
 
 
656
        branch = self.make_branch('branch1')
 
 
658
            self.assertIs(None, branch.get_old_bound_location())
 
 
659
        except errors.UpgradeRequired:
 
 
660
            raise TestSkipped('Format does not store old bound locations')
 
 
661
        branch2 = self.make_branch('branch2')
 
 
663
        self.assertIs(None, branch.get_old_bound_location())
 
 
665
        self.assertContainsRe(branch.get_old_bound_location(), '\/branch2\/$')
 
 
668
class TestStrict(TestCaseWithBranch):
 
 
670
    def test_strict_history(self):
 
 
671
        tree1 = self.make_branch_and_tree('tree1')
 
 
673
            tree1.branch.set_append_revisions_only(True)
 
 
674
        except errors.UpgradeRequired:
 
 
675
            raise TestSkipped('Format does not support strict history')
 
 
676
        tree1.commit('empty commit')
 
 
677
        tree2 = tree1.bzrdir.sprout('tree2').open_workingtree()
 
 
678
        tree2.commit('empty commit 2')
 
 
679
        tree1.pull(tree2.branch)
 
 
680
        tree1.commit('empty commit 3')
 
 
681
        tree2.commit('empty commit 4')
 
 
682
        self.assertRaises(errors.DivergedBranches, tree1.pull, tree2.branch)
 
 
683
        tree2.merge_from_branch(tree1.branch)
 
 
684
        tree2.commit('empty commit 5')
 
 
685
        self.assertRaises(errors.AppendRevisionsOnlyViolation, tree1.pull,
 
 
687
        tree3 = tree1.bzrdir.sprout('tree3').open_workingtree()
 
 
688
        tree3.merge_from_branch(tree2.branch)
 
 
689
        tree3.commit('empty commit 6')
 
 
690
        tree2.pull(tree3.branch)