2363.5.11
by Aaron Bentley
All info tests pass |
1 |
# Copyright (C) 2007 Canonical Ltd
|
2 |
#
|
|
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.
|
|
7 |
#
|
|
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.
|
|
12 |
#
|
|
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
|
2363.5.11
by Aaron Bentley
All info tests pass |
16 |
|
2804.4.3
by Alexander Belchenko
fix for test_info-tests: using osutils.getcwd instead of os.getcwd (sigh) |
17 |
import sys |
1551.15.43
by Aaron Bentley
Provide ways of getting at unicode-clean output |
18 |
from urllib import quote |
2363.5.11
by Aaron Bentley
All info tests pass |
19 |
|
2363.5.2
by Aaron Bentley
Implement layout description |
20 |
from bzrlib import ( |
2363.5.5
by Aaron Bentley
add info.describe_format |
21 |
branch as _mod_branch, |
2363.5.2
by Aaron Bentley
Implement layout description |
22 |
bzrdir, |
23 |
info, |
|
24 |
tests, |
|
2363.5.5
by Aaron Bentley
add info.describe_format |
25 |
workingtree, |
26 |
repository as _mod_repository, |
|
2363.5.2
by Aaron Bentley
Implement layout description |
27 |
)
|
28 |
||
29 |
||
30 |
class TestInfo(tests.TestCaseWithTransport): |
|
31 |
||
32 |
def test_describe_standalone_layout(self): |
|
33 |
tree = self.make_branch_and_tree('tree') |
|
34 |
self.assertEqual('Empty control directory', info.describe_layout()) |
|
35 |
self.assertEqual('Unshared repository with trees', |
|
36 |
info.describe_layout(tree.branch.repository)) |
|
37 |
tree.branch.repository.set_make_working_trees(False) |
|
38 |
self.assertEqual('Unshared repository', |
|
39 |
info.describe_layout(tree.branch.repository)) |
|
40 |
self.assertEqual('Standalone branch', |
|
41 |
info.describe_layout(tree.branch.repository, tree.branch)) |
|
42 |
self.assertEqual('Standalone branchless tree', |
|
43 |
info.describe_layout(tree.branch.repository, None, tree)) |
|
44 |
self.assertEqual('Standalone tree', |
|
45 |
info.describe_layout(tree.branch.repository, tree.branch, tree)) |
|
46 |
tree.branch.bind(tree.branch) |
|
47 |
self.assertEqual('Bound branch', |
|
48 |
info.describe_layout(tree.branch.repository, tree.branch)) |
|
49 |
self.assertEqual('Checkout', |
|
50 |
info.describe_layout(tree.branch.repository, tree.branch, tree)) |
|
51 |
checkout = tree.branch.create_checkout('checkout', lightweight=True) |
|
52 |
self.assertEqual('Lightweight checkout', |
|
53 |
info.describe_layout(checkout.branch.repository, checkout.branch, |
|
54 |
checkout)) |
|
55 |
||
56 |
def test_describe_repository_layout(self): |
|
57 |
repository = self.make_repository('.', shared=True) |
|
58 |
tree = bzrdir.BzrDir.create_branch_convenience('tree', |
|
59 |
force_new_tree=True).bzrdir.open_workingtree() |
|
60 |
self.assertEqual('Shared repository with trees', |
|
61 |
info.describe_layout(tree.branch.repository)) |
|
62 |
repository.set_make_working_trees(False) |
|
63 |
self.assertEqual('Shared repository', |
|
64 |
info.describe_layout(tree.branch.repository)) |
|
65 |
self.assertEqual('Repository branch', |
|
66 |
info.describe_layout(tree.branch.repository, tree.branch)) |
|
67 |
self.assertEqual('Repository branchless tree', |
|
68 |
info.describe_layout(tree.branch.repository, None, tree)) |
|
69 |
self.assertEqual('Repository tree', |
|
70 |
info.describe_layout(tree.branch.repository, tree.branch, tree)) |
|
71 |
tree.branch.bind(tree.branch) |
|
72 |
self.assertEqual('Repository checkout', |
|
73 |
info.describe_layout(tree.branch.repository, tree.branch, tree)) |
|
74 |
checkout = tree.branch.create_checkout('checkout', lightweight=True) |
|
2363.5.4
by Aaron Bentley
Eliminate the concept of a 'repository lightweight checkout' |
75 |
self.assertEqual('Lightweight checkout', |
2363.5.2
by Aaron Bentley
Implement layout description |
76 |
info.describe_layout(checkout.branch.repository, checkout.branch, |
77 |
checkout)) |
|
2363.5.5
by Aaron Bentley
add info.describe_format |
78 |
|
79 |
def assertTreeDescription(self, format): |
|
2363.5.22
by Aaron Bentley
Restructure tests |
80 |
"""Assert a tree's format description matches expectations"""
|
2363.5.6
by Aaron Bentley
Add short format description |
81 |
self.make_branch_and_tree('%s_tree' % format, format=format) |
2363.5.5
by Aaron Bentley
add info.describe_format |
82 |
tree = workingtree.WorkingTree.open('%s_tree' % format) |
83 |
self.assertEqual(format, info.describe_format(tree.bzrdir, |
|
84 |
tree.branch.repository, tree.branch, tree)) |
|
85 |
||
2363.5.6
by Aaron Bentley
Add short format description |
86 |
def assertCheckoutDescription(self, format, expected=None): |
2363.5.22
by Aaron Bentley
Restructure tests |
87 |
"""Assert a checkout's format description matches expectations"""
|
2363.5.6
by Aaron Bentley
Add short format description |
88 |
if expected is None: |
89 |
expected = format |
|
90 |
branch = self.make_branch('%s_cobranch' % format, format=format) |
|
91 |
# this ought to be easier...
|
|
92 |
branch.create_checkout('%s_co' % format, |
|
93 |
lightweight=True).bzrdir.destroy_workingtree() |
|
94 |
control = bzrdir.BzrDir.open('%s_co' % format) |
|
2363.5.13
by Aaron Bentley
Fix environment pollution with assertCheckoutDescription |
95 |
old_format = control._format.workingtree_format |
96 |
try: |
|
97 |
control._format.workingtree_format = \ |
|
98 |
bzrdir.format_registry.make_bzrdir(format).workingtree_format |
|
99 |
control.create_workingtree() |
|
100 |
tree = workingtree.WorkingTree.open('%s_co' % format) |
|
2592.4.2
by Martin Pool
exempt experimental-* formats from test_describe_checkout_format |
101 |
format_description = info.describe_format(tree.bzrdir, |
102 |
tree.branch.repository, tree.branch, tree) |
|
103 |
self.assertEqual(expected, format_description, |
|
104 |
"checkout of format called %r was described as %r" % |
|
105 |
(expected, format_description)) |
|
2363.5.13
by Aaron Bentley
Fix environment pollution with assertCheckoutDescription |
106 |
finally: |
107 |
control._format.workingtree_format = old_format |
|
2363.5.6
by Aaron Bentley
Add short format description |
108 |
|
2363.5.5
by Aaron Bentley
add info.describe_format |
109 |
def assertBranchDescription(self, format, expected=None): |
2363.5.22
by Aaron Bentley
Restructure tests |
110 |
"""Assert branch's format description matches expectations"""
|
2363.5.5
by Aaron Bentley
add info.describe_format |
111 |
if expected is None: |
112 |
expected = format |
|
2363.5.6
by Aaron Bentley
Add short format description |
113 |
self.make_branch('%s_branch' % format, format=format) |
2363.5.5
by Aaron Bentley
add info.describe_format |
114 |
branch = _mod_branch.Branch.open('%s_branch' % format) |
115 |
self.assertEqual(expected, info.describe_format(branch.bzrdir, |
|
116 |
branch.repository, branch, None)) |
|
117 |
||
118 |
def assertRepoDescription(self, format, expected=None): |
|
2363.5.22
by Aaron Bentley
Restructure tests |
119 |
"""Assert repository's format description matches expectations"""
|
2363.5.5
by Aaron Bentley
add info.describe_format |
120 |
if expected is None: |
121 |
expected = format |
|
2363.5.6
by Aaron Bentley
Add short format description |
122 |
self.make_repository('%s_repo' % format, format=format) |
2363.5.5
by Aaron Bentley
add info.describe_format |
123 |
repo = _mod_repository.Repository.open('%s_repo' % format) |
124 |
self.assertEqual(expected, info.describe_format(repo.bzrdir, |
|
125 |
repo, None, None)) |
|
126 |
||
2363.5.22
by Aaron Bentley
Restructure tests |
127 |
def test_describe_tree_format(self): |
2363.5.5
by Aaron Bentley
add info.describe_format |
128 |
for key in bzrdir.format_registry.keys(): |
3152.2.2
by Robert Collins
The bzrdir format registry now accepts an ``alias`` keyword to |
129 |
if key in bzrdir.format_registry.aliases(): |
2363.5.5
by Aaron Bentley
add info.describe_format |
130 |
continue
|
131 |
self.assertTreeDescription(key) |
|
132 |
||
2363.5.22
by Aaron Bentley
Restructure tests |
133 |
def test_describe_checkout_format(self): |
2363.5.5
by Aaron Bentley
add info.describe_format |
134 |
for key in bzrdir.format_registry.keys(): |
3152.2.2
by Robert Collins
The bzrdir format registry now accepts an ``alias`` keyword to |
135 |
if key in bzrdir.format_registry.aliases(): |
136 |
# Aliases will not describe correctly in the UI because the
|
|
137 |
# real format is found.
|
|
138 |
continue
|
|
139 |
# legacy: weave does not support checkouts
|
|
140 |
if key == 'weave': |
|
141 |
continue
|
|
142 |
if bzrdir.format_registry.get_info(key).experimental: |
|
143 |
# We don't require that experimental formats support checkouts
|
|
144 |
# or describe correctly in the UI.
|
|
2363.5.6
by Aaron Bentley
Add short format description |
145 |
continue
|
146 |
expected = None |
|
2939.2.1
by Ian Clatworthy
use 'knitpack' naming instead of 'experimental' for pack formats |
147 |
if key in ('dirstate', 'dirstate-tags', 'dirstate-with-subtree', |
2996.2.13
by Aaron Bentley
Merge bzr.dev |
148 |
'pack-0.92', 'pack-0.92-subtree', 'rich-root', |
3805.3.3
by Martin Pool
Update info tests for new 1.9 format combo |
149 |
'rich-root-pack', '1.6', '1.6.1-rich-root', |
150 |
'1.9', '1.9-rich-root'): |
|
3606.10.5
by John Arbash Meinel
Switch out --1.6-rich-root for --1.6.1-rich-root. |
151 |
expected = '1.6 or 1.6.1-rich-root or ' \ |
3805.3.3
by Martin Pool
Update info tests for new 1.9 format combo |
152 |
'1.9 or 1.9-rich-root or ' \
|
3575.2.1
by Martin Pool
Rename stacked format to 1.6 |
153 |
'dirstate or dirstate-tags or pack-0.92 or'\
|
154 |
' rich-root or rich-root-pack'
|
|
3586.2.6
by Ian Clatworthy
add 1.7 and 1.7-rich-root formats |
155 |
elif key in ('knit', 'metaweave'): |
2363.5.17
by Aaron Bentley
Change separator from '/' to 'or' |
156 |
expected = 'knit or metaweave' |
4210.4.1
by Ian Clatworthy
replace experimental development-wt5 formats with 1.14 formats |
157 |
elif key in ('1.14', '1.14-rich-root'): |
4265.1.1
by John Arbash Meinel
Merge the a couple rev older brisbane-core into bzr.dev, most things are resolve in favor of bzr.dev |
158 |
expected = '1.14 or 1.14-rich-root' |
2363.5.6
by Aaron Bentley
Add short format description |
159 |
self.assertCheckoutDescription(key, expected) |
160 |
||
2363.5.22
by Aaron Bentley
Restructure tests |
161 |
def test_describe_branch_format(self): |
2363.5.6
by Aaron Bentley
Add short format description |
162 |
for key in bzrdir.format_registry.keys(): |
3152.2.2
by Robert Collins
The bzrdir format registry now accepts an ``alias`` keyword to |
163 |
if key in bzrdir.format_registry.aliases(): |
2363.5.5
by Aaron Bentley
add info.describe_format |
164 |
continue
|
4210.4.2
by Ian Clatworthy
split filtered views support out into WorkingTreeFormat6 |
165 |
if bzrdir.format_registry.get_info(key).hidden: |
166 |
continue
|
|
2363.5.5
by Aaron Bentley
add info.describe_format |
167 |
expected = None |
168 |
if key in ('dirstate', 'knit'): |
|
2363.5.17
by Aaron Bentley
Change separator from '/' to 'or' |
169 |
expected = 'dirstate or knit' |
4210.4.1
by Ian Clatworthy
replace experimental development-wt5 formats with 1.14 formats |
170 |
elif key in ('1.9', '1.14'): |
171 |
expected = '1.14 or 1.9' |
|
172 |
elif key in ('1.9-rich-root', '1.14-rich-root'): |
|
173 |
expected = '1.14-rich-root or 1.9-rich-root' |
|
2363.5.5
by Aaron Bentley
add info.describe_format |
174 |
self.assertBranchDescription(key, expected) |
175 |
||
2363.5.22
by Aaron Bentley
Restructure tests |
176 |
def test_describe_repo_format(self): |
2363.5.5
by Aaron Bentley
add info.describe_format |
177 |
for key in bzrdir.format_registry.keys(): |
3152.2.2
by Robert Collins
The bzrdir format registry now accepts an ``alias`` keyword to |
178 |
if key in bzrdir.format_registry.aliases(): |
2363.5.5
by Aaron Bentley
add info.describe_format |
179 |
continue
|
4210.4.2
by Ian Clatworthy
split filtered views support out into WorkingTreeFormat6 |
180 |
if bzrdir.format_registry.get_info(key).hidden: |
181 |
continue
|
|
2363.5.5
by Aaron Bentley
add info.describe_format |
182 |
expected = None |
183 |
if key in ('dirstate', 'knit', 'dirstate-tags'): |
|
2363.5.17
by Aaron Bentley
Change separator from '/' to 'or' |
184 |
expected = 'dirstate or dirstate-tags or knit' |
4210.4.1
by Ian Clatworthy
replace experimental development-wt5 formats with 1.14 formats |
185 |
elif key in ('1.9', '1.14'): |
186 |
expected = '1.14 or 1.9' |
|
187 |
elif key in ('1.9-rich-root', '1.14-rich-root'): |
|
188 |
expected = '1.14-rich-root or 1.9-rich-root' |
|
2363.5.5
by Aaron Bentley
add info.describe_format |
189 |
self.assertRepoDescription(key, expected) |
190 |
||
191 |
format = bzrdir.format_registry.make_bzrdir('metaweave') |
|
192 |
format.set_branch_format(_mod_branch.BzrBranchFormat6()) |
|
193 |
tree = self.make_branch_and_tree('unknown', format=format) |
|
194 |
self.assertEqual('unnamed', info.describe_format(tree.bzrdir, |
|
195 |
tree.branch.repository, tree.branch, tree)) |
|
2363.5.18
by Aaron Bentley
Get all tests passing |
196 |
|
197 |
def test_gather_location_standalone(self): |
|
198 |
tree = self.make_branch_and_tree('tree') |
|
2363.5.23
by Aaron Bentley
Output 2-tuples from gather_locations |
199 |
self.assertEqual([('branch root', tree.bzrdir.root_transport.base)], |
2363.5.18
by Aaron Bentley
Get all tests passing |
200 |
info.gather_location_info(tree.branch.repository, tree.branch, |
201 |
tree)) |
|
2363.5.23
by Aaron Bentley
Output 2-tuples from gather_locations |
202 |
self.assertEqual([('branch root', tree.bzrdir.root_transport.base)], |
2363.5.18
by Aaron Bentley
Get all tests passing |
203 |
info.gather_location_info(tree.branch.repository, tree.branch)) |
204 |
return tree |
|
205 |
||
206 |
def test_gather_location_repo(self): |
|
207 |
srepo = self.make_repository('shared', shared=True) |
|
2363.5.23
by Aaron Bentley
Output 2-tuples from gather_locations |
208 |
self.assertEqual([('shared repository', |
209 |
srepo.bzrdir.root_transport.base)], |
|
2363.5.18
by Aaron Bentley
Get all tests passing |
210 |
info.gather_location_info(srepo)) |
211 |
urepo = self.make_repository('unshared') |
|
2363.5.23
by Aaron Bentley
Output 2-tuples from gather_locations |
212 |
self.assertEqual([('repository', |
213 |
urepo.bzrdir.root_transport.base)], |
|
2363.5.18
by Aaron Bentley
Get all tests passing |
214 |
info.gather_location_info(urepo)) |
215 |
||
216 |
def test_gather_location_repo_branch(self): |
|
217 |
srepo = self.make_repository('shared', shared=True) |
|
2363.5.23
by Aaron Bentley
Output 2-tuples from gather_locations |
218 |
self.assertEqual([('shared repository', |
219 |
srepo.bzrdir.root_transport.base)], |
|
2363.5.18
by Aaron Bentley
Get all tests passing |
220 |
info.gather_location_info(srepo)) |
221 |
tree = self.make_branch_and_tree('shared/tree') |
|
2363.5.23
by Aaron Bentley
Output 2-tuples from gather_locations |
222 |
self.assertEqual([('shared repository', |
223 |
srepo.bzrdir.root_transport.base), |
|
1551.15.41
by Aaron Bentley
Make info provide more related brances, and format all branches nicely |
224 |
('repository branch', tree.branch.base)], |
2363.5.25
by Aaron Bentley
Update deprecations to 0.18.0 |
225 |
info.gather_location_info(srepo, tree.branch, tree)) |
2363.5.18
by Aaron Bentley
Get all tests passing |
226 |
|
2363.5.22
by Aaron Bentley
Restructure tests |
227 |
def test_gather_location_light_checkout(self): |
2363.5.18
by Aaron Bentley
Get all tests passing |
228 |
tree = self.make_branch_and_tree('tree') |
229 |
lcheckout = tree.branch.create_checkout('lcheckout', lightweight=True) |
|
230 |
self.assertEqual( |
|
2363.5.23
by Aaron Bentley
Output 2-tuples from gather_locations |
231 |
[('light checkout root', lcheckout.bzrdir.root_transport.base), |
232 |
('checkout of branch', tree.bzrdir.root_transport.base)], |
|
2363.5.22
by Aaron Bentley
Restructure tests |
233 |
self.gather_tree_location_info(lcheckout)) |
234 |
||
235 |
def test_gather_location_heavy_checkout(self): |
|
236 |
tree = self.make_branch_and_tree('tree') |
|
237 |
checkout = tree.branch.create_checkout('checkout') |
|
238 |
self.assertEqual( |
|
2363.5.23
by Aaron Bentley
Output 2-tuples from gather_locations |
239 |
[('checkout root', checkout.bzrdir.root_transport.base), |
240 |
('checkout of branch', tree.bzrdir.root_transport.base)], |
|
2363.5.22
by Aaron Bentley
Restructure tests |
241 |
self.gather_tree_location_info(checkout)) |
242 |
light_checkout = checkout.branch.create_checkout('light_checkout', |
|
243 |
lightweight=True) |
|
244 |
self.assertEqual( |
|
2363.5.23
by Aaron Bentley
Output 2-tuples from gather_locations |
245 |
[('light checkout root', |
246 |
light_checkout.bzrdir.root_transport.base), |
|
247 |
('checkout root', checkout.bzrdir.root_transport.base), |
|
248 |
('checkout of branch', tree.bzrdir.root_transport.base)], |
|
2363.5.22
by Aaron Bentley
Restructure tests |
249 |
self.gather_tree_location_info(light_checkout) |
250 |
)
|
|
251 |
||
252 |
def test_gather_location_shared_repo_checkout(self): |
|
253 |
tree = self.make_branch_and_tree('tree') |
|
2363.5.18
by Aaron Bentley
Get all tests passing |
254 |
srepo = self.make_repository('shared', shared=True) |
2363.5.22
by Aaron Bentley
Restructure tests |
255 |
shared_checkout = tree.branch.create_checkout('shared/checkout') |
2363.5.18
by Aaron Bentley
Get all tests passing |
256 |
self.assertEqual( |
2363.5.23
by Aaron Bentley
Output 2-tuples from gather_locations |
257 |
[('repository checkout root', |
258 |
shared_checkout.bzrdir.root_transport.base), |
|
259 |
('checkout of branch', tree.bzrdir.root_transport.base), |
|
260 |
('shared repository', srepo.bzrdir.root_transport.base)], |
|
2363.5.22
by Aaron Bentley
Restructure tests |
261 |
self.gather_tree_location_info(shared_checkout)) |
262 |
||
263 |
def gather_tree_location_info(self, tree): |
|
264 |
return info.gather_location_info(tree.branch.repository, tree.branch, |
|
265 |
tree) |
|
2363.5.19
by Aaron Bentley
Add support for bound branches |
266 |
|
267 |
def test_gather_location_bound(self): |
|
268 |
branch = self.make_branch('branch') |
|
269 |
bound_branch = self.make_branch('bound_branch') |
|
270 |
bound_branch.bind(branch) |
|
271 |
self.assertEqual( |
|
2363.5.23
by Aaron Bentley
Output 2-tuples from gather_locations |
272 |
[('branch root', bound_branch.bzrdir.root_transport.base), |
273 |
('bound to branch', branch.bzrdir.root_transport.base)], |
|
2363.5.19
by Aaron Bentley
Add support for bound branches |
274 |
info.gather_location_info(bound_branch.repository, bound_branch) |
275 |
)
|
|
1551.15.41
by Aaron Bentley
Make info provide more related brances, and format all branches nicely |
276 |
|
277 |
def test_location_list(self): |
|
2804.4.3
by Alexander Belchenko
fix for test_info-tests: using osutils.getcwd instead of os.getcwd (sigh) |
278 |
if sys.platform == 'win32': |
279 |
raise tests.TestSkipped('Windows-unfriendly test') |
|
1551.15.41
by Aaron Bentley
Make info provide more related brances, and format all branches nicely |
280 |
locs = info.LocationList('/home/foo') |
281 |
locs.add_url('a', 'file:///home/foo/') |
|
282 |
locs.add_url('b', 'file:///home/foo/bar/') |
|
283 |
locs.add_url('c', 'file:///home/bar/bar') |
|
284 |
locs.add_url('d', 'http://example.com/example/') |
|
285 |
locs.add_url('e', None) |
|
1551.15.43
by Aaron Bentley
Provide ways of getting at unicode-clean output |
286 |
self.assertEqual(locs.locs, [('a', '.'), |
1551.15.41
by Aaron Bentley
Make info provide more related brances, and format all branches nicely |
287 |
('b', 'bar'), |
288 |
('c', '/home/bar/bar'), |
|
289 |
('d', 'http://example.com/example/')]) |
|
1551.15.43
by Aaron Bentley
Provide ways of getting at unicode-clean output |
290 |
self.assertEqualDiff(' a: .\n b: bar\n c: /home/bar/bar\n' |
291 |
' d: http://example.com/example/\n', |
|
292 |
''.join(locs.get_lines())) |
|
1551.15.41
by Aaron Bentley
Make info provide more related brances, and format all branches nicely |
293 |
|
294 |
def test_gather_related_braches(self): |
|
295 |
branch = self.make_branch('.') |
|
296 |
branch.set_public_branch('baz') |
|
297 |
branch.set_push_location('bar') |
|
298 |
branch.set_parent('foo') |
|
299 |
branch.set_submit_branch('qux') |
|
300 |
self.assertEqual( |
|
301 |
[('public branch', 'baz'), ('push branch', 'bar'), |
|
302 |
('parent branch', 'foo'), ('submit branch', 'qux')], |
|
1551.15.43
by Aaron Bentley
Provide ways of getting at unicode-clean output |
303 |
info._gather_related_branches(branch).locs) |