~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: 2006-02-22 06:19:39 UTC
  • mfrom: (1563.1.5 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060222061939-b4b7825d1d580ccf
Merge in ui for creating and converting to knit branch - no backend support yet.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
from stat import *
26
26
from StringIO import StringIO
27
27
 
 
28
import bzrlib
28
29
import bzrlib.bzrdir as bzrdir
29
30
import bzrlib.errors as errors
30
31
from bzrlib.errors import (NotBranchError,
213
214
                             t.get('inventory.weave').read())
214
215
 
215
216
 
 
217
class TestFormatKnit1(TestCaseWithTransport):
 
218
    
 
219
    def test_disk_layout(self):
 
220
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
 
221
        repo = repository.RepositoryFormatKnit1().initialize(control)
 
222
        # in case of side effects of locking.
 
223
        repo.lock_write()
 
224
        repo.unlock()
 
225
        # we want:
 
226
        # format 'Bazaar-NG Knit Repository Format 1'
 
227
        # lock ''
 
228
        # inventory.weave == empty_weave
 
229
        # empty revision-store directory
 
230
        # empty weaves directory
 
231
        t = control.get_repository_transport(None)
 
232
        self.assertEqualDiff('Bazaar-NG Knit Repository Format 1',
 
233
                             t.get('format').read())
 
234
        self.assertEqualDiff('', t.get('lock').read())
 
235
        self.assertTrue(S_ISDIR(t.stat('revision-store').st_mode))
 
236
        self.assertTrue(S_ISDIR(t.stat('knits').st_mode))
 
237
        # cheating and using a weave for now.
 
238
        self.assertEqualDiff('# bzr weave file v5\n'
 
239
                             'w\n'
 
240
                             'W\n',
 
241
                             t.get('inventory.weave').read())
 
242
 
 
243
    def test_shared_disk_layout(self):
 
244
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
 
245
        repo = repository.RepositoryFormatKnit1().initialize(control, shared=True)
 
246
        # we want:
 
247
        # format 'Bazaar-NG Knit Repository Format 1'
 
248
        # lock ''
 
249
        # inventory.weave == empty_weave
 
250
        # empty revision-store directory
 
251
        # empty weaves directory
 
252
        # a 'shared-storage' marker file.
 
253
        t = control.get_repository_transport(None)
 
254
        self.assertEqualDiff('Bazaar-NG Knit Repository Format 1',
 
255
                             t.get('format').read())
 
256
        self.assertEqualDiff('', t.get('lock').read())
 
257
        self.assertEqualDiff('', t.get('shared-storage').read())
 
258
        self.assertTrue(S_ISDIR(t.stat('revision-store').st_mode))
 
259
        self.assertTrue(S_ISDIR(t.stat('knits').st_mode))
 
260
        # cheating and using a weave for now.
 
261
        self.assertEqualDiff('# bzr weave file v5\n'
 
262
                             'w\n'
 
263
                             'W\n',
 
264
                             t.get('inventory.weave').read())
 
265
 
 
266
    def test_shared_no_tree_disk_layout(self):
 
267
        control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
 
268
        repo = repository.RepositoryFormatKnit1().initialize(control, shared=True)
 
269
        repo.set_make_working_trees(False)
 
270
        # we want:
 
271
        # format 'Bazaar-NG Knit Repository Format 1'
 
272
        # lock ''
 
273
        # inventory.weave == empty_weave
 
274
        # empty revision-store directory
 
275
        # empty weaves directory
 
276
        # a 'shared-storage' marker file.
 
277
        t = control.get_repository_transport(None)
 
278
        self.assertEqualDiff('Bazaar-NG Knit Repository Format 1',
 
279
                             t.get('format').read())
 
280
        self.assertEqualDiff('', t.get('lock').read())
 
281
        self.assertEqualDiff('', t.get('shared-storage').read())
 
282
        self.assertEqualDiff('', t.get('no-working-trees').read())
 
283
        repo.set_make_working_trees(True)
 
284
        self.assertFalse(t.has('no-working-trees'))
 
285
        self.assertTrue(S_ISDIR(t.stat('revision-store').st_mode))
 
286
        self.assertTrue(S_ISDIR(t.stat('knits').st_mode))
 
287
        # cheating and using a weave for now.
 
288
        self.assertEqualDiff('# bzr weave file v5\n'
 
289
                             'w\n'
 
290
                             'W\n',
 
291
                             t.get('inventory.weave').read())
 
292
 
 
293
 
216
294
class InterString(repository.InterRepository):
217
295
    """An inter-repository optimised code path for strings.
218
296
 
282
360
        formats = [repository.RepositoryFormat5(),
283
361
                   repository.RepositoryFormat6(),
284
362
                   repository.RepositoryFormat7()]
 
363
        incompatible_formats = [repository.RepositoryFormat4(),
 
364
                                repository.RepositoryFormatKnit1(),
 
365
                                ]
285
366
        repo_a = self.make_repository('a')
286
367
        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
368
        is_compatible = repository.InterWeaveRepo.is_compatible
291
 
        self.assertFalse(is_compatible(repo_a, repo_b))
292
 
        self.assertFalse(is_compatible(repo_b, repo_a))
 
369
        for source in incompatible_formats:
 
370
            # force incompatible left then right
 
371
            repo_a._format = source
 
372
            repo_b._format = formats[0]
 
373
            self.assertFalse(is_compatible(repo_a, repo_b))
 
374
            self.assertFalse(is_compatible(repo_b, repo_a))
293
375
        for source in formats:
294
376
            repo_a._format = source
295
377
            for target in formats:
298
380
        self.assertEqual(repository.InterWeaveRepo,
299
381
                         repository.InterRepository.get(repo_a,
300
382
                                                        repo_b).__class__)
 
383
 
 
384
 
 
385
class TestRepositoryConverter(TestCaseWithTransport):
 
386
 
 
387
    def test_convert_empty(self):
 
388
        t = get_transport(self.get_url('.'))
 
389
        t.mkdir('repository')
 
390
        repo_dir = bzrdir.BzrDirMetaFormat1().initialize('repository')
 
391
        repo = repository.RepositoryFormat7().initialize(repo_dir)
 
392
        target_format = repository.RepositoryFormatKnit1()
 
393
        pb = bzrlib.ui.ui_factory.progress_bar()
 
394
 
 
395
        converter = repository.CopyConverter(target_format)
 
396
        converter.convert(repo, pb)
 
397
        repo = repo_dir.open_repository()
 
398
        self.assertTrue(isinstance(target_format, repo._format.__class__))
 
399