~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_repository.py

  • Committer: Martin Pool
  • Date: 2007-02-06 06:27:24 UTC
  • mto: This revision was merged to the branch mainline in revision 2283.
  • Revision ID: mbp@sourcefrog.net-20070206062724-a5uo1u27jxsal2t0
Moved old weave-based repository formats into bzrlib.repofmt.weaverepo.

Change help for --format to just say 'see help formats'

RepositoryFormat.register_metadir gains an optional parameter for the
module name containing the repository format, and lazily loads from there.

Disable test_interrepository_get_returns_correct_optimiser, because it
seems too brittle.

Remove InterWeaveRepo, these should now just be upgraded.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006, 2007 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
43
43
    upgrade,
44
44
    workingtree,
45
45
    )
 
46
from bzrlib.repofmt import weaverepo
46
47
 
47
48
 
48
49
class TestDefaultFormat(TestCase):
108
109
            t = get_transport(url)
109
110
            found_format = repository.RepositoryFormat.find_format(dir)
110
111
            self.failUnless(isinstance(found_format, format.__class__))
111
 
        check_format(repository.RepositoryFormat7(), "bar")
 
112
        check_format(weaverepo.RepositoryFormat7(), "bar")
112
113
        
113
114
    def test_find_format_no_repository(self):
114
115
        dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
143
144
 
144
145
    def test_no_ancestry_weave(self):
145
146
        control = bzrdir.BzrDirFormat6().initialize(self.get_url())
146
 
        repo = repository.RepositoryFormat6().initialize(control)
 
147
        repo = weaverepo.RepositoryFormat6().initialize(control)
147
148
        # We no longer need to create the ancestry.weave file
148
149
        # since it is *never* used.
149
150
        self.assertRaises(NoSuchFile,
155
156
    
156
157
    def test_disk_layout(self):
157
158
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
158
 
        repo = repository.RepositoryFormat7().initialize(control)
 
159
        repo = weaverepo.RepositoryFormat7().initialize(control)
159
160
        # in case of side effects of locking.
160
161
        repo.lock_write()
161
162
        repo.unlock()
177
178
 
178
179
    def test_shared_disk_layout(self):
179
180
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
180
 
        repo = repository.RepositoryFormat7().initialize(control, shared=True)
 
181
        repo = weaverepo.RepositoryFormat7().initialize(control, shared=True)
181
182
        # we want:
182
183
        # format 'Bazaar-NG Repository format 7'
183
184
        # inventory.weave == empty_weave
200
201
    def test_creates_lockdir(self):
201
202
        """Make sure it appears to be controlled by a LockDir existence"""
202
203
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
203
 
        repo = repository.RepositoryFormat7().initialize(control, shared=True)
 
204
        repo = weaverepo.RepositoryFormat7().initialize(control, shared=True)
204
205
        t = control.get_repository_transport(None)
205
206
        # TODO: Should check there is a 'lock' toplevel directory, 
206
207
        # regardless of contents
216
217
        """repo format 7 actually locks on lockdir"""
217
218
        base_url = self.get_url()
218
219
        control = bzrdir.BzrDirMetaFormat1().initialize(base_url)
219
 
        repo = repository.RepositoryFormat7().initialize(control, shared=True)
 
220
        repo = weaverepo.RepositoryFormat7().initialize(control, shared=True)
220
221
        t = control.get_repository_transport(None)
221
222
        repo.lock_write()
222
223
        repo.unlock()
230
231
 
231
232
    def test_shared_no_tree_disk_layout(self):
232
233
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
233
 
        repo = repository.RepositoryFormat7().initialize(control, shared=True)
 
234
        repo = weaverepo.RepositoryFormat7().initialize(control, shared=True)
234
235
        repo.set_make_working_trees(False)
235
236
        # we want:
236
237
        # format 'Bazaar-NG Repository format 7'
394
395
        self.assertGetsDefaultInterRepository(dummy_a, dummy_b)
395
396
 
396
397
 
397
 
class TestInterWeaveRepo(TestCaseWithTransport):
398
 
 
399
 
    def test_is_compatible_and_registered(self):
400
 
        # InterWeaveRepo is compatible when either side
401
 
        # is a format 5/6/7 branch
402
 
        formats = [repository.RepositoryFormat5(),
403
 
                   repository.RepositoryFormat6(),
404
 
                   repository.RepositoryFormat7()]
405
 
        incompatible_formats = [repository.RepositoryFormat4(),
406
 
                                repository.RepositoryFormatKnit1(),
407
 
                                ]
408
 
        repo_a = self.make_repository('a')
409
 
        repo_b = self.make_repository('b')
410
 
        is_compatible = repository.InterWeaveRepo.is_compatible
411
 
        for source in incompatible_formats:
412
 
            # force incompatible left then right
413
 
            repo_a._format = source
414
 
            repo_b._format = formats[0]
415
 
            self.assertFalse(is_compatible(repo_a, repo_b))
416
 
            self.assertFalse(is_compatible(repo_b, repo_a))
417
 
        for source in formats:
418
 
            repo_a._format = source
419
 
            for target in formats:
420
 
                repo_b._format = target
421
 
                self.assertTrue(is_compatible(repo_a, repo_b))
422
 
        self.assertEqual(repository.InterWeaveRepo,
423
 
                         repository.InterRepository.get(repo_a,
424
 
                                                        repo_b).__class__)
425
 
 
426
 
 
427
398
class TestRepositoryConverter(TestCaseWithTransport):
428
399
 
429
400
    def test_convert_empty(self):
430
401
        t = get_transport(self.get_url('.'))
431
402
        t.mkdir('repository')
432
403
        repo_dir = bzrdir.BzrDirMetaFormat1().initialize('repository')
433
 
        repo = repository.RepositoryFormat7().initialize(repo_dir)
 
404
        repo = weaverepo.RepositoryFormat7().initialize(repo_dir)
434
405
        target_format = repository.RepositoryFormatKnit1()
435
406
        converter = repository.CopyConverter(target_format)
436
407
        pb = bzrlib.ui.ui_factory.nested_progress_bar()