bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
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 |
||
6624
by Jelmer Vernooij
Merge Python3 porting work ('py3 pokes') |
25 |
from .. import ( |
4360.10.47
by Vincent Ladeuil
Some cleanup. |
26 |
branch, |
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
27 |
controldir, |
4360.10.47
by Vincent Ladeuil
Some cleanup. |
28 |
tests, |
4360.10.48
by Vincent Ladeuil
And some more cleanup. |
29 |
upgrade, |
6670.4.1
by Jelmer Vernooij
Update imports. |
30 |
)
|
31 |
from ..bzr import ( |
|
32 |
branch as bzrbranch, |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
33 |
workingtree, |
34 |
workingtree_4, |
|
2230.3.29
by Aaron Bentley
Implement conversion to branch 6 |
35 |
)
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
36 |
|
37 |
||
4360.10.47
by Vincent Ladeuil
Some cleanup. |
38 |
class TestUpgrade(tests.TestCaseWithTransport): |
3943.8.1
by Marius Kruger
remove all trailing whitespace from bzr source |
39 |
|
4119.7.1
by Jelmer Vernooij
Make upgrade default to a rich-root-capable format if the source format uses rich roots. |
40 |
def test_upgrade_rich_root(self): |
41 |
tree = self.make_branch_and_tree('tree', format='rich-root') |
|
42 |
rev_id = tree.commit('first post') |
|
4360.10.48
by Vincent Ladeuil
And some more cleanup. |
43 |
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. |
44 |
|
2230.3.29
by Aaron Bentley
Implement conversion to branch 6 |
45 |
def test_convert_branch5_branch6(self): |
4360.10.47
by Vincent Ladeuil
Some cleanup. |
46 |
b = self.make_branch('branch', format='knit') |
5718.7.11
by Jelmer Vernooij
Fix set_revision_history. |
47 |
b._set_revision_history(['CD']) |
4360.10.47
by Vincent Ladeuil
Some cleanup. |
48 |
b.set_parent('file:///EF') |
49 |
b.set_bound_location('file:///GH') |
|
50 |
b.set_push_location('file:///IJ') |
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
51 |
target = controldir.format_registry.make_controldir('dirstate-with-subtree') |
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
52 |
converter = b.controldir._format.get_converter(target) |
53 |
converter.convert(b.controldir, None) |
|
4360.10.47
by Vincent Ladeuil
Some cleanup. |
54 |
new_branch = branch.Branch.open(self.get_url('branch')) |
6653.1.6
by Jelmer Vernooij
Fix some more imports. |
55 |
self.assertIs(new_branch.__class__, bzrbranch.BzrBranch6) |
2230.3.29
by Aaron Bentley
Implement conversion to branch 6 |
56 |
self.assertEqual('CD', new_branch.last_revision()) |
57 |
self.assertEqual('file:///EF', new_branch.get_parent()) |
|
58 |
self.assertEqual('file:///GH', new_branch.get_bound_location()) |
|
6421.3.1
by Vincent Ladeuil
Migrate more branch options to config stacks. |
59 |
branch_config = new_branch.get_config_stack() |
60 |
self.assertEqual('file:///IJ', branch_config.get('push_location')) |
|
2230.3.29
by Aaron Bentley
Implement conversion to branch 6 |
61 |
|
4360.10.47
by Vincent Ladeuil
Some cleanup. |
62 |
b2 = self.make_branch('branch2', format='knit') |
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
63 |
converter = b2.controldir._format.get_converter(target) |
64 |
converter.convert(b2.controldir, None) |
|
4360.10.47
by Vincent Ladeuil
Some cleanup. |
65 |
b2 = branch.Branch.open(self.get_url('branch')) |
6653.1.6
by Jelmer Vernooij
Fix some more imports. |
66 |
self.assertIs(b2.__class__, bzrbranch.BzrBranch6) |
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
67 |
|
4273.1.13
by Aaron Bentley
Implement upgrade from branch format 7 to 8. |
68 |
def test_convert_branch7_branch8(self): |
4360.10.47
by Vincent Ladeuil
Some cleanup. |
69 |
b = self.make_branch('branch', format='1.9') |
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
70 |
target = controldir.format_registry.make_controldir('1.9') |
6653.1.6
by Jelmer Vernooij
Fix some more imports. |
71 |
target.set_branch_format(bzrbranch.BzrBranchFormat8()) |
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
72 |
converter = b.controldir._format.get_converter(target) |
73 |
converter.convert(b.controldir, None) |
|
4360.10.47
by Vincent Ladeuil
Some cleanup. |
74 |
b = branch.Branch.open(self.get_url('branch')) |
6653.1.6
by Jelmer Vernooij
Fix some more imports. |
75 |
self.assertIs(b.__class__, bzrbranch.BzrBranch8) |
4360.10.47
by Vincent Ladeuil
Some cleanup. |
76 |
self.assertEqual({}, b._get_all_reference_info()) |
4273.1.13
by Aaron Bentley
Implement upgrade from branch format 7 to 8. |
77 |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
78 |
def test_convert_knit_dirstate_empty(self): |
79 |
# test that asking for an upgrade from knit to dirstate works.
|
|
80 |
tree = self.make_branch_and_tree('tree', format='knit') |
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
81 |
target = controldir.format_registry.make_controldir('dirstate') |
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
82 |
converter = tree.controldir._format.get_converter(target) |
83 |
converter.convert(tree.controldir, None) |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
84 |
new_tree = workingtree.WorkingTree.open('tree') |
85 |
self.assertIs(new_tree.__class__, workingtree_4.WorkingTree4) |
|
6973.14.6
by Jelmer Vernooij
Fix some more tests. |
86 |
self.assertEqual(b'null:', new_tree.last_revision()) |
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
87 |
|
88 |
def test_convert_knit_dirstate_content(self): |
|
89 |
# smoke test for dirstate conversion: we call dirstate primitives,
|
|
90 |
# and its there that the core logic is tested.
|
|
91 |
tree = self.make_branch_and_tree('tree', format='knit') |
|
92 |
self.build_tree(['tree/file']) |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
93 |
tree.add(['file'], [b'file-id']) |
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
94 |
target = controldir.format_registry.make_controldir('dirstate') |
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
95 |
converter = tree.controldir._format.get_converter(target) |
96 |
converter.convert(tree.controldir, None) |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
97 |
new_tree = workingtree.WorkingTree.open('tree') |
98 |
self.assertIs(new_tree.__class__, workingtree_4.WorkingTree4) |
|
6855.4.1
by Jelmer Vernooij
Yet more bees. |
99 |
self.assertEqual(b'null:', new_tree.last_revision()) |
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
100 |
|
101 |
def test_convert_knit_one_parent_dirstate(self): |
|
102 |
# test that asking for an upgrade from knit to dirstate works.
|
|
103 |
tree = self.make_branch_and_tree('tree', format='knit') |
|
104 |
rev_id = tree.commit('first post') |
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
105 |
target = controldir.format_registry.make_controldir('dirstate') |
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
106 |
converter = tree.controldir._format.get_converter(target) |
107 |
converter.convert(tree.controldir, None) |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
108 |
new_tree = workingtree.WorkingTree.open('tree') |
109 |
self.assertIs(new_tree.__class__, workingtree_4.WorkingTree4) |
|
110 |
self.assertEqual(rev_id, new_tree.last_revision()) |
|
111 |
for path in ['basis-inventory-cache', 'inventory', 'last-revision', |
|
112 |
'pending-merges', 'stat-cache']: |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
113 |
self.assertPathDoesNotExist('tree/.bzr/checkout/' + path) |
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
114 |
|
115 |
def test_convert_knit_merges_dirstate(self): |
|
116 |
tree = self.make_branch_and_tree('tree', format='knit') |
|
117 |
rev_id = tree.commit('first post') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
118 |
merge_tree = tree.controldir.sprout('tree2').open_workingtree() |
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
119 |
rev_id2 = tree.commit('second post') |
120 |
rev_id3 = merge_tree.commit('second merge post') |
|
121 |
tree.merge_from_branch(merge_tree.branch) |
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
122 |
target = controldir.format_registry.make_controldir('dirstate') |
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
123 |
converter = tree.controldir._format.get_converter(target) |
124 |
converter.convert(tree.controldir, None) |
|
2255.12.1
by Robert Collins
Implement upgrade for working trees. |
125 |
new_tree = workingtree.WorkingTree.open('tree') |
126 |
self.assertIs(new_tree.__class__, workingtree_4.WorkingTree4) |
|
127 |
self.assertEqual(rev_id2, new_tree.last_revision()) |
|
128 |
self.assertEqual([rev_id2, rev_id3], new_tree.get_parent_ids()) |
|
129 |
for path in ['basis-inventory-cache', 'inventory', 'last-revision', |
|
130 |
'pending-merges', 'stat-cache']: |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
131 |
self.assertPathDoesNotExist('tree/.bzr/checkout/' + path) |
2230.3.29
by Aaron Bentley
Implement conversion to branch 6 |
132 |
|
1393.1.31
by Martin Pool
- add simple test for upgrade |
133 |
|
4360.10.47
by Vincent Ladeuil
Some cleanup. |
134 |
class TestSmartUpgrade(tests.TestCaseWithTransport): |
4360.10.1
by Ian Clatworthy
initial cut at smarter upgrades |
135 |
|
6653.6.5
by Jelmer Vernooij
Rename make_bzrdir to make_controldir. |
136 |
from_format = controldir.format_registry.make_controldir("pack-0.92") |
137 |
to_format = controldir.format_registry.make_controldir("2a") |
|
4360.10.1
by Ian Clatworthy
initial cut at smarter upgrades |
138 |
|
139 |
def make_standalone_branch(self): |
|
140 |
wt = self.make_branch_and_tree("branch1", format=self.from_format) |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
141 |
return wt.controldir |
4360.10.1
by Ian Clatworthy
initial cut at smarter upgrades |
142 |
|
143 |
def test_upgrade_standalone_branch(self): |
|
144 |
control = self.make_standalone_branch() |
|
4360.10.48
by Vincent Ladeuil
And some more cleanup. |
145 |
tried, worked, issues = upgrade.smart_upgrade( |
146 |
[control], format=self.to_format) |
|
4360.10.39
by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests. |
147 |
self.assertLength(1, tried) |
4360.10.33
by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and |
148 |
self.assertEqual(tried[0], control) |
4360.10.39
by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests. |
149 |
self.assertLength(1, worked) |
4360.10.33
by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and |
150 |
self.assertEqual(worked[0], control) |
4360.10.39
by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests. |
151 |
self.assertLength(0, issues) |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
152 |
self.assertPathExists('branch1/backup.bzr.~1~') |
4360.10.32
by Matthew Fuller
Add some additional assertions into the TestSmartUpgrade tests to |
153 |
self.assertEqual(control.open_repository()._format, |
154 |
self.to_format._repository_format) |
|
4360.10.1
by Ian Clatworthy
initial cut at smarter upgrades |
155 |
|
156 |
def test_upgrade_standalone_branch_cleanup(self): |
|
157 |
control = self.make_standalone_branch() |
|
4360.10.48
by Vincent Ladeuil
And some more cleanup. |
158 |
tried, worked, issues = upgrade.smart_upgrade( |
159 |
[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. |
160 |
self.assertLength(1, tried) |
4360.10.33
by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and |
161 |
self.assertEqual(tried[0], control) |
4360.10.39
by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests. |
162 |
self.assertLength(1, worked) |
4360.10.33
by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and |
163 |
self.assertEqual(worked[0], control) |
4360.10.39
by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests. |
164 |
self.assertLength(0, issues) |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
165 |
self.assertPathExists('branch1') |
166 |
self.assertPathExists('branch1/.bzr') |
|
167 |
self.assertPathDoesNotExist('branch1/backup.bzr.~1~') |
|
4360.10.32
by Matthew Fuller
Add some additional assertions into the TestSmartUpgrade tests to |
168 |
self.assertEqual(control.open_repository()._format, |
169 |
self.to_format._repository_format) |
|
4360.10.1
by Ian Clatworthy
initial cut at smarter upgrades |
170 |
|
4360.10.2
by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs |
171 |
def make_repo_with_branches(self): |
4360.10.1
by Ian Clatworthy
initial cut at smarter upgrades |
172 |
repo = self.make_repository('repo', shared=True, |
173 |
format=self.from_format) |
|
4360.10.20
by Ian Clatworthy
fix tests to truly use a shared repository, not standalone branches inside one |
174 |
# Note: self.make_branch() always creates a new repo at the location
|
175 |
# so we need to avoid using that here ...
|
|
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
176 |
b1 = controldir.ControlDir.create_branch_convenience("repo/branch1", |
4360.10.20
by Ian Clatworthy
fix tests to truly use a shared repository, not standalone branches inside one |
177 |
format=self.from_format) |
6472.2.1
by Jelmer Vernooij
Use bzrdir.controldir for generic access to control directories. |
178 |
b2 = controldir.ControlDir.create_branch_convenience("repo/branch2", |
4360.10.20
by Ian Clatworthy
fix tests to truly use a shared repository, not standalone branches inside one |
179 |
format=self.from_format) |
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
180 |
return repo.controldir |
4360.10.1
by Ian Clatworthy
initial cut at smarter upgrades |
181 |
|
182 |
def test_upgrade_repo_with_branches(self): |
|
183 |
control = self.make_repo_with_branches() |
|
4360.10.48
by Vincent Ladeuil
And some more cleanup. |
184 |
tried, worked, issues = upgrade.smart_upgrade( |
185 |
[control], format=self.to_format) |
|
4360.10.39
by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests. |
186 |
self.assertLength(3, tried) |
4360.10.33
by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and |
187 |
self.assertEqual(tried[0], control) |
4360.10.39
by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests. |
188 |
self.assertLength(3, worked) |
4360.10.33
by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and |
189 |
self.assertEqual(worked[0], control) |
4360.10.39
by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests. |
190 |
self.assertLength(0, issues) |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
191 |
self.assertPathExists('repo/backup.bzr.~1~') |
192 |
self.assertPathExists('repo/branch1/backup.bzr.~1~') |
|
193 |
self.assertPathExists('repo/branch2/backup.bzr.~1~') |
|
4360.10.32
by Matthew Fuller
Add some additional assertions into the TestSmartUpgrade tests to |
194 |
self.assertEqual(control.open_repository()._format, |
195 |
self.to_format._repository_format) |
|
4360.10.47
by Vincent Ladeuil
Some cleanup. |
196 |
b1 = branch.Branch.open('repo/branch1') |
4360.10.32
by Matthew Fuller
Add some additional assertions into the TestSmartUpgrade tests to |
197 |
self.assertEqual(b1._format, self.to_format._branch_format) |
4360.10.1
by Ian Clatworthy
initial cut at smarter upgrades |
198 |
|
4360.10.2
by Ian Clatworthy
drop stacked vs unstacked logic; support multiple URLs |
199 |
def test_upgrade_repo_with_branches_cleanup(self): |
200 |
control = self.make_repo_with_branches() |
|
4360.10.48
by Vincent Ladeuil
And some more cleanup. |
201 |
tried, worked, issues = upgrade.smart_upgrade( |
202 |
[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. |
203 |
self.assertLength(3, tried) |
4360.10.33
by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and |
204 |
self.assertEqual(tried[0], control) |
4360.10.39
by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests. |
205 |
self.assertLength(3, worked) |
4360.10.33
by Matthew Fuller
The smart upgrade recurses and returns lists of what it tried and |
206 |
self.assertEqual(worked[0], control) |
4360.10.39
by Vincent Ladeuil
Use assertLength as it provides a better ouput to debug tests. |
207 |
self.assertLength(0, issues) |
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
208 |
self.assertPathExists('repo') |
209 |
self.assertPathExists('repo/.bzr') |
|
210 |
self.assertPathDoesNotExist('repo/backup.bzr.~1~') |
|
211 |
self.assertPathDoesNotExist('repo/branch1/backup.bzr.~1~') |
|
212 |
self.assertPathDoesNotExist('repo/branch2/backup.bzr.~1~') |
|
4360.10.32
by Matthew Fuller
Add some additional assertions into the TestSmartUpgrade tests to |
213 |
self.assertEqual(control.open_repository()._format, |
214 |
self.to_format._repository_format) |
|
4360.10.47
by Vincent Ladeuil
Some cleanup. |
215 |
b1 = branch.Branch.open('repo/branch1') |
4360.10.32
by Matthew Fuller
Add some additional assertions into the TestSmartUpgrade tests to |
216 |
self.assertEqual(b1._format, self.to_format._branch_format) |