213
214
t.get('inventory.weave').read())
217
class TestFormatKnit1(TestCaseWithTransport):
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.
226
# format 'Bazaar-NG Knit Repository Format 1'
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'
241
t.get('inventory.weave').read())
243
def test_shared_disk_layout(self):
244
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
245
repo = repository.RepositoryFormatKnit1().initialize(control, shared=True)
247
# format 'Bazaar-NG Knit Repository Format 1'
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'
264
t.get('inventory.weave').read())
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)
271
# format 'Bazaar-NG Knit Repository Format 1'
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'
291
t.get('inventory.weave').read())
216
294
class InterString(repository.InterRepository):
217
295
"""An inter-repository optimised code path for strings.
282
360
formats = [repository.RepositoryFormat5(),
283
361
repository.RepositoryFormat6(),
284
362
repository.RepositoryFormat7()]
363
incompatible_formats = [repository.RepositoryFormat4(),
364
repository.RepositoryFormatKnit1(),
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__)
385
class TestRepositoryConverter(TestCaseWithTransport):
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()
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__))