5557.1.7
by John Arbash Meinel
Merge in the bzr.dev 5582 |
1 |
# Copyright (C) 2005-2011 Canonical Ltd
|
1417.1.2
by Robert Collins
add sample test |
2 |
#
|
1393.1.31
by Martin Pool
- add simple test for upgrade |
3 |
# This program is free software; you can redistribute it and/or modify
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
1417.1.2
by Robert Collins
add sample test |
7 |
#
|
1393.1.31
by Martin Pool
- add simple test for upgrade |
8 |
# This program is distributed in the hope that it will be useful,
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
1417.1.2
by Robert Collins
add sample test |
12 |
#
|
1393.1.31
by Martin Pool
- add simple test for upgrade |
13 |
# You should have received a copy of the GNU General Public License
|
14 |
# along with this program; if not, write to the Free Software
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
1393.1.31
by Martin Pool
- add simple test for upgrade |
16 |
|
17 |
"""Tests for upgrade of old trees.
|
|
18 |
||
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
19 |
This file contains canned versions of some old trees, which are instantiated
|
1393.1.31
by Martin Pool
- add simple test for upgrade |
20 |
and then upgraded to the new format."""
|
21 |
||
1534.4.44
by Robert Collins
Make a new BzrDir format that uses a versioned branch format in a branch/ subdirectory. |
22 |
# TODO queue for upgrade:
|
23 |
# test the error message when upgrading an unknown BzrDir format.
|
|
24 |
||
2230.3.29
by Aaron Bentley
Implement conversion to branch 6 |
25 |
from bzrlib import ( |
4360.10.47
by Vincent Ladeuil
Some cleanup. |
26 |
branch, |
2230.3.29
by Aaron Bentley
Implement conversion to branch 6 |
27 |
bzrdir, |
4360.10.47
by Vincent Ladeuil
Some cleanup. |
28 |
tests, |
4360.10.48
by Vincent Ladeuil
And some more cleanup. |
29 |
upgrade, |
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
30 |
workingtree, |
31 |
workingtree_4, |
|
2230.3.29
by Aaron Bentley
Implement conversion to branch 6 |
32 |
)
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
33 |
|
34 |
||
4360.10.47
by Vincent Ladeuil
Some cleanup. |
35 |
class TestUpgrade(tests.TestCaseWithTransport): |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
36 |
|
4119.7.1
by Jelmer Vernooij
Make upgrade default to a rich-root-capable format if the source format uses rich roots. |
37 |
def test_upgrade_rich_root(self): |
38 |
tree = self.make_branch_and_tree('tree', format='rich-root') |
|
39 |
rev_id = tree.commit('first post') |
|
4360.10.48
by Vincent Ladeuil
And some more cleanup. |
40 |
upgrade.upgrade('tree') |
4119.7.1
by Jelmer Vernooij
Make upgrade default to a rich-root-capable format if the source format uses rich roots. |
41 |
|
2230.3.29
by Aaron Bentley
Implement conversion to branch 6 |
42 |
def test_convert_branch5_branch6(self): |
4360.10.47
by Vincent Ladeuil
Some cleanup. |
43 |
b = self.make_branch('branch', format='knit') |
5718.7.11
by Jelmer Vernooij
Fix set_revision_history. |
44 |
b._set_revision_history(['CD']) |
4360.10.47
by Vincent Ladeuil
Some cleanup. |
45 |
b.set_parent('file:///EF') |
46 |
b.set_bound_location('file:///GH') |
|
47 |
b.set_push_location('file:///IJ') |
|
2255.2.196
by Robert Collins
Fix test_upgrade defects related to non local or absent working trees. |
48 |
target = bzrdir.format_registry.make_bzrdir('dirstate-with-subtree') |
4360.10.47
by Vincent Ladeuil
Some cleanup. |
49 |
converter = b.bzrdir._format.get_converter(target) |
50 |
converter.convert(b.bzrdir, None) |
|
51 |
new_branch = branch.Branch.open(self.get_url('branch')) |
|
52 |
self.assertIs(new_branch.__class__, branch.BzrBranch6) |
|
2230.3.29
by Aaron Bentley
Implement conversion to branch 6 |
53 |
self.assertEqual('CD', new_branch.last_revision()) |
54 |
self.assertEqual('file:///EF', new_branch.get_parent()) |
|
55 |
self.assertEqual('file:///GH', new_branch.get_bound_location()) |
|
56 |
branch_config = new_branch.get_config()._get_branch_data_config() |
|
57 |
self.assertEqual('file:///IJ', |
|
58 |
branch_config.get_user_option('push_location')) |
|
59 |
||
4360.10.47
by Vincent Ladeuil
Some cleanup. |
60 |
b2 = self.make_branch('branch2', format='knit') |
61 |
converter = b2.bzrdir._format.get_converter(target) |
|
62 |
converter.convert(b2.bzrdir, None) |
|
63 |
b2 = branch.Branch.open(self.get_url('branch')) |
|
64 |
self.assertIs(b2.__class__, branch.BzrBranch6) |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
65 |
|
4273.1.13
by Aaron Bentley
Implement upgrade from branch format 7 to 8. |
66 |
def test_convert_branch7_branch8(self): |
4360.10.47
by Vincent Ladeuil
Some cleanup. |
67 |
b = self.make_branch('branch', format='1.9') |
4273.1.13
by Aaron Bentley
Implement upgrade from branch format 7 to 8. |
68 |
target = bzrdir.format_registry.make_bzrdir('1.9') |
4360.10.47
by Vincent Ladeuil
Some cleanup. |
69 |
target.set_branch_format(branch.BzrBranchFormat8()) |
70 |
converter = b.bzrdir._format.get_converter(target) |
|
71 |
converter.convert(b.bzrdir, None) |
|
72 |
b = branch.Branch.open(self.get_url('branch')) |
|
73 |
self.assertIs(b.__class__, branch.BzrBranch8) |
|
74 |
self.assertEqual({}, b._get_all_reference_info()) |
|
4273.1.13
by Aaron Bentley
Implement upgrade from branch format 7 to 8. |
75 |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
76 |
def test_convert_knit_dirstate_empty(self): |
77 |
# test that asking for an upgrade from knit to dirstate works.
|
|
78 |
tree = self.make_branch_and_tree('tree', format='knit') |
|
79 |
target = bzrdir.format_registry.make_bzrdir('dirstate') |
|
80 |
converter = tree.bzrdir._format.get_converter(target) |
|
4961.2.9
by Martin Pool
Rip out most remaining uses of DummyProgressBar |
81 |
converter.convert(tree.bzrdir, None) |
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
82 |
new_tree = workingtree.WorkingTree.open('tree') |
83 |
self.assertIs(new_tree.__class__, workingtree_4.WorkingTree4) |
|
2598.5.10
by Aaron Bentley
Return NULL_REVISION instead of None for the null revision |
84 |
self.assertEqual('null:', new_tree.last_revision()) |
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
85 |
|
86 |
def test_convert_knit_dirstate_content(self): |
|
87 |
# smoke test for dirstate conversion: we call dirstate primitives,
|
|
88 |
# and its there that the core logic is tested.
|
|
89 |
tree = self.make_branch_and_tree('tree', format='knit') |
|
90 |
self.build_tree(['tree/file']) |
|
91 |
tree.add(['file'], ['file-id']) |
|
92 |
target = bzrdir.format_registry.make_bzrdir('dirstate') |
|
93 |
converter = tree.bzrdir._format.get_converter(target) |
|
4961.2.9
by Martin Pool
Rip out most remaining uses of DummyProgressBar |
94 |
converter.convert(tree.bzrdir, None) |
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
95 |
new_tree = workingtree.WorkingTree.open('tree') |
96 |
self.assertIs(new_tree.__class__, workingtree_4.WorkingTree4) |
|
2598.5.10
by Aaron Bentley
Return NULL_REVISION instead of None for the null revision |
97 |
self.assertEqual('null:', new_tree.last_revision()) |
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
98 |
|
99 |
def test_convert_knit_one_parent_dirstate(self): |
|
100 |
# test that asking for an upgrade from knit to dirstate works.
|
|
101 |
tree = self.make_branch_and_tree('tree', format='knit') |
|
102 |
rev_id = tree.commit('first post') |
|
103 |
target = bzrdir.format_registry.make_bzrdir('dirstate') |
|
104 |
converter = tree.bzrdir._format.get_converter(target) |
|
4961.2.9
by Martin Pool
Rip out most remaining uses of DummyProgressBar |
105 |
converter.convert(tree.bzrdir, None) |
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
106 |
new_tree = workingtree.WorkingTree.open('tree') |
107 |
self.assertIs(new_tree.__class__, workingtree_4.WorkingTree4) |
|
108 |
self.assertEqual(rev_id, new_tree.last_revision()) |
|
109 |
for path in ['basis-inventory-cache', 'inventory', 'last-revision', |
|
110 |
'pending-merges', 'stat-cache']: |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
111 |
self.assertPathDoesNotExist('tree/.bzr/checkout/' + path) |
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
112 |
|
113 |
def test_convert_knit_merges_dirstate(self): |
|
114 |
tree = self.make_branch_and_tree('tree', format='knit') |
|
115 |
rev_id = tree.commit('first post') |
|
116 |
merge_tree = tree.bzrdir.sprout('tree2').open_workingtree() |
|
117 |
rev_id2 = tree.commit('second post') |
|
118 |
rev_id3 = merge_tree.commit('second merge post') |
|
119 |
tree.merge_from_branch(merge_tree.branch) |
|
120 |
target = bzrdir.format_registry.make_bzrdir('dirstate') |
|
121 |
converter = tree.bzrdir._format.get_converter(target) |
|
4961.2.9
by Martin Pool
Rip out most remaining uses of DummyProgressBar |
122 |
converter.convert(tree.bzrdir, None) |
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
123 |
new_tree = workingtree.WorkingTree.open('tree') |
124 |
self.assertIs(new_tree.__class__, workingtree_4.WorkingTree4) |
|
125 |
self.assertEqual(rev_id2, new_tree.last_revision()) |
|
126 |
self.assertEqual([rev_id2, rev_id3], new_tree.get_parent_ids()) |
|
127 |
for path in ['basis-inventory-cache', 'inventory', 'last-revision', |
|
128 |
'pending-merges', 'stat-cache']: |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
129 |
self.assertPathDoesNotExist('tree/.bzr/checkout/' + path) |
2230.3.29
by Aaron Bentley
Implement conversion to branch 6 |
130 |
|
1393.1.31
by Martin Pool
- add simple test for upgrade |
131 |
|
4360.10.47
by Vincent Ladeuil
Some cleanup. |
132 |
class TestSmartUpgrade(tests.TestCaseWithTransport): |
4360.10.1
by Ian Clatworthy
initial cut at smarter upgrades |
133 |
|
4360.10.20
by Ian Clatworthy
fix tests to truly use a shared repository, not standalone branches inside one |
134 |
from_format = bzrdir.format_registry.make_bzrdir("pack-0.92") |
4360.10.14
by Ian Clatworthy
use the most common format converison in tests |
135 |
to_format = bzrdir.format_registry.make_bzrdir("2a") |
4360.10.1
by Ian Clatworthy
initial cut at smarter upgrades |
136 |
|
137 |
def make_standalone_branch(self): |
|
138 |
wt = self.make_branch_and_tree("branch1", format=self.from_format) |
|
139 |
return wt.bzrdir |
|
140 |
||
141 |
def test_upgrade_standalone_branch(self): |
|
142 |
control = self.make_standalone_branch() |
|
4360.10.48
by Vincent Ladeuil
And some more cleanup. |
143 |
tried, worked, issues = upgrade.smart_upgrade( |
144 |
[control], format=self.to_format) |
|
4360.10.39
by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests. |
145 |
self.assertLength(1, tried) |
4360.10.33
by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and |
146 |
self.assertEqual(tried[0], control) |
4360.10.39
by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests. |
147 |
self.assertLength(1, worked) |
4360.10.33
by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and |
148 |
self.assertEqual(worked[0], control) |
4360.10.39
by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests. |
149 |
self.assertLength(0, issues) |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
150 |
self.assertPathExists('branch1/backup.bzr.~1~') |
4360.10.32
by Matthew Fuller
Add some additional assertions into the TestSmartUpgrade tests to |
151 |
self.assertEqual(control.open_repository()._format, |
152 |
self.to_format._repository_format) |
|
4360.10.1
by Ian Clatworthy
initial cut at smarter upgrades |
153 |
|
154 |
def test_upgrade_standalone_branch_cleanup(self): |
|
155 |
control = self.make_standalone_branch() |
|
4360.10.48
by Vincent Ladeuil
And some more cleanup. |
156 |
tried, worked, issues = upgrade.smart_upgrade( |
157 |
[control], format=self.to_format, clean_up=True) |
|
4360.10.39
by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests. |
158 |
self.assertLength(1, tried) |
4360.10.33
by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and |
159 |
self.assertEqual(tried[0], control) |
4360.10.39
by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests. |
160 |
self.assertLength(1, worked) |
4360.10.33
by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and |
161 |
self.assertEqual(worked[0], control) |
4360.10.39
by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests. |
162 |
self.assertLength(0, issues) |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
163 |
self.assertPathExists('branch1') |
164 |
self.assertPathExists('branch1/.bzr') |
|
165 |
self.assertPathDoesNotExist('branch1/backup.bzr.~1~') |
|
4360.10.32
by Matthew Fuller
Add some additional assertions into the TestSmartUpgrade tests to |
166 |
self.assertEqual(control.open_repository()._format, |
167 |
self.to_format._repository_format) |
|
4360.10.1
by Ian Clatworthy
initial cut at smarter upgrades |
168 |
|
4360.10.2
by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs |
169 |
def make_repo_with_branches(self): |
4360.10.1
by Ian Clatworthy
initial cut at smarter upgrades |
170 |
repo = self.make_repository('repo', shared=True, |
171 |
format=self.from_format) |
|
4360.10.20
by Ian Clatworthy
fix tests to truly use a shared repository, not standalone branches inside one |
172 |
# Note: self.make_branch() always creates a new repo at the location
|
173 |
# so we need to avoid using that here ...
|
|
174 |
b1 = bzrdir.BzrDir.create_branch_convenience("repo/branch1", |
|
175 |
format=self.from_format) |
|
176 |
b2 = bzrdir.BzrDir.create_branch_convenience("repo/branch2", |
|
177 |
format=self.from_format) |
|
4360.10.1
by Ian Clatworthy
initial cut at smarter upgrades |
178 |
return repo.bzrdir |
179 |
||
180 |
def test_upgrade_repo_with_branches(self): |
|
181 |
control = self.make_repo_with_branches() |
|
4360.10.48
by Vincent Ladeuil
And some more cleanup. |
182 |
tried, worked, issues = upgrade.smart_upgrade( |
183 |
[control], format=self.to_format) |
|
4360.10.39
by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests. |
184 |
self.assertLength(3, tried) |
4360.10.33
by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and |
185 |
self.assertEqual(tried[0], control) |
4360.10.39
by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests. |
186 |
self.assertLength(3, worked) |
4360.10.33
by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and |
187 |
self.assertEqual(worked[0], control) |
4360.10.39
by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests. |
188 |
self.assertLength(0, issues) |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
189 |
self.assertPathExists('repo/backup.bzr.~1~') |
190 |
self.assertPathExists('repo/branch1/backup.bzr.~1~') |
|
191 |
self.assertPathExists('repo/branch2/backup.bzr.~1~') |
|
4360.10.32
by Matthew Fuller
Add some additional assertions into the TestSmartUpgrade tests to |
192 |
self.assertEqual(control.open_repository()._format, |
193 |
self.to_format._repository_format) |
|
4360.10.47
by Vincent Ladeuil
Some cleanup. |
194 |
b1 = branch.Branch.open('repo/branch1') |
4360.10.32
by Matthew Fuller
Add some additional assertions into the TestSmartUpgrade tests to |
195 |
self.assertEqual(b1._format, self.to_format._branch_format) |
4360.10.1
by Ian Clatworthy
initial cut at smarter upgrades |
196 |
|
4360.10.2
by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs |
197 |
def test_upgrade_repo_with_branches_cleanup(self): |
198 |
control = self.make_repo_with_branches() |
|
4360.10.48
by Vincent Ladeuil
And some more cleanup. |
199 |
tried, worked, issues = upgrade.smart_upgrade( |
200 |
[control], format=self.to_format, clean_up=True) |
|
4360.10.39
by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests. |
201 |
self.assertLength(3, tried) |
4360.10.33
by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and |
202 |
self.assertEqual(tried[0], control) |
4360.10.39
by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests. |
203 |
self.assertLength(3, worked) |
4360.10.33
by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and |
204 |
self.assertEqual(worked[0], control) |
4360.10.39
by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests. |
205 |
self.assertLength(0, issues) |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
206 |
self.assertPathExists('repo') |
207 |
self.assertPathExists('repo/.bzr') |
|
208 |
self.assertPathDoesNotExist('repo/backup.bzr.~1~') |
|
209 |
self.assertPathDoesNotExist('repo/branch1/backup.bzr.~1~') |
|
210 |
self.assertPathDoesNotExist('repo/branch2/backup.bzr.~1~') |
|
4360.10.32
by Matthew Fuller
Add some additional assertions into the TestSmartUpgrade tests to |
211 |
self.assertEqual(control.open_repository()._format, |
212 |
self.to_format._repository_format) |
|
4360.10.47
by Vincent Ladeuil
Some cleanup. |
213 |
b1 = branch.Branch.open('repo/branch1') |
4360.10.32
by Matthew Fuller
Add some additional assertions into the TestSmartUpgrade tests to |
214 |
self.assertEqual(b1._format, self.to_format._branch_format) |