40
40
def test_upgrade_rich_root(self):
41
41
tree = self.make_branch_and_tree('tree', format='rich-root')
42
tree.commit('first post')
42
rev_id = tree.commit('first post')
43
43
upgrade.upgrade('tree')
45
45
def test_convert_branch5_branch6(self):
46
46
b = self.make_branch('branch', format='knit')
47
b._set_revision_history([b'CD'])
47
b._set_revision_history(['CD'])
48
48
b.set_parent('file:///EF')
49
49
b.set_bound_location('file:///GH')
50
50
b.set_push_location('file:///IJ')
51
target = controldir.format_registry.make_controldir(
52
'dirstate-with-subtree')
51
target = controldir.format_registry.make_controldir('dirstate-with-subtree')
53
52
converter = b.controldir._format.get_converter(target)
54
53
converter.convert(b.controldir, None)
55
54
new_branch = branch.Branch.open(self.get_url('branch'))
56
55
self.assertIs(new_branch.__class__, bzrbranch.BzrBranch6)
57
self.assertEqual(b'CD', new_branch.last_revision())
56
self.assertEqual('CD', new_branch.last_revision())
58
57
self.assertEqual('file:///EF', new_branch.get_parent())
59
58
self.assertEqual('file:///GH', new_branch.get_bound_location())
60
59
branch_config = new_branch.get_config_stack()
84
83
converter.convert(tree.controldir, None)
85
84
new_tree = workingtree.WorkingTree.open('tree')
86
85
self.assertIs(new_tree.__class__, workingtree_4.WorkingTree4)
87
self.assertEqual(b'null:', new_tree.last_revision())
86
self.assertEqual('null:', new_tree.last_revision())
89
88
def test_convert_knit_dirstate_content(self):
90
89
# smoke test for dirstate conversion: we call dirstate primitives,
91
90
# and its there that the core logic is tested.
92
91
tree = self.make_branch_and_tree('tree', format='knit')
93
92
self.build_tree(['tree/file'])
94
tree.add(['file'], [b'file-id'])
93
tree.add(['file'], ['file-id'])
95
94
target = controldir.format_registry.make_controldir('dirstate')
96
95
converter = tree.controldir._format.get_converter(target)
97
96
converter.convert(tree.controldir, None)
98
97
new_tree = workingtree.WorkingTree.open('tree')
99
98
self.assertIs(new_tree.__class__, workingtree_4.WorkingTree4)
100
self.assertEqual(b'null:', new_tree.last_revision())
99
self.assertEqual('null:', new_tree.last_revision())
102
101
def test_convert_knit_one_parent_dirstate(self):
103
102
# test that asking for an upgrade from knit to dirstate works.
110
109
self.assertIs(new_tree.__class__, workingtree_4.WorkingTree4)
111
110
self.assertEqual(rev_id, new_tree.last_revision())
112
111
for path in ['basis-inventory-cache', 'inventory', 'last-revision',
113
'pending-merges', 'stat-cache']:
112
'pending-merges', 'stat-cache']:
114
113
self.assertPathDoesNotExist('tree/.bzr/checkout/' + path)
116
115
def test_convert_knit_merges_dirstate(self):
117
116
tree = self.make_branch_and_tree('tree', format='knit')
118
tree.commit('first post')
117
rev_id = tree.commit('first post')
119
118
merge_tree = tree.controldir.sprout('tree2').open_workingtree()
120
119
rev_id2 = tree.commit('second post')
121
120
rev_id3 = merge_tree.commit('second merge post')
128
127
self.assertEqual(rev_id2, new_tree.last_revision())
129
128
self.assertEqual([rev_id2, rev_id3], new_tree.get_parent_ids())
130
129
for path in ['basis-inventory-cache', 'inventory', 'last-revision',
131
'pending-merges', 'stat-cache']:
130
'pending-merges', 'stat-cache']:
132
131
self.assertPathDoesNotExist('tree/.bzr/checkout/' + path)
172
171
def make_repo_with_branches(self):
173
172
repo = self.make_repository('repo', shared=True,
174
format=self.from_format)
173
format=self.from_format)
175
174
# Note: self.make_branch() always creates a new repo at the location
176
175
# so we need to avoid using that here ...
177
controldir.ControlDir.create_branch_convenience(
178
"repo/branch1", format=self.from_format)
179
b2 = controldir.ControlDir.create_branch_convenience(
180
"repo/branch2", format=self.from_format)
176
b1 = controldir.ControlDir.create_branch_convenience("repo/branch1",
177
format=self.from_format)
178
b2 = controldir.ControlDir.create_branch_convenience("repo/branch2",
179
format=self.from_format)
181
180
return repo.controldir
183
182
def test_upgrade_repo_with_branches(self):