~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_repository.py

  • Committer: Jelmer Vernooij
  • Date: 2011-01-11 04:33:12 UTC
  • mto: (5582.12.2 weave-plugin)
  • mto: This revision was merged to the branch mainline in revision 5718.
  • Revision ID: jelmer@samba.org-20110111043312-g4wx6iuf9662f36d
Move weave formats into bzrlib.plugins.weave_fmt.

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
    groupcompress_repo,
61
61
    knitrepo,
62
62
    pack_repo,
63
 
    weaverepo,
64
63
    )
65
64
 
66
65
 
131
130
            t = get_transport(url)
132
131
            found_format = repository.RepositoryFormat.find_format(dir)
133
132
            self.failUnless(isinstance(found_format, format.__class__))
134
 
        check_format(weaverepo.RepositoryFormat7(), "bar")
 
133
        from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
 
134
        check_format(RepositoryFormat7(), "bar")
135
135
 
136
136
    def test_find_format_no_repository(self):
137
137
        dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
167
167
    def test_attribute__fetch_order(self):
168
168
        """Weaves need topological data insertion."""
169
169
        control = bzrdir.BzrDirFormat6().initialize(self.get_url())
170
 
        repo = weaverepo.RepositoryFormat6().initialize(control)
 
170
        from bzrlib.plugins.weave_fmt.repository import RepositoryFormat6
 
171
        repo = RepositoryFormat6().initialize(control)
171
172
        self.assertEqual('topological', repo._format._fetch_order)
172
173
 
173
174
    def test_attribute__fetch_uses_deltas(self):
174
175
        """Weaves do not reuse deltas."""
175
176
        control = bzrdir.BzrDirFormat6().initialize(self.get_url())
176
 
        repo = weaverepo.RepositoryFormat6().initialize(control)
 
177
        from bzrlib.plugins.weave_fmt.repository import RepositoryFormat6
 
178
        repo = RepositoryFormat6().initialize(control)
177
179
        self.assertEqual(False, repo._format._fetch_uses_deltas)
178
180
 
179
181
    def test_attribute__fetch_reconcile(self):
180
182
        """Weave repositories need a reconcile after fetch."""
181
183
        control = bzrdir.BzrDirFormat6().initialize(self.get_url())
182
 
        repo = weaverepo.RepositoryFormat6().initialize(control)
 
184
        from bzrlib.plugins.weave_fmt.repository import RepositoryFormat6
 
185
        repo = RepositoryFormat6().initialize(control)
183
186
        self.assertEqual(True, repo._format._fetch_reconcile)
184
187
 
185
188
    def test_no_ancestry_weave(self):
186
189
        control = bzrdir.BzrDirFormat6().initialize(self.get_url())
187
 
        repo = weaverepo.RepositoryFormat6().initialize(control)
 
190
        from bzrlib.plugins.weave_fmt.repository import RepositoryFormat6
 
191
        repo = RepositoryFormat6().initialize(control)
188
192
        # We no longer need to create the ancestry.weave file
189
193
        # since it is *never* used.
