1
# Copyright (C) 2006 Canonical Ltd
1
# Copyright (C) 2006, 2007 Canonical Ltd
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
108
109
t = get_transport(url)
109
110
found_format = repository.RepositoryFormat.find_format(dir)
110
111
self.failUnless(isinstance(found_format, format.__class__))
111
check_format(repository.RepositoryFormat7(), "bar")
112
check_format(weaverepo.RepositoryFormat7(), "bar")
113
114
def test_find_format_no_repository(self):
114
115
dir = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
144
145
def test_no_ancestry_weave(self):
145
146
control = bzrdir.BzrDirFormat6().initialize(self.get_url())
146
repo = repository.RepositoryFormat6().initialize(control)
147
repo = weaverepo.RepositoryFormat6().initialize(control)
147
148
# We no longer need to create the ancestry.weave file
148
149
# since it is *never* used.
149
150
self.assertRaises(NoSuchFile,
156
157
def test_disk_layout(self):
157
158
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
158
repo = repository.RepositoryFormat7().initialize(control)
159
repo = weaverepo.RepositoryFormat7().initialize(control)
159
160
# in case of side effects of locking.
160
161
repo.lock_write()
178
179
def test_shared_disk_layout(self):
179
180
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
180
repo = repository.RepositoryFormat7().initialize(control, shared=True)
181
repo = weaverepo.RepositoryFormat7().initialize(control, shared=True)
182
183
# format 'Bazaar-NG Repository format 7'
183
184
# inventory.weave == empty_weave
200
201
def test_creates_lockdir(self):
201
202
"""Make sure it appears to be controlled by a LockDir existence"""
202
203
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
203
repo = repository.RepositoryFormat7().initialize(control, shared=True)
204
repo = weaverepo.RepositoryFormat7().initialize(control, shared=True)
204
205
t = control.get_repository_transport(None)
205
206
# TODO: Should check there is a 'lock' toplevel directory,
206
207
# regardless of contents
216
217
"""repo format 7 actually locks on lockdir"""
217
218
base_url = self.get_url()
218
219
control = bzrdir.BzrDirMetaFormat1().initialize(base_url)
219
repo = repository.RepositoryFormat7().initialize(control, shared=True)
220
repo = weaverepo.RepositoryFormat7().initialize(control, shared=True)
220
221
t = control.get_repository_transport(None)
221
222
repo.lock_write()
231
232
def test_shared_no_tree_disk_layout(self):
232
233
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
233
repo = repository.RepositoryFormat7().initialize(control, shared=True)
234
repo = weaverepo.RepositoryFormat7().initialize(control, shared=True)
234
235
repo.set_make_working_trees(False)
236
237
# format 'Bazaar-NG Repository format 7'
394
395
self.assertGetsDefaultInterRepository(dummy_a, dummy_b)
397
class TestInterWeaveRepo(TestCaseWithTransport):
399
def test_is_compatible_and_registered(self):
400
# InterWeaveRepo is compatible when either side
401
# is a format 5/6/7 branch
402
formats = [repository.RepositoryFormat5(),
403
repository.RepositoryFormat6(),
404
repository.RepositoryFormat7()]
405
incompatible_formats = [repository.RepositoryFormat4(),
406
repository.RepositoryFormatKnit1(),
408
repo_a = self.make_repository('a')
409
repo_b = self.make_repository('b')
410
is_compatible = repository.InterWeaveRepo.is_compatible
411
for source in incompatible_formats:
412
# force incompatible left then right
413
repo_a._format = source
414
repo_b._format = formats[0]
415
self.assertFalse(is_compatible(repo_a, repo_b))
416
self.assertFalse(is_compatible(repo_b, repo_a))
417
for source in formats:
418
repo_a._format = source
419
for target in formats:
420
repo_b._format = target
421
self.assertTrue(is_compatible(repo_a, repo_b))
422
self.assertEqual(repository.InterWeaveRepo,
423
repository.InterRepository.get(repo_a,
427
398
class TestRepositoryConverter(TestCaseWithTransport):
429
400
def test_convert_empty(self):
430
401
t = get_transport(self.get_url('.'))
431
402
t.mkdir('repository')
432
403
repo_dir = bzrdir.BzrDirMetaFormat1().initialize('repository')
433
repo = repository.RepositoryFormat7().initialize(repo_dir)
404
repo = weaverepo.RepositoryFormat7().initialize(repo_dir)
434
405
target_format = repository.RepositoryFormatKnit1()
435
406
converter = repository.CopyConverter(target_format)
436
407
pb = bzrlib.ui.ui_factory.nested_progress_bar()