~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_repository/test_repository.py

  • Committer: Martin Pool
  • Date: 2010-04-01 04:41:18 UTC
  • mto: This revision was merged to the branch mainline in revision 5128.
  • Revision ID: mbp@sourcefrog.net-20100401044118-shyctqc02ob08ngz
ignore .testrepository

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
    per_repository,
48
48
    test_server,
49
49
    )
50
 
from bzrlib.tests.matchers import *
51
50
 
52
51
 
53
52
class TestRepositoryMakeBranchAndTree(per_repository.TestCaseWithRepository):
725
724
        self.assertTrue('ghost' not in parents)
726
725
        self.assertEqual(parents['rev2'], ('rev1', 'ghost'))
727
726
 
728
 
    def test_get_known_graph_ancestry(self):
729
 
        tree = self.make_branch_and_tree('here')
730
 
        tree.lock_write()
731
 
        self.addCleanup(tree.unlock)
732
 
        # A
733
 
        # |\
734
 
        # | B
735
 
        # |/
736
 
        # C
737
 
        tree.commit('initial commit', rev_id='A')
738
 
        tree_other = tree.bzrdir.sprout('there').open_workingtree()
739
 
        tree_other.commit('another', rev_id='B')
740
 
        tree.merge_from_branch(tree_other.branch)
741
 
        tree.commit('another', rev_id='C')
742
 
        kg = tree.branch.repository.get_known_graph_ancestry(
743
 
            ['C'])
744
 
        self.assertEqual(['C'], list(kg.heads(['A', 'B', 'C'])))
745
 
        self.assertEqual(['A', 'B', 'C'], list(kg.topo_sort()))
746
 
 
747
727
    def test_parent_map_type(self):
748
728
        tree = self.make_branch_and_tree('here')
749
729
        tree.lock_write()
1088
1068
        repo = self.make_repository('r')
1089
1069
        # Lock the repository, then use leave_lock_in_place so that when we
1090
1070
        # unlock the repository the lock is still held on disk.
1091
 
        token = repo.lock_write().repository_token
 
1071
        token = repo.lock_write()
1092
1072
        try:
1093
1073
            if token is None:
1094
1074
                # This test does not apply, because this repository refuses lock
1108
1088
    def test_dont_leave_lock_in_place(self):
1109
1089
        repo = self.make_repository('r')
1110
1090
        # Create a lock on disk.
1111
 
        token = repo.lock_write().repository_token
 
1091
        token = repo.lock_write()
1112
1092
        try:
1113
1093
            if token is None:
1114
1094
                # This test does not apply, because this repository refuses lock
1142
1122
        repo.lock_read()
1143
1123
        repo.unlock()
1144
1124
 
1145
 
    def test_lock_read_returns_unlockable(self):
1146
 
        repo = self.make_repository('r')
1147
 
        self.assertThat(repo.lock_read, ReturnsUnlockable(repo))
1148
 
 
1149
 
    def test_lock_write_returns_unlockable(self):
1150
 
        repo = self.make_repository('r')
1151
 
        self.assertThat(repo.lock_write, ReturnsUnlockable(repo))
1152
 
 
1153
1125
 
1154
1126
class TestCaseWithComplexRepository(per_repository.TestCaseWithRepository):
1155
1127
 
1351
1323
        fileobj = StringIO()
1352
1324
        wt.branch.repository.create_bundle(
1353
1325
            'rev1', _mod_revision.NULL_REVISION, fileobj)
1354
 
 
1355
 
 
1356
 
 
1357
 
 
1358
 
class TestRepositoryControlComponent(per_repository.TestCaseWithRepository):
1359
 
    """Repository implementations adequately implement ControlComponent."""
1360
 
    
1361
 
    def test_urls(self):
1362
 
        repo = self.make_repository('repo')
1363
 
        self.assertIsInstance(repo.user_url, str)
1364
 
        self.assertEqual(repo.user_url, repo.user_transport.base)
1365
 
        # for all current bzrdir implementations the user dir must be 
1366
 
        # above the control dir but we might need to relax that?
1367
 
        self.assertEqual(repo.control_url.find(repo.user_url), 0)
1368
 
        self.assertEqual(repo.control_url, repo.control_transport.base)