~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_repository.py

  • Committer: Robert Collins
  • Date: 2006-02-21 05:45:21 UTC
  • mto: (1563.1.5 integration)
  • mto: This revision was merged to the branch mainline in revision 1568.
  • Revision ID: robertc@robertcollins.net-20060221054521-b26e1fd3b723dc00
Rearrangment of Repository logic to be less type code driven, and bugfix InterRepository.missing_revision_ids

Show diffs side-by-side

added added

removed removed

Lines of Context:
213
213
                             t.get('inventory.weave').read())
214
214
 
215
215
 
 
216
class TestFormatKnit1(TestCaseWithTransport):
 
217
    
 
218
    def test_disk_layout(self):
 
219
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
 
220
        repo = repository.RepositoryFormatKnit1().initialize(control)
 
221
        # in case of side effects of locking.
 
222
        repo.lock_write()
 
223
        repo.unlock()
 
224
        # we want:
 
225
        # format 'Bazaar-NG Knit Repository Format 1'
 
226
        # lock ''
 
227
        # inventory.weave == empty_weave
 
228
        # empty revision-store directory
 
229
        # empty weaves directory
 
230
        t = control.get_repository_transport(None)
 
231
        self.assertEqualDiff('Bazaar-NG Knit Repository Format 1',
 
232
                             t.get('format').read())
 
233
        self.assertEqualDiff('', t.get('lock').read())
 
234
        self.assertTrue(S_ISDIR(t.stat('revision-store').st_mode))
 
235
        self.assertTrue(S_ISDIR(t.stat('knits').st_mode))
 
236
        # cheating and using a weave for now.
 
237
        self.assertEqualDiff('# bzr weave file v5\n'
 
238
                             'w\n'
 
239
                             'W\n',
 
240
                             t.get('inventory.weave').read())
 
241
 
 
242
    def test_shared_disk_layout(self):
 
243
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
 
244
        repo = repository.RepositoryFormatKnit1().initialize(control, shared=True)
 
245
        # we want:
 
246
        # format 'Bazaar-NG Knit Repository Format 1'
 
247
        # lock ''
 
248
        # inventory.weave == empty_weave
 
249
        # empty revision-store directory
 
250
        # empty weaves directory
 
251
        # a 'shared-storage' marker file.
 
252
        t = control.get_repository_transport(None)
 
253
        self.assertEqualDiff('Bazaar-NG Knit Repository Format 1',
 
254
                             t.get('format').read())
 
255
        self.assertEqualDiff('', t.get('lock').read())
 
256
        self.assertEqualDiff('', t.get('shared-storage').read())
 
257
        self.assertTrue(S_ISDIR(t.stat('revision-store').st_mode))
 
258
        self.assertTrue(S_ISDIR(t.stat('knits').st_mode))
 
259
        # cheating and using a weave for now.
 
260
        self.assertEqualDiff('# bzr weave file v5\n'
 
261
                             'w\n'
 
262
                             'W\n',
 
263
                             t.get('inventory.weave').read())
 
264
 
 
265
    def test_shared_no_tree_disk_layout(self):
 
266
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
 
267
        repo = repository.RepositoryFormatKnit1().initialize(control, shared=True)
 
268
        repo.set_make_working_trees(False)
 
269
        # we want:
 
270
        # format 'Bazaar-NG Knit Repository Format 1'
 
271
        # lock ''
 
272
        # inventory.weave == empty_weave
 
273
        # empty revision-store directory
 
274
        # empty weaves directory
 
275
        # a 'shared-storage' marker file.
 
276
        t = control.get_repository_transport(None)
 
277
        self.assertEqualDiff('Bazaar-NG Knit Repository Format 1',
 
278
                             t.get('format').read())
 
279
        self.assertEqualDiff('', t.get('lock').read())
 
280
        self.assertEqualDiff('', t.get('shared-storage').read())
 
281
        self.assertEqualDiff('', t.get('no-working-trees').read())
 
282
        repo.set_make_working_trees(True)
 
283
        self.assertFalse(t.has('no-working-trees'))
 
284
        self.assertTrue(S_ISDIR(t.stat('revision-store').st_mode))
 
285
        self.assertTrue(S_ISDIR(t.stat('knits').st_mode))
 
286
        # cheating and using a weave for now.
 
287
        self.assertEqualDiff('# bzr weave file v5\n'
 
288
                             'w\n'
 
289
                             'W\n',
 
290
                             t.get('inventory.weave').read())
 
291
 
 
292
 
216
293
class InterString(repository.InterRepository):
217
294
    """An inter-repository optimised code path for strings.
218
295
 
282
359
        formats = [repository.RepositoryFormat5(),
283
360
                   repository.RepositoryFormat6(),
284
361
                   repository.RepositoryFormat7()]
 
362
        incompatible_formats = [repository.RepositoryFormat4(),
 
363
                                repository.RepositoryFormatKnit1(),
 
364
                                ]
285
365
        repo_a = self.make_repository('a')
286
366
        repo_b = self.make_repository('b')
287
 
        # force incompatible left then right
288
 
        repo_a._format = repository.RepositoryFormat4()
289
 
        repo_b._format = formats[0]
290
367
        is_compatible = repository.InterWeaveRepo.is_compatible
291
 
        self.assertFalse(is_compatible(repo_a, repo_b))
292
 
        self.assertFalse(is_compatible(repo_b, repo_a))
 
368
        for source in incompatible_formats:
 
369
            # force incompatible left then right
 
370
            repo_a._format = source
 
371
            repo_b._format = formats[0]
 
372
            self.assertFalse(is_compatible(repo_a, repo_b))
 
373
            self.assertFalse(is_compatible(repo_b, repo_a))
293
374
        for source in formats:
294
375
            repo_a._format = source
295
376
            for target in formats: