~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_repository.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-02-13 11:48:14 UTC
  • mfrom: (2241.1.20 repoformats)
  • Revision ID: pqm@pqm.ubuntu.com-20070213114814-9606106906ac312f
(mbp) split repository formats into repofmt (r=john)

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 knitrepo, weaverepo
46
47
 
47
48
 
48
49
class TestDefaultFormat(TestCase):
111
112
            t = get_transport(url)
112
113
            found_format = repository.RepositoryFormat.find_format(dir)
113
114
            self.failUnless(isinstance(found_format, format.__class__))
114
 
        check_format(repository.RepositoryFormat7(), "bar")
 
115
        check_format(weaverepo.RepositoryFormat7(), "bar")
115
116
        
116
117
    def test_find_format_no_repository(self):
117
118
        dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
146
147
 
147
148
    def test_no_ancestry_weave(self):
148
149
        control = bzrdir.BzrDirFormat6().initialize(self.get_url())
149
 
        repo = repository.RepositoryFormat6().initialize(control)
 
150
        repo = weaverepo.RepositoryFormat6().initialize(control)
150
151
        # We no longer need to create the ancestry.weave file
151
152
        # since it is *never* used.
152
153
        self.assertRaises(NoSuchFile,
158
159
    
159
160
    def test_disk_layout(self):
160
161
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
161
 
        repo = repository.RepositoryFormat7().initialize(control)
 
162
        repo = weaverepo.RepositoryFormat7().initialize(control)
162
163
        # in case of side effects of locking.
163
164
        repo.lock_write()
164
165
        repo.unlock()
180
181
 
181
182
    def test_shared_disk_layout(self):
182
183
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
183
 
        repo = repository.RepositoryFormat7().initialize(control, shared=True)
 
184
        repo = weaverepo.RepositoryFormat7().initialize(control, shared=True)
184
185
        # we want:
185
186
        # format 'Bazaar-NG Repository format 7'
186
187
        # inventory.weave == empty_weave
203
204
    def test_creates_lockdir(self):
204
205
        """Make sure it appears to be controlled by a LockDir existence"""
205
206
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
206
 
        repo = repository.RepositoryFormat7().initialize(control, shared=True)
 
207
        repo = weaverepo.RepositoryFormat7().initialize(control, shared=True)
207
208
        t = control.get_repository_transport(None)
208
209
        # TODO: Should check there is a 'lock' toplevel directory, 
209
210
        # regardless of contents
219
220
        """repo format 7 actually locks on lockdir"""
220
221
        base_url = self.get_url()
221
222
        control = bzrdir.BzrDirMetaFormat1().initialize(base_url)
222
 
        repo = repository.RepositoryFormat7().initialize(control, shared=True)
 
223
        repo = weaverepo.RepositoryFormat7().initialize(control, shared=True)
223
224
        t = control.get_repository_transport(None)
224
225
        repo.lock_write()
225
226
        repo.unlock()
233
234
 
234
235
    def test_shared_no_tree_disk_layout(self):
235
236
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
236
 
        repo = repository.RepositoryFormat7().initialize(control, shared=True)
 
237
        repo = weaverepo.RepositoryFormat7().initialize(control, shared=True)
237
238
        repo.set_make_working_trees(False)
238
239
        # we want:
239
240
        # format 'Bazaar-NG Repository format 7'
262
263
    
263
264
    def test_disk_layout(self):
264
265
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
265
 
        repo = repository.RepositoryFormatKnit1().initialize(control)
 
266
        repo = knitrepo.RepositoryFormatKnit1().initialize(control)
266
267
        # in case of side effects of locking.
267
268
        repo.lock_write()
268
269
        repo.unlock()
295
296
 
296
297
    def test_shared_disk_layout(self):
297
298
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
298
 
        repo = repository.RepositoryFormatKnit1().initialize(control, shared=True)
 
299
        repo = knitrepo.RepositoryFormatKnit1().initialize(control, shared=True)
299
300
        # we want:
300
301
        # format 'Bazaar-NG Knit Repository Format 1'
301
302
        # lock: is a directory
314
315
 
315
316
    def test_shared_no_tree_disk_layout(self):
316
317
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
317
 
        repo = repository.RepositoryFormatKnit1().initialize(control, shared=True)
 
318
        repo = knitrepo.RepositoryFormatKnit1().initialize(control, shared=True)
318
319
        repo.set_make_working_trees(False)
319
320
        # we want:
320
321
        # format 'Bazaar-NG Knit Repository Format 1'
402
403
    def test_is_compatible_and_registered(self):
403
404
        # InterWeaveRepo is compatible when either side
404
405
        # is a format 5/6/7 branch
405
 
        formats = [repository.RepositoryFormat5(),
406
 
                   repository.RepositoryFormat6(),
407
 
                   repository.RepositoryFormat7()]
408
 
        incompatible_formats = [repository.RepositoryFormat4(),
409
 
                                repository.RepositoryFormatKnit1(),
 
406
        from bzrlib.repofmt import knitrepo, weaverepo
 
407
        formats = [weaverepo.RepositoryFormat5(),
 
408
                   weaverepo.RepositoryFormat6(),
 
409
                   weaverepo.RepositoryFormat7()]
 
410
        incompatible_formats = [weaverepo.RepositoryFormat4(),
 
411
                                knitrepo.RepositoryFormatKnit1(),
410
412
                                ]
411
413
        repo_a = self.make_repository('a')
412
414
        repo_b = self.make_repository('b')
433
435
        t = get_transport(self.get_url('.'))
434
436
        t.mkdir('repository')
435
437
        repo_dir = bzrdir.BzrDirMetaFormat1().initialize('repository')
436
 
        repo = repository.RepositoryFormat7().initialize(repo_dir)
437
 
        target_format = repository.RepositoryFormatKnit1()
 
438
        repo = weaverepo.RepositoryFormat7().initialize(repo_dir)
 
439
        target_format = knitrepo.RepositoryFormatKnit1()
438
440
        converter = repository.CopyConverter(target_format)
439
441
        pb = bzrlib.ui.ui_factory.nested_progress_bar()
440
442
        try:
457
459
    def test_convert(self):
458
460
        """Ensure the upgrade adds weaves for roots"""
459
461
        format = bzrdir.BzrDirMetaFormat1()
460
 
        format.repository_format = repository.RepositoryFormatKnit1()
 
462
        format.repository_format = knitrepo.RepositoryFormatKnit1()
461
463
        tree = self.make_branch_and_tree('.', format)
462
464
        tree.commit("Dull commit", rev_id="dull")
463
465
        revision_tree = tree.branch.repository.revision_tree('dull')
464
466
        self.assertRaises(errors.NoSuchFile, revision_tree.get_file_lines,
465
467
            revision_tree.inventory.root.file_id)
466
468
        format = bzrdir.BzrDirMetaFormat1()
467
 
        format.repository_format = repository.RepositoryFormatKnit2()
 
469
        format.repository_format = knitrepo.RepositoryFormatKnit2()
468
470
        upgrade.Convert('.', format)
469
471
        tree = workingtree.WorkingTree.open('.')
470
472
        revision_tree = tree.branch.repository.revision_tree('dull')