bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2255.7.83
by John Arbash Meinel
Update some obvious copyright headers to include 2007. |
1 |
# Copyright (C) 2006, 2007 Canonical Ltd
|
|
1852.6.1
by Robert Collins
Start tree implementation tests. |
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
|
|
1852.6.1
by Robert Collins
Start tree implementation tests. |
16 |
|
|
4523.1.4
by Martin Pool
Rename remaining *_implementations tests |
17 |
"""Tests for the test trees used by the per_tree tests."""
|
|
1852.6.1
by Robert Collins
Start tree implementation tests. |
18 |
|
|
6913.1.1
by Jelmer Vernooij
Move utf-8 specific code closer to where it's run, and make foreign branch compatible. |
19 |
from breezy import errors |
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
20 |
from breezy.tests import per_tree |
21 |
from breezy.tests import ( |
|
|
6861.1.1
by Jelmer Vernooij
More foreign branch test fixes. |
22 |
TestNotApplicable, |
|
6913.1.1
by Jelmer Vernooij
Move utf-8 specific code closer to where it's run, and make foreign branch compatible. |
23 |
TestSkipped, |
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
24 |
features, |
25 |
)
|
|
|
4523.1.4
by Martin Pool
Rename remaining *_implementations tests |
26 |
|
27 |
||
28 |
class TestTreeShapes(per_tree.TestCaseWithTree): |
|
|
1852.6.1
by Robert Collins
Start tree implementation tests. |
29 |
|
30 |
def test_empty_tree_no_parents(self): |
|
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
31 |
tree = self.make_branch_and_tree('.') |
32 |
tree = self.get_tree_no_parents_no_content(tree) |
|
|
2255.2.64
by John Arbash Meinel
Add the DirStateRevisionTree to the list of 'tree_implementations' |
33 |
tree.lock_read() |
34 |
self.addCleanup(tree.unlock) |
|
|
1852.6.1
by Robert Collins
Start tree implementation tests. |
35 |
self.assertEqual([], tree.get_parent_ids()) |
36 |
self.assertEqual([], tree.conflicts()) |
|
37 |
self.assertEqual([], list(tree.unknowns())) |
|
|
6825.5.1
by Jelmer Vernooij
Implement Tree.all_versioned_paths. |
38 |
self.assertEqual([''], list(tree.all_versioned_paths())) |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
39 |
self.assertEqual( |
|
6844.1.1
by Jelmer Vernooij
Many more foreign branch fixes. |
40 |
[('', tree.path2id(''))], |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
41 |
[(path, node.file_id) for path, node in tree.iter_entries_by_dir()]) |
42 |
||
43 |
def test_abc_tree_no_parents(self): |
|
|
1852.8.7
by Robert Collins
Update tree_implementation test tree factories to be intertree ready. |
44 |
tree = self.make_branch_and_tree('.') |
45 |
tree = self.get_tree_no_parents_abc_content(tree) |
|
|
2255.2.64
by John Arbash Meinel
Add the DirStateRevisionTree to the list of 'tree_implementations' |
46 |
tree.lock_read() |
47 |
self.addCleanup(tree.unlock) |
|
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
48 |
self.assertEqual([], tree.get_parent_ids()) |
49 |
self.assertEqual([], tree.conflicts()) |
|
50 |
self.assertEqual([], list(tree.unknowns())) |
|
51 |
# __iter__ has no strongly defined order
|
|
52 |
self.assertEqual( |
|
|
6825.5.1
by Jelmer Vernooij
Implement Tree.all_versioned_paths. |
53 |
{'', 'a', 'b', 'b/c'}, |
54 |
set(tree.all_versioned_paths())) |
|
|
6852.3.1
by Jelmer Vernooij
add Tree.is_versioned. |
55 |
self.assertTrue(tree.is_versioned('a')) |
56 |
self.assertTrue(tree.is_versioned('b')) |
|
57 |
self.assertTrue(tree.is_versioned('b/c')) |
|
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
58 |
self.assertEqual( |
|
6793.5.1
by Jelmer Vernooij
Hardcode fileids in fewer places. |
59 |
[(p, tree.path2id(p)) for p in ['', 'a', 'b', 'b/c']], |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
60 |
[(path, node.file_id) for path, node in tree.iter_entries_by_dir()]) |
|
6973.7.3
by Jelmer Vernooij
Fix some more tests. |
61 |
self.assertEqualDiff(b'contents of a\n', tree.get_file_text('a')) |
|
6809.4.4
by Jelmer Vernooij
Swap arguments for Tree.is_executable. |
62 |
self.assertFalse(tree.is_executable('b/c')) |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
63 |
|
64 |
def test_abc_tree_content_2_no_parents(self): |
|
|
1852.8.7
by Robert Collins
Update tree_implementation test tree factories to be intertree ready. |
65 |
tree = self.make_branch_and_tree('.') |
66 |
tree = self.get_tree_no_parents_abc_content_2(tree) |
|
|
2255.2.64
by John Arbash Meinel
Add the DirStateRevisionTree to the list of 'tree_implementations' |
67 |
tree.lock_read() |
68 |
self.addCleanup(tree.unlock) |
|
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
69 |
self.assertEqual([], tree.get_parent_ids()) |
70 |
self.assertEqual([], tree.conflicts()) |
|
71 |
self.assertEqual([], list(tree.unknowns())) |
|
72 |
# __iter__ has no strongly defined order
|
|
73 |
self.assertEqual( |
|
|
6825.5.1
by Jelmer Vernooij
Implement Tree.all_versioned_paths. |
74 |
{'', 'a', 'b', 'b/c'}, |
75 |
set(tree.all_versioned_paths())) |
|
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
76 |
self.assertEqual( |
|
6793.5.1
by Jelmer Vernooij
Hardcode fileids in fewer places. |
77 |
[(p, tree.path2id(p)) for p in ['', 'a', 'b', 'b/c']], |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
78 |
[(path, node.file_id) for path, node in tree.iter_entries_by_dir()]) |
|
7397.2.3
by Jelmer Vernooij
Fix passing directories in specific_files in GitWorkingTree. |
79 |
self.assertEqual( |
80 |
[(p, tree.path2id(p)) for p in ['b']], |
|
81 |
[(path, node.file_id) for path, node in tree.iter_entries_by_dir( |
|
82 |
specific_files=['b'])]) |
|
|
6973.7.3
by Jelmer Vernooij
Fix some more tests. |
83 |
self.assertEqualDiff(b'foobar\n', tree.get_file_text('a')) |
|
6809.4.4
by Jelmer Vernooij
Swap arguments for Tree.is_executable. |
84 |
self.assertFalse(tree.is_executable('b//c')) |
|
7397.2.3
by Jelmer Vernooij
Fix passing directories in specific_files in GitWorkingTree. |
85 |
self.assertFalse(tree.is_executable('b/c')) |
|
2255.2.64
by John Arbash Meinel
Add the DirStateRevisionTree to the list of 'tree_implementations' |
86 |
|
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
87 |
def test_abc_tree_content_3_no_parents(self): |
|
1852.8.7
by Robert Collins
Update tree_implementation test tree factories to be intertree ready. |
88 |
tree = self.make_branch_and_tree('.') |
89 |
tree = self.get_tree_no_parents_abc_content_3(tree) |
|
|
2255.2.64
by John Arbash Meinel
Add the DirStateRevisionTree to the list of 'tree_implementations' |
90 |
tree.lock_read() |
91 |
self.addCleanup(tree.unlock) |
|
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
92 |
self.assertEqual([], tree.get_parent_ids()) |
93 |
self.assertEqual([], tree.conflicts()) |
|
94 |
self.assertEqual([], list(tree.unknowns())) |
|
95 |
# __iter__ has no strongly defined order
|
|
96 |
self.assertEqual( |
|
|
6825.5.1
by Jelmer Vernooij
Implement Tree.all_versioned_paths. |
97 |
{'', 'a', 'b', 'b/c'}, |
98 |
set(tree.all_versioned_paths())) |
|
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
99 |
self.assertEqual( |
|
6793.5.1
by Jelmer Vernooij
Hardcode fileids in fewer places. |
100 |
[(p, tree.path2id(p)) for p in ['', 'a', 'b', 'b/c']], |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
101 |
[(path, node.file_id) for path, node in tree.iter_entries_by_dir()]) |
|
6973.7.3
by Jelmer Vernooij
Fix some more tests. |
102 |
self.assertEqualDiff(b'contents of a\n', tree.get_file_text('a')) |
|
6809.4.4
by Jelmer Vernooij
Swap arguments for Tree.is_executable. |
103 |
self.assertTrue(tree.is_executable('b/c')) |
|
2255.2.64
by John Arbash Meinel
Add the DirStateRevisionTree to the list of 'tree_implementations' |
104 |
|
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
105 |
def test_abc_tree_content_4_no_parents(self): |
|
1852.8.7
by Robert Collins
Update tree_implementation test tree factories to be intertree ready. |
106 |
tree = self.make_branch_and_tree('.') |
107 |
tree = self.get_tree_no_parents_abc_content_4(tree) |
|
|
2255.2.64
by John Arbash Meinel
Add the DirStateRevisionTree to the list of 'tree_implementations' |
108 |
tree.lock_read() |
109 |
self.addCleanup(tree.unlock) |
|
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
110 |
self.assertEqual([], tree.get_parent_ids()) |
111 |
self.assertEqual([], tree.conflicts()) |
|
112 |
self.assertEqual([], list(tree.unknowns())) |
|
113 |
# __iter__ has no strongly defined order
|
|
114 |
self.assertEqual( |
|
|
6825.5.1
by Jelmer Vernooij
Implement Tree.all_versioned_paths. |
115 |
{'', 'b', 'd', 'b/c'}, |
116 |
set(tree.all_versioned_paths())) |
|
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
117 |
self.assertEqual( |
|
6793.5.1
by Jelmer Vernooij
Hardcode fileids in fewer places. |
118 |
[(p, tree.path2id(p)) for p in ['', 'b', 'd', 'b/c']], |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
119 |
[(path, node.file_id) for path, node in tree.iter_entries_by_dir()]) |
|
6973.7.3
by Jelmer Vernooij
Fix some more tests. |
120 |
self.assertEqualDiff(b'contents of a\n', tree.get_file_text('d')) |
|
6809.4.4
by Jelmer Vernooij
Swap arguments for Tree.is_executable. |
121 |
self.assertFalse(tree.is_executable('b/c')) |
|
2255.2.64
by John Arbash Meinel
Add the DirStateRevisionTree to the list of 'tree_implementations' |
122 |
|
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
123 |
def test_abc_tree_content_5_no_parents(self): |
|
1852.8.7
by Robert Collins
Update tree_implementation test tree factories to be intertree ready. |
124 |
tree = self.make_branch_and_tree('.') |
125 |
tree = self.get_tree_no_parents_abc_content_5(tree) |
|
|
2255.2.64
by John Arbash Meinel
Add the DirStateRevisionTree to the list of 'tree_implementations' |
126 |
tree.lock_read() |
127 |
self.addCleanup(tree.unlock) |
|
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
128 |
self.assertEqual([], tree.get_parent_ids()) |
129 |
self.assertEqual([], tree.conflicts()) |
|
130 |
self.assertEqual([], list(tree.unknowns())) |
|
131 |
# __iter__ has no strongly defined order
|
|
132 |
self.assertEqual( |
|
|
6825.5.1
by Jelmer Vernooij
Implement Tree.all_versioned_paths. |
133 |
{'', 'd', 'b', 'b/c'}, |
134 |
set(tree.all_versioned_paths())) |
|
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
135 |
self.assertEqual( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
136 |
[(p, tree.path2id(p)) for p in ['', 'b', 'd', 'b/c']], |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
137 |
[(path, node.file_id) for path, node in tree.iter_entries_by_dir()]) |
|
6973.7.3
by Jelmer Vernooij
Fix some more tests. |
138 |
self.assertEqualDiff(b'bar\n', tree.get_file_text('d')) |
|
6809.4.4
by Jelmer Vernooij
Swap arguments for Tree.is_executable. |
139 |
self.assertFalse(tree.is_executable('b/c')) |
|
2255.2.64
by John Arbash Meinel
Add the DirStateRevisionTree to the list of 'tree_implementations' |
140 |
|
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
141 |
def test_abc_tree_content_6_no_parents(self): |
|
1852.8.7
by Robert Collins
Update tree_implementation test tree factories to be intertree ready. |
142 |
tree = self.make_branch_and_tree('.') |
143 |
tree = self.get_tree_no_parents_abc_content_6(tree) |
|
|
2255.2.64
by John Arbash Meinel
Add the DirStateRevisionTree to the list of 'tree_implementations' |
144 |
tree.lock_read() |
145 |
self.addCleanup(tree.unlock) |
|
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
146 |
self.assertEqual([], tree.get_parent_ids()) |
147 |
self.assertEqual([], tree.conflicts()) |
|
|
7199.3.1
by Jelmer Vernooij
Don't report empty directories as changes. |
148 |
self.assertEqual([], list(tree.unknowns())) |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
149 |
# __iter__ has no strongly defined order
|
|
6844.1.1
by Jelmer Vernooij
Many more foreign branch fixes. |
150 |
expected_paths = ( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
151 |
['', 'a'] |
|
7143.15.5
by Jelmer Vernooij
More PEP8 fixes. |
152 |
+ (['b'] if tree.has_versioned_directories() else []) |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
153 |
+ ['e']) |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
154 |
self.assertEqual( |
|
6844.1.1
by Jelmer Vernooij
Many more foreign branch fixes. |
155 |
set(expected_paths), |
|
6825.5.1
by Jelmer Vernooij
Implement Tree.all_versioned_paths. |
156 |
set(tree.all_versioned_paths())) |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
157 |
self.assertEqual( |
|
6844.1.1
by Jelmer Vernooij
Many more foreign branch fixes. |
158 |
[(p, tree.path2id(p)) for p in expected_paths], |
|
1852.6.9
by Robert Collins
Add more test trees to the tree-implementations tests. |
159 |
[(path, node.file_id) for path, node in tree.iter_entries_by_dir()]) |
|
6973.7.3
by Jelmer Vernooij
Fix some more tests. |
160 |
self.assertEqualDiff(b'contents of a\n', tree.get_file_text('a')) |
|
6809.4.4
by Jelmer Vernooij
Swap arguments for Tree.is_executable. |
161 |
self.assertTrue(tree.is_executable('e')) |
|
2294.1.1
by John Arbash Meinel
Track down some non-ascii deficiencies in commit logic. |
162 |
|
|
1852.15.1
by Robert Collins
Add a complex test tree for use with Tree.walkdirs. |
163 |
def test_tree_with_subdirs_and_all_content_types(self): |
164 |
# currently this test tree requires unicode. It might be good
|
|
165 |
# to have it simply stop having the single unicode file in it
|
|
166 |
# when dealing with a non-unicode filesystem.
|
|
|
5967.12.1
by Martin Pool
Move all test features into bzrlib.tests.features |
167 |
self.requireFeature(features.SymlinkFeature) |
|
1852.15.1
by Robert Collins
Add a complex test tree for use with Tree.walkdirs. |
168 |
tree = self.get_tree_with_subdirs_and_all_content_types() |
|
2255.2.64
by John Arbash Meinel
Add the DirStateRevisionTree to the list of 'tree_implementations' |
169 |
tree.lock_read() |
170 |
self.addCleanup(tree.unlock) |
|
|
1852.15.1
by Robert Collins
Add a complex test tree for use with Tree.walkdirs. |
171 |
self.assertEqual([], tree.get_parent_ids()) |
172 |
self.assertEqual([], tree.conflicts()) |
|
|
7199.3.1
by Jelmer Vernooij
Don't report empty directories as changes. |
173 |
self.assertEqual([], list(tree.unknowns())) |
|
1852.15.1
by Robert Collins
Add a complex test tree for use with Tree.walkdirs. |
174 |
# __iter__ has no strongly defined order
|
|
2255.2.17
by Robert Collins
tweaks - finishes off all the test_test_trees tests for dirstate. |
175 |
tree_root = tree.path2id('') |
|
7170.3.1
by Jelmer Vernooij
Make Tree.all_file_ids optional. |
176 |
try: |
177 |
all_file_ids = set(tree.all_file_ids()) |
|
178 |
except errors.UnsupportedOperation: |
|
179 |
all_file_ids = None |
|
|
6913.1.1
by Jelmer Vernooij
Move utf-8 specific code closer to where it's run, and make foreign branch compatible. |
180 |
if tree.has_versioned_directories(): |
|
7170.3.1
by Jelmer Vernooij
Make Tree.all_file_ids optional. |
181 |
if all_file_ids is not None: |
182 |
self.assertEqual( |
|
183 |
{tree.path2id(p) for p in [ |
|
184 |
'', '0file', '1top-dir', '1top-dir/1dir-in-1topdir', |
|
185 |
'1top-dir/0file-in-1topdir', 'symlink', u'2utf\u1234file']}, |
|
186 |
set(tree.all_file_ids())) |
|
|
6913.1.1
by Jelmer Vernooij
Move utf-8 specific code closer to where it's run, and make foreign branch compatible. |
187 |
# note that the order of the paths and fileids is deliberately
|
188 |
# mismatched to ensure that the result order is path based.
|
|
189 |
self.assertEqual( |
|
190 |
[('', 'directory'), |
|
191 |
('0file', 'file'), |
|
192 |
('1top-dir', 'directory'), |
|
193 |
(u'2utf\u1234file', 'file'), |
|
194 |
('symlink', 'symlink'), |
|
195 |
('1top-dir/0file-in-1topdir', 'file'), |
|
196 |
('1top-dir/1dir-in-1topdir', 'directory')], |
|
197 |
[(path, node.kind) for path, node in tree.iter_entries_by_dir()]) |
|
198 |
else: |
|
|
7170.3.1
by Jelmer Vernooij
Make Tree.all_file_ids optional. |
199 |
if all_file_ids is not None: |
200 |
self.assertEqual( |
|
201 |
{tree.path2id(p) for p in [ |
|
202 |
'', '0file', '1top-dir', |
|
|
7170.3.2
by Jelmer Vernooij
Merge trunk. |
203 |
'1top-dir/0file-in-1topdir', 'symlink', |
204 |
u'2utf\u1234file']}, |
|
|
7170.3.1
by Jelmer Vernooij
Make Tree.all_file_ids optional. |
205 |
set(tree.all_file_ids())) |
|
6913.1.1
by Jelmer Vernooij
Move utf-8 specific code closer to where it's run, and make foreign branch compatible. |
206 |
# note that the order of the paths and fileids is deliberately
|
207 |
# mismatched to ensure that the result order is path based.
|
|
208 |
self.assertEqual( |
|
209 |
[('', 'directory'), |
|
210 |
('0file', 'file'), |
|
211 |
('1top-dir', 'directory'), |
|
212 |
(u'2utf\u1234file', 'file'), |
|
213 |
('symlink', 'symlink'), |
|
214 |
('1top-dir/0file-in-1topdir', 'file')], |
|
215 |
[(path, node.kind) for path, node in tree.iter_entries_by_dir()]) |
|
|
2255.2.106
by John Arbash Meinel
[merge] bzr.dev 2298 (broken) |
216 |
|
|
2408.1.3
by Alexander Belchenko
tree_implementations: make usage of symlinks optional |
217 |
def test_tree_with_subdirs_and_all_content_types_wo_symlinks(self): |
218 |
# currently this test tree requires unicode. It might be good
|
|
219 |
# to have it simply stop having the single unicode file in it
|
|
220 |
# when dealing with a non-unicode filesystem.
|
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
221 |
tree = self.get_tree_with_subdirs_and_all_supported_content_types( |
222 |
False) |
|
|
2408.1.3
by Alexander Belchenko
tree_implementations: make usage of symlinks optional |
223 |
tree.lock_read() |
224 |
self.addCleanup(tree.unlock) |
|
225 |
self.assertEqual([], tree.get_parent_ids()) |
|
226 |
self.assertEqual([], tree.conflicts()) |
|
|
7199.3.1
by Jelmer Vernooij
Don't report empty directories as changes. |
227 |
self.assertEqual([], list(tree.unknowns())) |
|
2408.1.3
by Alexander Belchenko
tree_implementations: make usage of symlinks optional |
228 |
# __iter__ has no strongly defined order
|
229 |
tree_root = tree.path2id('') |
|
|
6913.1.1
by Jelmer Vernooij
Move utf-8 specific code closer to where it's run, and make foreign branch compatible. |
230 |
if tree.has_versioned_directories(): |
231 |
self.assertEqual( |
|
232 |
{'', '0file', '1top-dir', '1top-dir/0file-in-1topdir', |
|
233 |
'1top-dir/1dir-in-1topdir', u'2utf\u1234file'}, |
|
234 |
set(tree.all_versioned_paths())) |
|
235 |
# note that the order of the paths and fileids is deliberately
|
|
236 |
# mismatched to ensure that the result order is path based.
|
|
237 |
self.assertEqual( |
|
238 |
[('', 'directory'), |
|
239 |
('0file', 'file'), |
|
240 |
('1top-dir', 'directory'), |
|
241 |
(u'2utf\u1234file', 'file'), |
|
242 |
('1top-dir/0file-in-1topdir', 'file'), |
|
243 |
('1top-dir/1dir-in-1topdir', 'directory')], |
|
244 |
[(path, node.kind) for path, node in tree.iter_entries_by_dir()]) |
|
245 |
else: |
|
246 |
self.assertEqual( |
|
247 |
{'', '0file', '1top-dir', '1top-dir/0file-in-1topdir', |
|
248 |
u'2utf\u1234file'}, |
|
249 |
set(tree.all_versioned_paths())) |
|
250 |
# note that the order of the paths and fileids is deliberately
|
|
251 |
# mismatched to ensure that the result order is path based.
|
|
252 |
self.assertEqual( |
|
253 |
[('', 'directory'), |
|
254 |
('0file', 'file'), |
|
255 |
('1top-dir', 'directory'), |
|
256 |
(u'2utf\u1234file', 'file'), |
|
257 |
('1top-dir/0file-in-1topdir', 'file')], |
|
258 |
[(path, node.kind) for path, node in tree.iter_entries_by_dir()]) |
|
259 |
||
260 |
def _create_tree_with_utf8(self, tree): |
|
261 |
self.requireFeature(features.UnicodeFilenameFeature) |
|
262 |
||
263 |
# We avoid combining characters in file names here, normalization
|
|
264 |
# checks (as performed by some file systems (OSX) are outside the scope
|
|
265 |
# of these tests). We use the euro sign \N{Euro Sign} or \u20ac in
|
|
266 |
# unicode strings or '\xe2\x82\ac' (its utf-8 encoding) in raw strings.
|
|
267 |
paths = [u'', |
|
268 |
u'fo\N{Euro Sign}o', |
|
269 |
u'ba\N{Euro Sign}r/', |
|
270 |
u'ba\N{Euro Sign}r/ba\N{Euro Sign}z', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
271 |
]
|
|
6913.1.1
by Jelmer Vernooij
Move utf-8 specific code closer to where it's run, and make foreign branch compatible. |
272 |
# bzr itself does not create unicode file ids, but we want them for
|
273 |
# testing.
|
|
|
7045.4.11
by Jelmer Vernooij
Some more tests fixed. |
274 |
file_ids = [b'TREE_ROOT', |
275 |
b'fo\xe2\x82\xaco-id', |
|
276 |
b'ba\xe2\x82\xacr-id', |
|
277 |
b'ba\xe2\x82\xacz-id', |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
278 |
]
|
|
6913.1.1
by Jelmer Vernooij
Move utf-8 specific code closer to where it's run, and make foreign branch compatible. |
279 |
self.build_tree(paths[1:]) |
|
7358.14.1
by Jelmer Vernooij
Remove Tree.get_root_id() in favour of Tree.path2id(''). |
280 |
if tree.path2id('') is None: |
|
6913.1.1
by Jelmer Vernooij
Move utf-8 specific code closer to where it's run, and make foreign branch compatible. |
281 |
# Some trees do not have a root yet.
|
282 |
tree.add(paths, file_ids) |
|
283 |
else: |
|
284 |
# Some trees will already have a root
|
|
285 |
if tree.supports_setting_file_ids(): |
|
286 |
tree.set_root_id(file_ids[0]) |
|
287 |
tree.add(paths[1:], file_ids[1:]) |
|
288 |
else: |
|
289 |
tree.add(paths[1:]) |
|
290 |
if tree.branch.repository._format.supports_setting_revision_ids: |
|
291 |
try: |
|
292 |
tree.commit(u'in\xedtial', rev_id=u'r\xe9v-1'.encode('utf8')) |
|
293 |
except errors.NonAsciiRevisionId: |
|
294 |
raise TestSkipped('non-ascii revision ids not supported') |
|
295 |
else: |
|
296 |
tree.commit(u'in\xedtial') |
|
297 |
||
298 |
return tree |
|
|
2408.1.3
by Alexander Belchenko
tree_implementations: make usage of symlinks optional |
299 |
|
|
2294.1.1
by John Arbash Meinel
Track down some non-ascii deficiencies in commit logic. |
300 |
def test_tree_with_utf8(self): |
301 |
tree = self.make_branch_and_tree('.') |
|
|
6861.1.2
by Jelmer Vernooij
Fix test. |
302 |
if not tree.supports_setting_file_ids(): |
|
6861.1.1
by Jelmer Vernooij
More foreign branch test fixes. |
303 |
raise TestNotApplicable( |
304 |
'format does not support custom file ids') |
|
|
6913.1.1
by Jelmer Vernooij
Move utf-8 specific code closer to where it's run, and make foreign branch compatible. |
305 |
self._create_tree_with_utf8(tree) |
306 |
||
307 |
tree = self.workingtree_to_test_tree(tree) |
|
|
2294.1.2
by John Arbash Meinel
Track down and add tests that all tree.commit() can handle |
308 |
|
|
2294.1.3
by John Arbash Meinel
Make sure the inventory enrtries returned are properly formed. |
309 |
revision_id = u'r\xe9v-1'.encode('utf8') |
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
310 |
root_id = b'TREE_ROOT' |
|
3638.3.12
by Vincent Ladeuil
Fix test missed in the previous commit (--starting-with doesn't |
311 |
bar_id = u'ba\N{Euro Sign}r-id'.encode('utf8') |
312 |
foo_id = u'fo\N{Euro Sign}o-id'.encode('utf8') |
|
313 |
baz_id = u'ba\N{Euro Sign}z-id'.encode('utf8') |
|
314 |
path_and_ids = [(u'', root_id, None, None), |
|
315 |
(u'ba\N{Euro Sign}r', bar_id, root_id, revision_id), |
|
316 |
(u'fo\N{Euro Sign}o', foo_id, root_id, revision_id), |
|
317 |
(u'ba\N{Euro Sign}r/ba\N{Euro Sign}z', |
|
318 |
baz_id, bar_id, revision_id), |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
319 |
]
|
|
6885.6.1
by Jelmer Vernooij
Support specific_files argument to Tree.iter_entries_by_dir. |
320 |
with tree.lock_read(): |
|
2294.1.3
by John Arbash Meinel
Make sure the inventory enrtries returned are properly formed. |
321 |
path_entries = list(tree.iter_entries_by_dir()) |
322 |
||
|
2294.1.7
by John Arbash Meinel
Add tests for parent ids in test_test_trees |
323 |
for expected, (path, ie) in zip(path_and_ids, path_entries): |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
324 |
self.assertEqual(expected[0], path) # Paths should match |
|
7479.2.1
by Jelmer Vernooij
Drop python2 support. |
325 |
self.assertIsInstance(path, str) |
|
2294.1.7
by John Arbash Meinel
Add tests for parent ids in test_test_trees |
326 |
self.assertEqual(expected[1], ie.file_id) |
|
7045.4.34
by Jelmer Vernooij
Fix some more tests. |
327 |
self.assertIsInstance(ie.file_id, bytes) |
|
2294.1.7
by John Arbash Meinel
Add tests for parent ids in test_test_trees |
328 |
self.assertEqual(expected[2], ie.parent_id) |
329 |
if expected[2] is not None: |
|
|
7045.4.34
by Jelmer Vernooij
Fix some more tests. |
330 |
self.assertIsInstance(ie.parent_id, bytes) |
|
2294.1.3
by John Arbash Meinel
Make sure the inventory enrtries returned are properly formed. |
331 |
# WorkingTree's return None for the last modified revision
|
|
2294.1.7
by John Arbash Meinel
Add tests for parent ids in test_test_trees |
332 |
if ie.revision is not None: |
|
7045.4.34
by Jelmer Vernooij
Fix some more tests. |
333 |
self.assertIsInstance(ie.revision, bytes) |
|
2294.1.7
by John Arbash Meinel
Add tests for parent ids in test_test_trees |
334 |
if expected[0] != '': |
|
2294.1.3
by John Arbash Meinel
Make sure the inventory enrtries returned are properly formed. |
335 |
# Some trees will preserve the revision id of the tree root,
|
336 |
# but not all will
|
|
|
2294.1.7
by John Arbash Meinel
Add tests for parent ids in test_test_trees |
337 |
self.assertEqual(revision_id, ie.revision) |
|
2294.1.3
by John Arbash Meinel
Make sure the inventory enrtries returned are properly formed. |
338 |
self.assertEqual(len(path_and_ids), len(path_entries)) |
339 |
get_revision_id = getattr(tree, 'get_revision_id', None) |
|
340 |
if get_revision_id is not None: |
|
|
7045.4.34
by Jelmer Vernooij
Fix some more tests. |
341 |
self.assertIsInstance(get_revision_id(), bytes) |
|
2294.1.3
by John Arbash Meinel
Make sure the inventory enrtries returned are properly formed. |
342 |
last_revision = getattr(tree, 'last_revision', None) |
343 |
if last_revision is not None: |
|
|
7045.4.34
by Jelmer Vernooij
Fix some more tests. |
344 |
self.assertIsInstance(last_revision(), bytes) |
|
2294.1.3
by John Arbash Meinel
Make sure the inventory enrtries returned are properly formed. |
345 |
|
|
2294.1.2
by John Arbash Meinel
Track down and add tests that all tree.commit() can handle |
346 |
def test_tree_with_merged_utf8(self): |
|
6913.1.1
by Jelmer Vernooij
Move utf-8 specific code closer to where it's run, and make foreign branch compatible. |
347 |
wt = self.make_branch_and_tree('.') |
348 |
||
349 |
self._create_tree_with_utf8(wt) |
|
350 |
||
351 |
tree2 = wt.controldir.sprout('tree2').open_workingtree() |
|
352 |
self.build_tree([u'tree2/ba\N{Euro Sign}r/qu\N{Euro Sign}x']) |
|
353 |
if wt.supports_setting_file_ids(): |
|
354 |
tree2.add([u'ba\N{Euro Sign}r/qu\N{Euro Sign}x'], |
|
355 |
[u'qu\N{Euro Sign}x-id'.encode('utf-8')]) |
|
356 |
else: |
|
357 |
tree2.add([u'ba\N{Euro Sign}r/qu\N{Euro Sign}x']) |
|
358 |
if wt.branch.repository._format.supports_setting_revision_ids: |
|
359 |
tree2.commit(u'to m\xe9rge', rev_id=u'r\xe9v-2'.encode('utf8')) |
|
360 |
else: |
|
361 |
tree2.commit(u'to m\xe9rge') |
|
362 |
||
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
363 |
self.assertTrue(tree2.is_versioned( |
364 |
u'ba\N{Euro Sign}r/qu\N{Euro Sign}x')) |
|
|
6913.1.1
by Jelmer Vernooij
Move utf-8 specific code closer to where it's run, and make foreign branch compatible. |
365 |
wt.merge_from_branch(tree2.branch) |
366 |
self.assertTrue(wt.is_versioned(u'ba\N{Euro Sign}r/qu\N{Euro Sign}x')) |
|
367 |
||
368 |
if wt.branch.repository._format.supports_setting_revision_ids: |
|
369 |
wt.commit(u'm\xe9rge', rev_id=u'r\xe9v-3'.encode('utf8')) |
|
370 |
else: |
|
371 |
wt.commit(u'm\xe9rge') |
|
372 |
tree = self.workingtree_to_test_tree(wt) |
|
|
2294.1.3
by John Arbash Meinel
Make sure the inventory enrtries returned are properly formed. |
373 |
|
374 |
revision_id_1 = u'r\xe9v-1'.encode('utf8') |
|
375 |
revision_id_2 = u'r\xe9v-2'.encode('utf8') |
|
|
6973.13.2
by Jelmer Vernooij
Fix some more tests. |
376 |
root_id = b'TREE_ROOT' |
|
3638.3.11
by Vincent Ladeuil
Fix failing tests by avoiding unicode combinig encodings (we test |
377 |
bar_id = u'ba\N{Euro Sign}r-id'.encode('utf8') |
378 |
foo_id = u'fo\N{Euro Sign}o-id'.encode('utf8') |
|
379 |
baz_id = u'ba\N{Euro Sign}z-id'.encode('utf8') |
|
380 |
qux_id = u'qu\N{Euro Sign}x-id'.encode('utf8') |
|
|
2294.1.10
by John Arbash Meinel
Switch all apis over to utf8 file ids. All tests pass |
381 |
path_and_ids = [(u'', root_id, None, None), |
|
3638.3.11
by Vincent Ladeuil
Fix failing tests by avoiding unicode combinig encodings (we test |
382 |
(u'ba\N{Euro Sign}r', bar_id, root_id, revision_id_1), |
383 |
(u'fo\N{Euro Sign}o', foo_id, root_id, revision_id_1), |
|
384 |
(u'ba\N{Euro Sign}r/ba\N{Euro Sign}z', |
|
385 |
baz_id, bar_id, revision_id_1), |
|
386 |
(u'ba\N{Euro Sign}r/qu\N{Euro Sign}x', |
|
387 |
qux_id, bar_id, revision_id_2), |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
388 |
]
|
|
6885.6.1
by Jelmer Vernooij
Support specific_files argument to Tree.iter_entries_by_dir. |
389 |
with tree.lock_read(): |
|
2294.1.3
by John Arbash Meinel
Make sure the inventory enrtries returned are properly formed. |
390 |
path_entries = list(tree.iter_entries_by_dir()) |
391 |
||
|
3638.3.11
by Vincent Ladeuil
Fix failing tests by avoiding unicode combinig encodings (we test |
392 |
for (epath, efid, eparent, erev), (path, ie) in zip(path_and_ids, |
393 |
path_entries): |
|
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
394 |
self.assertEqual(epath, path) # Paths should match |
|
7479.2.1
by Jelmer Vernooij
Drop python2 support. |
395 |
self.assertIsInstance(path, str) |
|
6913.1.1
by Jelmer Vernooij
Move utf-8 specific code closer to where it's run, and make foreign branch compatible. |
396 |
self.assertIsInstance(ie.file_id, bytes) |
397 |
if wt.supports_setting_file_ids(): |
|
398 |
self.assertEqual(efid, ie.file_id) |
|
399 |
self.assertEqual(eparent, ie.parent_id) |
|
|
3638.3.11
by Vincent Ladeuil
Fix failing tests by avoiding unicode combinig encodings (we test |
400 |
if eparent is not None: |
|
6913.1.1
by Jelmer Vernooij
Move utf-8 specific code closer to where it's run, and make foreign branch compatible. |
401 |
self.assertIsInstance(ie.parent_id, bytes) |
402 |
self.assertEqual(len(path_and_ids), len(path_entries), |
|
403 |
"%r vs %r" % ( |
|
404 |
[p for (p, f, pf, r) in path_and_ids], |
|
405 |
[p for (p, e) in path_entries])) |
|
|
2294.1.3
by John Arbash Meinel
Make sure the inventory enrtries returned are properly formed. |
406 |
get_revision_id = getattr(tree, 'get_revision_id', None) |
407 |
if get_revision_id is not None: |
|
|
6913.1.1
by Jelmer Vernooij
Move utf-8 specific code closer to where it's run, and make foreign branch compatible. |
408 |
self.assertIsInstance(get_revision_id(), bytes) |
|
2294.1.3
by John Arbash Meinel
Make sure the inventory enrtries returned are properly formed. |
409 |
last_revision = getattr(tree, 'last_revision', None) |
410 |
if last_revision is not None: |
|
|
6913.1.1
by Jelmer Vernooij
Move utf-8 specific code closer to where it's run, and make foreign branch compatible. |
411 |
self.assertIsInstance(last_revision(), bytes) |
|
7404.3.1
by Jelmer Vernooij
Add follow_tree_references argument to Tree.iter_entries_by_dir. |
412 |
|
413 |
def skip_if_no_reference(self, tree): |
|
414 |
if not getattr(tree, 'supports_tree_reference', lambda: False)(): |
|
415 |
raise TestNotApplicable('Tree references not supported') |
|
416 |
||
417 |
def create_nested(self): |
|
418 |
work_tree = self.make_branch_and_tree('wt') |
|
419 |
with work_tree.lock_write(): |
|
420 |
self.skip_if_no_reference(work_tree) |
|
421 |
subtree = self.make_branch_and_tree('wt/subtree') |
|
422 |
self.build_tree(['wt/subtree/a']) |
|
423 |
subtree.add(['a']) |
|
424 |
subtree.commit('foo') |
|
425 |
work_tree.add_reference(subtree) |
|
426 |
tree = self._convert_tree(work_tree) |
|
427 |
self.skip_if_no_reference(tree) |
|
428 |
return tree, subtree |
|
429 |
||
430 |
def test_iter_entries_with_unfollowed_reference(self): |
|
431 |
tree, subtree = self.create_nested() |
|
432 |
expected = [ |
|
433 |
('', 'directory'), |
|
434 |
('subtree', 'tree-reference')] |
|
435 |
with tree.lock_read(): |
|
|
7404.3.2
by Jelmer Vernooij
Merge rename of flag to recurse_nested. |
436 |
path_entries = list(tree.iter_entries_by_dir(recurse_nested=False)) |
|
7404.3.1
by Jelmer Vernooij
Add follow_tree_references argument to Tree.iter_entries_by_dir. |
437 |
actual = [(path, ie.kind) |
438 |
for path, ie in path_entries] |
|
439 |
self.assertEqual(expected, actual) |
|
440 |
||
441 |
def test_iter_entries_with_followed_reference(self): |
|
442 |
tree, subtree = self.create_nested() |
|
443 |
expected = [ |
|
444 |
('', 'directory'), |
|
445 |
('subtree', 'directory'), |
|
446 |
('subtree/a', 'file')] |
|
447 |
with tree.lock_read(): |
|
|
7404.3.2
by Jelmer Vernooij
Merge rename of flag to recurse_nested. |
448 |
path_entries = list(tree.iter_entries_by_dir(recurse_nested=True)) |
|
7404.3.1
by Jelmer Vernooij
Add follow_tree_references argument to Tree.iter_entries_by_dir. |
449 |
actual = [(path, ie.kind) |
450 |
for path, ie in path_entries] |
|
451 |
self.assertEqual(expected, actual) |