162
160
repository.RepositoryFormat.unregister_format(format)
165
class TestFormat6(TestCaseWithTransport):
167
def test_attribute__fetch_order(self):
168
"""Weaves need topological data insertion."""
169
control = bzrdir.BzrDirFormat6().initialize(self.get_url())
170
from bzrlib.plugins.weave_fmt.repository import RepositoryFormat6
171
repo = RepositoryFormat6().initialize(control)
172
self.assertEqual('topological', repo._format._fetch_order)
174
def test_attribute__fetch_uses_deltas(self):
175
"""Weaves do not reuse deltas."""
176
control = bzrdir.BzrDirFormat6().initialize(self.get_url())
177
from bzrlib.plugins.weave_fmt.repository import RepositoryFormat6
178
repo = RepositoryFormat6().initialize(control)
179
self.assertEqual(False, repo._format._fetch_uses_deltas)
181
def test_attribute__fetch_reconcile(self):
182
"""Weave repositories need a reconcile after fetch."""
183
control = bzrdir.BzrDirFormat6().initialize(self.get_url())
184
from bzrlib.plugins.weave_fmt.repository import RepositoryFormat6
185
repo = RepositoryFormat6().initialize(control)
186
self.assertEqual(True, repo._format._fetch_reconcile)
188
def test_no_ancestry_weave(self):
189
control = bzrdir.BzrDirFormat6().initialize(self.get_url())
190
from bzrlib.plugins.weave_fmt.repository import RepositoryFormat6
191
repo = RepositoryFormat6().initialize(control)
192
# We no longer need to create the ancestry.weave file
193
# since it is *never* used.
194
self.assertRaises(NoSuchFile,
195
control.transport.get,
198
def test_supports_external_lookups(self):
199
control = bzrdir.BzrDirFormat6().initialize(self.get_url())
200
from bzrlib.plugins.weave_fmt.repository import RepositoryFormat6
201
repo = RepositoryFormat6().initialize(control)
202
self.assertFalse(repo._format.supports_external_lookups)
205
class TestFormat7(TestCaseWithTransport):
207
def test_attribute__fetch_order(self):
208
"""Weaves need topological data insertion."""
209
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
210
from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
211
repo = RepositoryFormat7().initialize(control)
212
self.assertEqual('topological', repo._format._fetch_order)
214
def test_attribute__fetch_uses_deltas(self):
215
"""Weaves do not reuse deltas."""
216
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
217
from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
218
repo = RepositoryFormat7().initialize(control)
219
self.assertEqual(False, repo._format._fetch_uses_deltas)
221
def test_attribute__fetch_reconcile(self):
222
"""Weave repositories need a reconcile after fetch."""
223
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
224
from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
225
repo = RepositoryFormat7().initialize(control)
226
self.assertEqual(True, repo._format._fetch_reconcile)
228
def test_disk_layout(self):
229
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
230
from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
231
repo = RepositoryFormat7().initialize(control)
232
# in case of side effects of locking.
236
# format 'Bazaar-NG Repository format 7'
238
# inventory.weave == empty_weave
239
# empty revision-store directory
240
# empty weaves directory
241
t = control.get_repository_transport(None)
242
self.assertEqualDiff('Bazaar-NG Repository format 7',
243
t.get('format').read())
244
self.assertTrue(S_ISDIR(t.stat('revision-store').st_mode))
245
self.assertTrue(S_ISDIR(t.stat('weaves').st_mode))
246
self.assertEqualDiff('# bzr weave file v5\n'
249
t.get('inventory.weave').read())
250
# Creating a file with id Foo:Bar results in a non-escaped file name on
252
control.create_branch()
253
tree = control.create_workingtree()
254
tree.add(['foo'], ['Foo:Bar'], ['file'])
255
tree.put_file_bytes_non_atomic('Foo:Bar', 'content\n')
257
tree.commit('first post', rev_id='first')
258
except errors.IllegalPath:
259
if sys.platform != 'win32':
261
self.knownFailure('Foo:Bar cannot be used as a file-id on windows'
264
self.assertEqualDiff(
265
'# bzr weave file v5\n'
267
'1 7fe70820e08a1aac0ef224d9c66ab66831cc4ab1\n'
275
t.get('weaves/74/Foo%3ABar.weave').read())
277
def test_shared_disk_layout(self):
278
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
279
from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
280
repo = RepositoryFormat7().initialize(control, shared=True)
282
# format 'Bazaar-NG Repository format 7'
283
# inventory.weave == empty_weave
284
# empty revision-store directory
285
# empty weaves directory
286
# a 'shared-storage' marker file.
287
# lock is not present when unlocked
288
t = control.get_repository_transport(None)
289
self.assertEqualDiff('Bazaar-NG Repository format 7',
290
t.get('format').read())
291
self.assertEqualDiff('', t.get('shared-storage').read())
292
self.assertTrue(S_ISDIR(t.stat('revision-store').st_mode))
293
self.assertTrue(S_ISDIR(t.stat('weaves').st_mode))
294
self.assertEqualDiff('# bzr weave file v5\n'
297
t.get('inventory.weave').read())
298
self.assertFalse(t.has('branch-lock'))
300
def test_creates_lockdir(self):
301
"""Make sure it appears to be controlled by a LockDir existence"""
302
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
303
from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
304
repo = RepositoryFormat7().initialize(control, shared=True)
305
t = control.get_repository_transport(None)
306
# TODO: Should check there is a 'lock' toplevel directory,
307
# regardless of contents
308
self.assertFalse(t.has('lock/held/info'))
311
self.assertTrue(t.has('lock/held/info'))
313
# unlock so we don't get a warning about failing to do so
316
def test_uses_lockdir(self):
317
"""repo format 7 actually locks on lockdir"""
318
base_url = self.get_url()
319
control = bzrdir.BzrDirMetaFormat1().initialize(base_url)
320
from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
321
repo = RepositoryFormat7().initialize(control, shared=True)
322
t = control.get_repository_transport(None)
326
# make sure the same lock is created by opening it
327
repo = repository.Repository.open(base_url)
329
self.assertTrue(t.has('lock/held/info'))
331
self.assertFalse(t.has('lock/held/info'))
333
def test_shared_no_tree_disk_layout(self):
334
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
335
from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
336
repo = RepositoryFormat7().initialize(control, shared=True)
337
repo.set_make_working_trees(False)
339
# format 'Bazaar-NG Repository format 7'
341
# inventory.weave == empty_weave
342
# empty revision-store directory
343
# empty weaves directory
344
# a 'shared-storage' marker file.
345
t = control.get_repository_transport(None)
346
self.assertEqualDiff('Bazaar-NG Repository format 7',
347
t.get('format').read())
348
## self.assertEqualDiff('', t.get('lock').read())
349
self.assertEqualDiff('', t.get('shared-storage').read())
350
self.assertEqualDiff('', t.get('no-working-trees').read())
351
repo.set_make_working_trees(True)
352
self.assertFalse(t.has('no-working-trees'))
353
self.assertTrue(S_ISDIR(t.stat('revision-store').st_mode))
354
self.assertTrue(S_ISDIR(t.stat('weaves').st_mode))
355
self.assertEqualDiff('# bzr weave file v5\n'
358
t.get('inventory.weave').read())
360
def test_supports_external_lookups(self):
361
control = bzrdir.BzrDirMetaFormat1().initialize(self.get_url())
362
from bzrlib.plugins.weave_fmt.repository import RepositoryFormat7
363
repo = RepositoryFormat7().initialize(control)
364
self.assertFalse(repo._format.supports_external_lookups)
367
163
class TestFormatKnit1(TestCaseWithTransport):
369
165
def test_attribute__fetch_order(self):
586
382
self.assertGetsDefaultInterRepository(dummy_a, dummy_b)
589
class TestInterWeaveRepo(TestCaseWithTransport):
591
def test_is_compatible_and_registered(self):
592
# InterWeaveRepo is compatible when either side
593
# is a format 5/6/7 branch
594
from bzrlib.repofmt import knitrepo
595
from bzrlib.plugins.weave_fmt.repository import (
596
InterWeaveRepo, RepositoryFormat4, RepositoryFormat5,
597
RepositoryFormat6, RepositoryFormat7)
598
formats = [RepositoryFormat5(),
601
incompatible_formats = [RepositoryFormat4(),
602
knitrepo.RepositoryFormatKnit1(),
604
repo_a = self.make_repository('a')
605
repo_b = self.make_repository('b')
606
is_compatible = InterWeaveRepo.is_compatible
607
for source in incompatible_formats:
608
# force incompatible left then right
609
repo_a._format = source
610
repo_b._format = formats[0]
611
self.assertFalse(is_compatible(repo_a, repo_b))
612
self.assertFalse(is_compatible(repo_b, repo_a))
613
for source in formats:
614
repo_a._format = source
615
for target in formats:
616
repo_b._format = target
617
self.assertTrue(is_compatible(repo_a, repo_b))
618
self.assertEqual(InterWeaveRepo,
619
repository.InterRepository.get(repo_a,
623
385
class TestRepositoryConverter(TestCaseWithTransport):
625
387
def test_convert_empty(self):