190
194
        self.assertRaises(NoSuchFile,
193
197
 
194
198
    def test_supports_external_lookups(self):
195
199
        control = bzrdir.BzrDirFormat6().initialize(self.get_url())
196
 
        repo = weaverepo.RepositoryFormat6().initialize(control)
 
200
        from bzrlib.plugins.weave_fmt.repository import RepositoryFormat6
 
201
        repo = RepositoryFormat6().initialize(control)
197
202
        self.assertFalse(repo._format.supports_external_lookups)
198
203
 
199
204
 
202
207
    def test_attribute__fetch_order(self):
203
208
        """Weaves need topological data insertion."""
204
209
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
205
 
        repo = weaverepo.RepositoryFormat7().initialize(control)
 
210
        from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
 
211
        repo = RepositoryFormat7().initialize(control)
206
212
        self.assertEqual('topological', repo._format._fetch_order)
207
213
 
208
214
    def test_attribute__fetch_uses_deltas(self):
209
215
        """Weaves do not reuse deltas."""
210
216
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
211
 
        repo = weaverepo.RepositoryFormat7().initialize(control)
 
217
        from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
 
218
        repo = RepositoryFormat7().initialize(control)
212
219
        self.assertEqual(False, repo._format._fetch_uses_deltas)
213
220
 
214
221
    def test_attribute__fetch_reconcile(self):
215
222
        """Weave repositories need a reconcile after fetch."""
216
223
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
217
 
        repo = weaverepo.RepositoryFormat7().initialize(control)
 
224
        from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
 
225
        repo = RepositoryFormat7().initialize(control)
218
226
        self.assertEqual(True, repo._format._fetch_reconcile)
219
227
 
220
228
    def test_disk_layout(self):
221
229
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
222
 
        repo = weaverepo.RepositoryFormat7().initialize(control)
 
230
        from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
 
231
        repo = RepositoryFormat7().initialize(control)
223
232
        # in case of side effects of locking.
224
233
        repo.lock_write()
225
234
        repo.unlock()
267
276
 
268
277
    def test_shared_disk_layout(self):
269
278
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
270
 
        repo = weaverepo.RepositoryFormat7().initialize(control, shared=True)
 
279
        from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
 
280
        repo = RepositoryFormat7().initialize(control, shared=True)
271
281
        # we want:
272
282
        # format 'Bazaar-NG Repository format 7'
273
283
        # inventory.weave == empty_weave
290
300
    def test_creates_lockdir(self):
291
301
        """Make sure it appears to be controlled by a LockDir existence"""
292
302
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
293
 
        repo = weaverepo.RepositoryFormat7().initialize(control, shared=True)
 
303
        from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
 
304
        repo = RepositoryFormat7().initialize(control, shared=True)
294
305
        t = control.get_repository_transport(None)
295
306
        # TODO: Should check there is a 'lock' toplevel directory,
296
307
        # regardless of contents
306
317
        """repo format 7 actually locks on lockdir"""
307
318
        base_url = self.get_url()
308
319
        control = bzrdir.BzrDirMetaFormat1().initialize(base_url)
309
 
        repo = weaverepo.RepositoryFormat7().initialize(control, shared=True)
 
320
        from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
 
321
        repo = RepositoryFormat7().initialize(control, shared=True)
310
322
        t = control.get_repository_transport(None)
311
323
        repo.lock_write()
312
324
        repo.unlock()
320
332
 
321
333
    def test_shared_no_tree_disk_layout(self):
322
334
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
323
 
        repo = weaverepo.RepositoryFormat7().initialize(control, shared=True)
 
335
        from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
 
336
        repo = RepositoryFormat7().initialize(control, shared=True)
324
337
        repo.set_make_working_trees(False)
325
338
        # we want:
326
339
        # format 'Bazaar-NG Repository format 7'
346
359
 
347
360
    def test_supports_external_lookups(self):
348
361
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
349
 
        repo = weaverepo.RepositoryFormat7().initialize(control)
 
362
        from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
 
363
        repo = RepositoryFormat7().initialize(control)
350
364
        self.assertFalse(repo._format.supports_external_lookups)
351
365
 
352
366
 
577
591
    def test_is_compatible_and_registered(self):
578
592
        # InterWeaveRepo is compatible when either side
579
593
        # is a format 5/6/7 branch
580
 
        from bzrlib.repofmt import knitrepo, weaverepo
581
 
        formats = [weaverepo.RepositoryFormat5(),
582
 
                   weaverepo.RepositoryFormat6(),
583
 
                   weaverepo.RepositoryFormat7()]
584
 
        incompatible_formats = [weaverepo.RepositoryFormat4(),
 
594
        from bzrlib.repofmt import knitrepo
 
595
        from bzrlib.plugins.weave_fmt.repository import (
 
596
            InterWeaveRepo, RepositoryFormat4, RepositoryFormat5,
 
597
            RepositoryFormat6, RepositoryFormat7)
 
598
        formats = [RepositoryFormat5(),
 
599
                   RepositoryFormat6(),
 
600
                   RepositoryFormat7()]
 
601
        incompatible_formats = [RepositoryFormat4(),
585
602
                                knitrepo.RepositoryFormatKnit1(),
586
603
                                ]
587
604
        repo_a = self.make_repository('a')
588
605
        repo_b = self.make_repository('b')
589
 
        is_compatible = weaverepo.InterWeaveRepo.is_compatible
 
606
        is_compatible = InterWeaveRepo.is_compatible
590
607
        for source in incompatible_formats:
591
608
            # force incompatible left then right
592
609
            repo_a._format = source
598
615
            for target in formats:
599
616
                repo_b._format = target
600
617
                self.assertTrue(is_compatible(repo_a, repo_b))
601
 
        self.assertEqual(weaverepo.InterWeaveRepo,
 
618
        self.assertEqual(InterWeaveRepo,
602
619
                         repository.InterRepository.get(repo_a,
603
620
                                                        repo_b).__class__)
604
621
 
606
623
class TestRepositoryConverter(TestCaseWithTransport):
607
624
 
608
625
    def test_convert_empty(self):
 
626
        from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
609
627
        t = get_transport(self.get_url('.'))
610
628
        t.mkdir('repository')
611
629
        repo_dir = bzrdir.BzrDirMetaFormat1().initialize('repository')
612
 
        repo = weaverepo.RepositoryFormat7().initialize(repo_dir)
 
630
        repo = RepositoryFormat7().initialize(repo_dir)
613
631
        target_format = knitrepo.RepositoryFormatKnit1()
614
632
        converter = repository.CopyConverter(target_format)
615
633
        pb = bzrlib.ui.ui_factory.nested_progress_bar()