1
# Copyright (C) 2006-2011 Canonical Ltd
1
# Copyright (C) 2011, 2012, 2016 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
65
67
self.assertTrue(ctrl_2 is ctrl_3)
66
68
check_dir_components_use_same_lock(dir)
67
69
# and if we open it normally.
68
dir = bzrdir.BzrDir.open(self.get_url())
70
dir = controldir.ControlDir.open(self.get_url())
69
71
check_dir_components_use_same_lock(dir)
71
73
def test_can_convert(self):
99
101
self.assertTrue(ctrl_2 is ctrl_3)
100
102
check_dir_components_use_same_lock(dir)
101
103
# and if we open it normally.
102
dir = bzrdir.BzrDir.open(self.get_url())
104
dir = controldir.ControlDir.open(self.get_url())
103
105
check_dir_components_use_same_lock(dir)
105
107
def test_can_convert(self):
301
303
# At this point, we have a format6 branch without checkout files.
302
304
upgrade.upgrade('.', bzrdir.BzrDirMetaFormat1())
303
305
# The upgrade should not have set up a working tree.
304
control = bzrdir.BzrDir.open('.')
306
control = controldir.ControlDir.open('.')
305
307
self.assertFalse(control.has_workingtree())
306
308
# We have covered the scope of this test, we may as well check that
307
309
# upgrade has not eaten our data, even if it's a bit redundant with
309
311
self.assertIsInstance(control._format, bzrdir.BzrDirMetaFormat1)
310
312
b = control.open_branch()
311
self.assertEquals(b.revision_history(),
313
self.addCleanup(b.lock_read().unlock)
314
self.assertEqual(b._revision_history(),
312
315
['mbp@sourcefrog.net-20051004035611-176b16534b086b3c',
313
316
'mbp@sourcefrog.net-20051004035756-235f2b7dcdddd8dd'])
315
318
def test_upgrade_simple(self):
316
319
"""Upgrade simple v0.0.4 format to latest format"""
317
eq = self.assertEquals
320
eq = self.assertEqual
318
321
self.build_tree_contents(_upgrade1_template)
319
322
upgrade.upgrade(u'.')
320
control = bzrdir.BzrDir.open('.')
323
control = controldir.ControlDir.open('.')
321
324
b = control.open_branch()
322
325
# tsk, peeking under the covers.
323
326
self.assertIsInstance(
325
328
bzrdir.BzrDirFormat.get_default_format().__class__)
326
rh = b.revision_history()
329
self.addCleanup(b.lock_read().unlock)
330
rh = b._revision_history()
328
332
['mbp@sourcefrog.net-20051004035611-176b16534b086b3c',
329
333
'mbp@sourcefrog.net-20051004035756-235f2b7dcdddd8dd'])
374
378
bzr, but can happen in branches imported from baz and arch, or from
375
379
other systems, where the importer knows about a revision but not
377
eq = self.assertEquals
381
eq = self.assertEqual
378
382
self.build_tree_contents(_ghost_template)
379
383
upgrade.upgrade(u'.')
380
384
b = branch.Branch.open(u'.')
381
revision_id = b.revision_history()[1]
385
self.addCleanup(b.lock_read().unlock)
386
revision_id = b._revision_history()[1]
382
387
rev = b.repository.get_revision(revision_id)
383
388
eq(len(rev.parent_ids), 2)
384
389
eq(rev.parent_ids[1], 'wibble@wobble-2')
386
391
def test_upgrade_makes_dir_weaves(self):
387
392
self.build_tree_contents(_upgrade_dir_template)
388
old_repodir = bzrdir.BzrDir.open_unsupported('.')
393
old_repodir = controldir.ControlDir.open_unsupported('.')
389
394
old_repo_format = old_repodir.open_repository()._format
390
395
upgrade.upgrade('.')
391
396
# this is the path to the literal file. As format changes
407
412
self.build_tree_contents(_upgrade_dir_template)
408
413
upgrade.upgrade('.', bzrdir.BzrDirMetaFormat1())
409
414
tree = workingtree.WorkingTree.open('.')
410
self.assertEqual([tree.branch.revision_history()[-1]],
415
self.addCleanup(tree.lock_read().unlock)
416
self.assertEqual([tree.branch._revision_history()[-1]],
411
417
tree.get_parent_ids())
539
545
self.build_tree(['master/', 'child/'])
540
546
self.make_branch_and_tree('master')
541
547
self.make_branch_and_tree('child',
542
format=bzrdir.format_registry.make_bzrdir('weave'))
548
format=controldir.format_registry.make_bzrdir('weave'))
543
549
os.chdir('child')
545
551
def test_bind_format_6_bzrdir(self):