~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from bzrlib import (
23
23
    bzrdir,
24
24
    errors,
 
25
    remote,
25
26
    repository,
26
27
    )
27
28
from bzrlib.delta import TreeDelta
36
37
 
37
38
class TestCaseWithRepository(TestCaseWithBzrDir):
38
39
 
39
 
    def make_branch(self, relpath, format=None):
40
 
        repo = self.make_repository(relpath, format=None)
41
 
        return repo.bzrdir.create_branch()
42
 
 
43
40
    def make_repository(self, relpath, format=None):
44
 
        made_control = self.make_bzrdir(relpath)
45
 
        return self.repository_format.initialize(made_control)
 
41
        if format is None:
 
42
            # Create a repository of the type we are trying to test.
 
43
            made_control = self.make_bzrdir(relpath)
 
44
            return self.repository_format.initialize(made_control)
 
45
        else:
 
46
            return super(TestCaseWithRepository, self).make_repository(
 
47
                relpath, format)
46
48
 
47
49
 
48
50
class TestRepositoryMakeBranchAndTree(TestCaseWithRepository):
49
51
 
50
52
    def test_repository_format(self):
51
 
        # make sure the repository on tree.branch is of the desired format
 
53
        # make sure the repository on tree.branch is of the desired format,
 
54
        # because developers use this api to setup the tree, branch and 
 
55
        # repository for their tests: having it now give the right repository
 
56
        # type would invalidate the tests.
52
57
        tree = self.make_branch_and_tree('repo')
53
58
        self.assertIsInstance(tree.branch.repository._format,
54
59
            self.repository_format.__class__)
76
81
        second_revision = tree.commit('')
77
82
        inv = tree.branch.repository.revision_tree(second_revision).inventory
78
83
        rich_root = (inv.root.revision != second_revision)
79
 
        self.assertEqual(rich_root, 
 
84
        self.assertEqual(rich_root,
80
85
                         tree.branch.repository.supports_rich_root())
81
86
 
82
87
    def test_clone_specific_format(self):
183
188
                   revision_id=None,
184
189
                   pb=bzrlib.progress.DummyProgress())
185
190
 
186
 
    def test_fetch_knit2(self):
 
191
    def test_fetch_knit3(self):
 
192
        # create a repository of the sort we are testing.
187
193
        tree_a = self.make_branch_and_tree('a', '')
188
194
        self.build_tree(['a/foo'])
189
195
        tree_a.add('foo', 'file1')
190
196
        tree_a.commit('rev1', rev_id='rev1')
191
 
        # fetch with a default limit (grab everything)
 
197
        # create a knit-3 based format to fetch into
192
198
        f = bzrdir.format_registry.make_bzrdir('dirstate-with-subtree')
193
199
        try:
194
200
            format = tree_a.branch.repository._format
195
201
            format.check_conversion_target(f.repository_format)
 
202
            # if we cannot convert data to knit3, skip the test.
196
203
        except errors.BadConversionTarget, e:
197
204
            raise TestSkipped(str(e))
198
205
        self.get_transport().mkdir('b')
199
206
        b_bzrdir = f.initialize(self.get_url('b'))
200
 
        repo = b_bzrdir.create_repository()
201
 
        repo.fetch(tree_a.branch.repository,
202
 
                   revision_id=None,
203
 
                   pb=bzrlib.progress.DummyProgress())
204
 
        rev1_tree = repo.revision_tree('rev1')
 
207
        knit3_repo = b_bzrdir.create_repository()
 
208
        # fetch with a default limit (grab everything)
 
209
        knit3_repo.fetch(tree_a.branch.repository, revision_id=None)
 
210
        rev1_tree = knit3_repo.revision_tree('rev1')
205
211
        lines = rev1_tree.get_file_lines(rev1_tree.inventory.root.file_id)
206
212
        self.assertEqual([], lines)
207
213
        b_branch = b_bzrdir.create_branch()
212
218
            raise TestSkipped("cannot make working tree with transport %r"
213
219
                              % b_bzrdir.transport)
214
220
        tree_b.commit('no change', rev_id='rev2')
215
 
        rev2_tree = repo.revision_tree('rev2')
 
221
        rev2_tree = knit3_repo.revision_tree('rev2')
216
222
        self.assertEqual('rev1', rev2_tree.inventory.root.revision)
217
223
 
218
224
    def test_get_revision_delta(self):
253
259
        try:
254
260
            made_repo.set_make_working_trees(False)
255
261
        except NotImplementedError:
256
 
            if made_repo.make_working_trees():
257
 
                # this repository always makes working trees.
258
 
                return
 
262
            # the repository does not support having its tree-making flag
 
263
            # toggled.
 
264
            return
259
265
        result = made_control.clone(self.get_url('target'))
260
266
        # Check that we have a repository object.
261
267
        made_repo.has_revision('foo')
395
401
        if self.repository_format.get_format_description() \
396
402
            == "Repository format 4":
397
403
            raise TestSkipped('Cannot convert format-4 to itself')
 
404
        if isinstance(self.repository_format, remote.RemoteRepositoryFormat):
 
405
            return # local conversion to/from RemoteObjects is irrelevant.
398
406
        self.build_tree_contents(_upgrade_dir_template)
399
407
        old_repodir = bzrlib.bzrdir.BzrDir.open_unsupported('.')
400
408
        old_repo_format = old_repodir.open_repository()._format
658
666
    """
659
667
 
660
668
    def test_on_vfat(self):
 
669
        # dont bother with remote repository testing, because this test is
 
670
        # about local disk layout/support.
 
671
        from bzrlib.remote import RemoteRepositoryFormat
 
672
        if isinstance(self.repository_format, RemoteRepositoryFormat):
 
673
            return
661
674
        FOO_ID = 'foo<:>ID'
662
675
        REV_ID = 'revid-1' 
663
676
        # this makes a default format repository always, which is wrong: