bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
1 |
# Copyright (C) 2006-2009, 2011, 2012, 2016 Canonical Ltd
|
|
1551.9.21
by Aaron Bentley
Fix copyright statements |
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
|
|
1551.9.21
by Aaron Bentley
Fix copyright statements |
16 |
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
17 |
from breezy import ( |
|
2255.11.5
by Martin Pool
Tree.id2path should raise NoSuchId, not return None. |
18 |
errors, |
|
3363.13.1
by Aaron Bentley
Implement PreviewTree.extras |
19 |
conflicts, |
|
3363.15.4
by Aaron Bentley
Implement PreviewTree.get_file_sha1 properly |
20 |
osutils, |
|
3363.13.1
by Aaron Bentley
Implement PreviewTree.extras |
21 |
revisiontree, |
|
2255.2.180
by Martin Pool
merge dirstate |
22 |
tests, |
|
6670.4.3
by Jelmer Vernooij
Fix more imports. |
23 |
)
|
|
7358.4.1
by Jelmer Vernooij
Add Tree.get_nested_tree. |
24 |
from breezy.tree import MissingNestedTree |
|
6670.4.3
by Jelmer Vernooij
Fix more imports. |
25 |
from breezy.bzr import ( |
|
3363.13.1
by Aaron Bentley
Implement PreviewTree.extras |
26 |
workingtree_4, |
|
2255.11.5
by Martin Pool
Tree.id2path should raise NoSuchId, not return None. |
27 |
)
|
|
6622.1.34
by Jelmer Vernooij
Rename brzlib => breezy. |
28 |
from breezy.tests import TestSkipped |
29 |
from breezy.tests.per_tree import TestCaseWithTree |
|
|
5967.7.1
by Martin Pool
Deprecate __contains__ on Tree and Inventory |
30 |
|
|
1551.9.16
by Aaron Bentley
Implement Tree.annotate_iter for RevisionTree and WorkingTree |
31 |
|
32 |
class TestAnnotate(TestCaseWithTree): |
|
|
2255.2.69
by John Arbash Meinel
Implement annotate_iter, get_revision_id, and walkdirs so that all tree_implementations now pass |
33 |
|
|
1551.9.16
by Aaron Bentley
Implement Tree.annotate_iter for RevisionTree and WorkingTree |
34 |
def test_annotate(self): |
35 |
work_tree = self.make_branch_and_tree('wt') |
|
36 |
tree = self.get_tree_no_parents_abc_content(work_tree) |
|
|
7018.3.2
by Jelmer Vernooij
Fix some git tests. |
37 |
tree_revision = getattr(tree, 'get_revision_id', lambda: b'current:')() |
|
2255.2.69
by John Arbash Meinel
Implement annotate_iter, get_revision_id, and walkdirs so that all tree_implementations now pass |
38 |
tree.lock_read() |
|
1551.15.48
by Aaron Bentley
Add tests for annotate and plan_merge |
39 |
self.addCleanup(tree.unlock) |
|
6809.4.2
by Jelmer Vernooij
Swap arguments for annotate_iter. |
40 |
for revision, line in tree.annotate_iter('a'): |
|
7018.3.2
by Jelmer Vernooij
Fix some git tests. |
41 |
self.assertEqual(b'contents of a\n', line) |
|
1551.15.48
by Aaron Bentley
Add tests for annotate and plan_merge |
42 |
self.assertEqual(tree_revision, revision) |
|
7018.3.2
by Jelmer Vernooij
Fix some git tests. |
43 |
tree_revision = getattr(tree, 'get_revision_id', lambda: b'random:')() |
44 |
for revision, line in tree.annotate_iter('a', default_revision=b'random:'): |
|
45 |
self.assertEqual(b'contents of a\n', line) |
|
|
1551.15.48
by Aaron Bentley
Add tests for annotate and plan_merge |
46 |
self.assertEqual(tree_revision, revision) |
47 |
||
48 |
||
|
1551.15.52
by Aaron Bentley
Tweak from review comments |
49 |
class TestPlanFileMerge(TestCaseWithTree): |
|
1551.15.48
by Aaron Bentley
Add tests for annotate and plan_merge |
50 |
|
|
1551.15.52
by Aaron Bentley
Tweak from review comments |
51 |
def test_plan_file_merge(self): |
|
1551.15.48
by Aaron Bentley
Add tests for annotate and plan_merge |
52 |
work_a = self.make_branch_and_tree('wta') |
|
6855.3.1
by Jelmer Vernooij
Several more fixes. |
53 |
self.build_tree_contents([('wta/file', b'a\nb\nc\nd\n')]) |
|
6745.1.1
by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking |
54 |
work_a.add('file') |
|
1551.15.48
by Aaron Bentley
Add tests for annotate and plan_merge |
55 |
work_a.commit('base version') |
|
6653.6.1
by Jelmer Vernooij
Rename a number of attributes from bzrdir to controldir. |
56 |
work_b = work_a.controldir.sprout('wtb').open_workingtree() |
|
6855.3.1
by Jelmer Vernooij
Several more fixes. |
57 |
self.build_tree_contents([('wta/file', b'b\nc\nd\ne\n')]) |
|
1551.15.48
by Aaron Bentley
Add tests for annotate and plan_merge |
58 |
tree_a = self.workingtree_to_test_tree(work_a) |
|
6861.2.3
by Jelmer Vernooij
Mark which merge types require plan_file_merge. |
59 |
if getattr(tree_a, 'plan_file_merge', None) is None: |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
60 |
raise tests.TestNotApplicable( |
61 |
'Tree does not support plan_file_merge') |
|
|
1551.15.48
by Aaron Bentley
Add tests for annotate and plan_merge |
62 |
tree_a.lock_read() |
63 |
self.addCleanup(tree_a.unlock) |
|
|
6855.3.1
by Jelmer Vernooij
Several more fixes. |
64 |
self.build_tree_contents([('wtb/file', b'a\nc\nd\nf\n')]) |
|
1551.15.48
by Aaron Bentley
Add tests for annotate and plan_merge |
65 |
tree_b = self.workingtree_to_test_tree(work_b) |
66 |
tree_b.lock_read() |
|
67 |
self.addCleanup(tree_b.unlock) |
|
68 |
self.assertEqual([ |
|
|
6973.11.7
by Jelmer Vernooij
Fix more tests. |
69 |
('killed-a', b'a\n'), |
70 |
('killed-b', b'b\n'), |
|
71 |
('unchanged', b'c\n'), |
|
72 |
('unchanged', b'd\n'), |
|
73 |
('new-a', b'e\n'), |
|
74 |
('new-b', b'f\n'), |
|
|
7350.6.4
by Jelmer Vernooij
Drop file_id attribute from MergeHookParams and Tree.plan_file_merge. |
75 |
], list(tree_a.plan_file_merge('file', tree_b))) |
|
2100.3.20
by Aaron Bentley
Implement tree comparison for tree references |
76 |
|
77 |
||
78 |
class TestReference(TestCaseWithTree): |
|
79 |
||
80 |
def skip_if_no_reference(self, tree): |
|
|
7447.2.1
by Jelmer Vernooij
Rely on supports_tree_reference existing. |
81 |
if not tree.supports_tree_reference(): |
|
3504.2.1
by John Arbash Meinel
Shortcut iter_references when we know references aren't supported. |
82 |
raise tests.TestNotApplicable('Tree references not supported') |
|
2100.3.20
by Aaron Bentley
Implement tree comparison for tree references |
83 |
|
|
2100.3.27
by Aaron Bentley
Enable nested commits |
84 |
def create_nested(self): |
|
2100.3.20
by Aaron Bentley
Implement tree comparison for tree references |
85 |
work_tree = self.make_branch_and_tree('wt') |
|
7358.4.1
by Jelmer Vernooij
Add Tree.get_nested_tree. |
86 |
with work_tree.lock_write(): |
|
2255.2.158
by Martin Pool
Most of the integration of dirstate and subtree |
87 |
self.skip_if_no_reference(work_tree) |
88 |
subtree = self.make_branch_and_tree('wt/subtree') |
|
|
6926.2.1
by Jelmer Vernooij
Some tree reference fixes. |
89 |
subtree.commit('foo') |
|
2255.2.158
by Martin Pool
Most of the integration of dirstate and subtree |
90 |
work_tree.add_reference(subtree) |
|
2100.3.20
by Aaron Bentley
Implement tree comparison for tree references |
91 |
tree = self._convert_tree(work_tree) |
92 |
self.skip_if_no_reference(tree) |
|
|
6926.2.1
by Jelmer Vernooij
Some tree reference fixes. |
93 |
return tree, subtree |
|
2100.3.27
by Aaron Bentley
Enable nested commits |
94 |
|
95 |
def test_get_reference_revision(self): |
|
|
6926.2.1
by Jelmer Vernooij
Some tree reference fixes. |
96 |
tree, subtree = self.create_nested() |
|
3504.2.1
by John Arbash Meinel
Shortcut iter_references when we know references aren't supported. |
97 |
tree.lock_read() |
98 |
self.addCleanup(tree.unlock) |
|
|
6926.2.1
by Jelmer Vernooij
Some tree reference fixes. |
99 |
self.assertEqual( |
100 |
subtree.last_revision(), |
|
101 |
tree.get_reference_revision('subtree')) |
|
|
2100.3.27
by Aaron Bentley
Enable nested commits |
102 |
|
|
2255.2.226
by Robert Collins
Get merge_nested finally working: change nested tree iterators to take file_ids, and ensure the right branch is connected to in the merge logic. May not be suitable for shared repositories yet. |
103 |
def test_iter_references(self): |
|
6926.2.1
by Jelmer Vernooij
Some tree reference fixes. |
104 |
tree, subtree = self.create_nested() |
|
2255.2.158
by Martin Pool
Most of the integration of dirstate and subtree |
105 |
tree.lock_read() |
|
2255.2.226
by Robert Collins
Get merge_nested finally working: change nested tree iterators to take file_ids, and ensure the right branch is connected to in the merge logic. May not be suitable for shared repositories yet. |
106 |
self.addCleanup(tree.unlock) |
|
6926.2.2
by Jelmer Vernooij
More fixes. |
107 |
self.assertEqual( |
|
7350.2.1
by Jelmer Vernooij
Drop file_id return value from Tree.iter_references. |
108 |
[u'subtree'], |
|
2255.2.226
by Robert Collins
Get merge_nested finally working: change nested tree iterators to take file_ids, and ensure the right branch is connected to in the merge logic. May not be suitable for shared repositories yet. |
109 |
list(tree.iter_references())) |
|
2255.2.166
by Martin Pool
(broken) Add Tree.get_root_id() & test |
110 |
|
|
7358.4.1
by Jelmer Vernooij
Add Tree.get_nested_tree. |
111 |
def test_get_nested_tree(self): |
112 |
tree, subtree = self.create_nested() |
|
113 |
try: |
|
114 |
changes = subtree.changes_from(tree.get_nested_tree('subtree')) |
|
115 |
self.assertFalse(changes.has_changed()) |
|
116 |
except MissingNestedTree: |
|
117 |
# Also okay.
|
|
118 |
pass
|
|
119 |
||
|
2255.2.166
by Martin Pool
(broken) Add Tree.get_root_id() & test |
120 |
def test_get_root_id(self): |
121 |
# trees should return some kind of root id; it can be none
|
|
122 |
tree = self.make_branch_and_tree('tree') |
|
|
7358.14.1
by Jelmer Vernooij
Remove Tree.get_root_id() in favour of Tree.path2id(''). |
123 |
root_id = tree.path2id('') |
|
2255.2.166
by Martin Pool
(broken) Add Tree.get_root_id() & test |
124 |
if root_id is not None: |
|
6973.11.7
by Jelmer Vernooij
Fix more tests. |
125 |
self.assertIsInstance(root_id, bytes) |
|
2255.2.180
by Martin Pool
merge dirstate |
126 |
|
|
6852.3.1
by Jelmer Vernooij
add Tree.is_versioned. |
127 |
def test_is_versioned(self): |
|
6856
by Jelmer Vernooij
Merge lp:~jelmer/brz/is-versioned. |
128 |
tree = self.make_branch_and_tree('tree') |
|
6852.3.1
by Jelmer Vernooij
add Tree.is_versioned. |
129 |
self.assertTrue(tree.is_versioned('')) |
130 |
self.assertFalse(tree.is_versioned('blah')) |
|
|
6861.1.1
by Jelmer Vernooij
More foreign branch test fixes. |
131 |
self.build_tree(['tree/dir/', 'tree/dir/file']) |
132 |
self.assertFalse(tree.is_versioned('dir')) |
|
133 |
self.assertFalse(tree.is_versioned('dir/')) |
|
134 |
tree.add(['dir', 'dir/file']) |
|
135 |
self.assertTrue(tree.is_versioned('dir')) |
|
136 |
self.assertTrue(tree.is_versioned('dir/')) |
|
|
6852.3.1
by Jelmer Vernooij
add Tree.is_versioned. |
137 |
|
|
2255.2.180
by Martin Pool
merge dirstate |
138 |
|
|
2255.11.5
by Martin Pool
Tree.id2path should raise NoSuchId, not return None. |
139 |
class TestFileIds(TestCaseWithTree): |
140 |
||
141 |
def test_id2path(self): |
|
142 |
# translate from file-id back to path
|
|
143 |
work_tree = self.make_branch_and_tree('wt') |
|
|
7391.3.1
by Jelmer Vernooij
Use id2path in fewer places. |
144 |
if not work_tree.supports_setting_file_ids(): |
145 |
self.skipTest("working tree does not support setting file ids") |
|
|
2255.11.5
by Martin Pool
Tree.id2path should raise NoSuchId, not return None. |
146 |
tree = self.get_tree_no_parents_abc_content(work_tree) |
|
6793.5.1
by Jelmer Vernooij
Hardcode fileids in fewer places. |
147 |
a_id = tree.path2id('a') |
|
6852.3.1
by Jelmer Vernooij
add Tree.is_versioned. |
148 |
with tree.lock_read(): |
|
6793.5.1
by Jelmer Vernooij
Hardcode fileids in fewer places. |
149 |
self.assertEqual(u'a', tree.id2path(a_id)) |
|
2255.11.5
by Martin Pool
Tree.id2path should raise NoSuchId, not return None. |
150 |
# other ids give an error- don't return None for this case
|
|
7045.4.1
by Jelmer Vernooij
Some brz-git fixes. |
151 |
self.assertRaises(errors.NoSuchId, tree.id2path, b'a') |
|
2708.1.1
by Aaron Bentley
Implement Tree.extract_files |
152 |
|
|
3146.8.16
by Aaron Bentley
Updates from review |
153 |
def test_all_file_ids(self): |
|
3146.8.2
by Aaron Bentley
Introduce iter_all_file_ids, to avoid hitting Inventory for this case |
154 |
work_tree = self.make_branch_and_tree('wt') |
155 |
tree = self.get_tree_no_parents_abc_content(work_tree) |
|
156 |
tree.lock_read() |
|
157 |
self.addCleanup(tree.unlock) |
|
|
7170.3.1
by Jelmer Vernooij
Make Tree.all_file_ids optional. |
158 |
try: |
159 |
self.assertEqual(tree.all_file_ids(), |
|
160 |
{tree.path2id('a'), tree.path2id(''), |
|
161 |
tree.path2id('b'), tree.path2id('b/c')}) |
|
162 |
except errors.UnsupportedOperation: |
|
163 |
raise tests.TestNotApplicable( |
|
164 |
'Tree does not support all_file_ids') |
|
|
3146.8.2
by Aaron Bentley
Introduce iter_all_file_ids, to avoid hitting Inventory for this case |
165 |
|
|
2708.1.1
by Aaron Bentley
Implement Tree.extract_files |
166 |
|
|
3146.8.4
by Aaron Bentley
Eliminate direct use of inventory from transform application |
167 |
class TestStoredKind(TestCaseWithTree): |
168 |
||
169 |
def test_stored_kind(self): |
|
170 |
tree = self.make_branch_and_tree('tree') |
|
171 |
work_tree = self.make_branch_and_tree('wt') |
|
172 |
tree = self.get_tree_no_parents_abc_content(work_tree) |
|
173 |
tree.lock_read() |
|
174 |
self.addCleanup(tree.unlock) |
|
|
6809.4.7
by Jelmer Vernooij
Swap arguments for get_symlink_target and kind/stored_kind. |
175 |
self.assertEqual('file', tree.stored_kind('a')) |
176 |
self.assertEqual('directory', tree.stored_kind('b')) |
|
|
3146.8.4
by Aaron Bentley
Eliminate direct use of inventory from transform application |
177 |
|
178 |
||
|
2743.3.5
by Ian Clatworthy
Incorporate feedback from abentley |
179 |
class TestFileContent(TestCaseWithTree): |
180 |
||
181 |
def test_get_file(self): |
|
182 |
work_tree = self.make_branch_and_tree('wt') |
|
183 |
tree = self.get_tree_no_parents_abc_content_2(work_tree) |
|
|
6793.5.1
by Jelmer Vernooij
Hardcode fileids in fewer places. |
184 |
a_id = tree.path2id('a') |
|
2743.3.5
by Ian Clatworthy
Incorporate feedback from abentley |
185 |
tree.lock_read() |
|
6437.20.6
by Martin Packman
Poke test_get_file in bt.per_tree.test_tree to be more careful about cleanup |
186 |
self.addCleanup(tree.unlock) |
187 |
# Test lookup without path works
|
|
|
6809.4.5
by Jelmer Vernooij
Swap arguments for get_file_*. |
188 |
file_without_path = tree.get_file('a') |
|
2743.3.5
by Ian Clatworthy
Incorporate feedback from abentley |
189 |
try: |
|
6437.20.2
by Wouter van Heyst
close files returned by transport.get |
190 |
lines = file_without_path.readlines() |
|
6973.6.1
by Jelmer Vernooij
More bees. |
191 |
self.assertEqual([b'foobar\n'], lines) |
|
6437.20.6
by Martin Packman
Poke test_get_file in bt.per_tree.test_tree to be more careful about cleanup |
192 |
finally: |
193 |
file_without_path.close() |
|
|
2743.3.5
by Ian Clatworthy
Incorporate feedback from abentley |
194 |
|
|
6977.2.1
by Jelmer Vernooij
Require that get_file implementations are contect managers, simplify file handling in transform. |
195 |
def test_get_file_context_manager(self): |
196 |
work_tree = self.make_branch_and_tree('wt') |
|
197 |
tree = self.get_tree_no_parents_abc_content_2(work_tree) |
|
198 |
a_id = tree.path2id('a') |
|
199 |
tree.lock_read() |
|
200 |
self.addCleanup(tree.unlock) |
|
201 |
with tree.get_file('a') as f: |
|
|
6973.6.1
by Jelmer Vernooij
More bees. |
202 |
self.assertEqual(b'foobar\n', f.read()) |
|
6977.2.1
by Jelmer Vernooij
Require that get_file implementations are contect managers, simplify file handling in transform. |
203 |
|
|
3774.1.1
by Aaron Bentley
Test Tree.get_file_text() and supply default implementation. |
204 |
def test_get_file_text(self): |
205 |
work_tree = self.make_branch_and_tree('wt') |
|
206 |
tree = self.get_tree_no_parents_abc_content_2(work_tree) |
|
|
6793.5.1
by Jelmer Vernooij
Hardcode fileids in fewer places. |
207 |
a_id = tree.path2id('a') |
|
3774.1.1
by Aaron Bentley
Test Tree.get_file_text() and supply default implementation. |
208 |
tree.lock_read() |
209 |
self.addCleanup(tree.unlock) |
|
210 |
# test read by path
|
|
|
6973.7.3
by Jelmer Vernooij
Fix some more tests. |
211 |
self.assertEqual(b'foobar\n', tree.get_file_text('a')) |
|
3774.1.1
by Aaron Bentley
Test Tree.get_file_text() and supply default implementation. |
212 |
|
|
3774.1.2
by Aaron Bentley
Test Tree.get_file_lines, provide a default implementation |
213 |
def test_get_file_lines(self): |
214 |
work_tree = self.make_branch_and_tree('wt') |
|
215 |
tree = self.get_tree_no_parents_abc_content_2(work_tree) |
|
|
6793.5.1
by Jelmer Vernooij
Hardcode fileids in fewer places. |
216 |
a_id = tree.path2id('a') |
|
3774.1.2
by Aaron Bentley
Test Tree.get_file_lines, provide a default implementation |
217 |
tree.lock_read() |
218 |
self.addCleanup(tree.unlock) |
|
219 |
# test read by path
|
|
|
6973.7.3
by Jelmer Vernooij
Fix some more tests. |
220 |
self.assertEqual([b'foobar\n'], tree.get_file_lines('a')) |
|
2743.3.5
by Ian Clatworthy
Incorporate feedback from abentley |
221 |
|
|
3774.1.4
by Aaron Bentley
Use file.readlines on working trees. |
222 |
def test_get_file_lines_multi_line_breaks(self): |
223 |
work_tree = self.make_branch_and_tree('wt') |
|
|
6855.3.1
by Jelmer Vernooij
Several more fixes. |
224 |
self.build_tree_contents([('wt/foobar', b'a\rb\nc\r\nd')]) |
|
6745.1.1
by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking |
225 |
work_tree.add('foobar') |
|
3774.1.4
by Aaron Bentley
Use file.readlines on working trees. |
226 |
tree = self._convert_tree(work_tree) |
227 |
tree.lock_read() |
|
228 |
self.addCleanup(tree.unlock) |
|
|
6973.6.1
by Jelmer Vernooij
More bees. |
229 |
self.assertEqual([b'a\rb\n', b'c\r\n', b'd'], |
|
6809.4.5
by Jelmer Vernooij
Swap arguments for get_file_*. |
230 |
tree.get_file_lines('foobar')) |
|
3774.1.4
by Aaron Bentley
Use file.readlines on working trees. |
231 |
|
232 |
||
|
2708.1.1
by Aaron Bentley
Implement Tree.extract_files |
233 |
class TestExtractFilesBytes(TestCaseWithTree): |
234 |
||
|
2708.1.7
by Aaron Bentley
Rename extract_files_bytes to iter_files_bytes |
235 |
def test_iter_files_bytes(self): |
|
2708.1.1
by Aaron Bentley
Implement Tree.extract_files |
236 |
work_tree = self.make_branch_and_tree('wt') |
|
6855.3.1
by Jelmer Vernooij
Several more fixes. |
237 |
self.build_tree_contents([('wt/foo', b'foo'), |
238 |
('wt/bar', b'bar'), |
|
239 |
('wt/baz', b'baz')]) |
|
|
6745.1.1
by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking |
240 |
work_tree.add(['foo', 'bar', 'baz']) |
|
2708.1.1
by Aaron Bentley
Implement Tree.extract_files |
241 |
tree = self._convert_tree(work_tree) |
242 |
tree.lock_read() |
|
243 |
self.addCleanup(tree.unlock) |
|
|
6973.6.1
by Jelmer Vernooij
More bees. |
244 |
extracted = dict((i, b''.join(b)) for i, b in |
|
6874.2.1
by Jelmer Vernooij
Make Tree.iter_files_bytes() take paths rather than file_ids. |
245 |
tree.iter_files_bytes([('foo', 'id1'), |
246 |
('bar', 'id2'), |
|
247 |
('baz', 'id3')])) |
|
|
6973.6.1
by Jelmer Vernooij
More bees. |
248 |
self.assertEqual(b'foo', extracted['id1']) |
249 |
self.assertEqual(b'bar', extracted['id2']) |
|
250 |
self.assertEqual(b'baz', extracted['id3']) |
|
|
6874.2.1
by Jelmer Vernooij
Make Tree.iter_files_bytes() take paths rather than file_ids. |
251 |
self.assertRaises(errors.NoSuchFile, lambda: list( |
|
2708.1.11
by Aaron Bentley
Test and tweak error handling |
252 |
tree.iter_files_bytes( |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
253 |
[('qux', 'file1-notpresent')]))) |
|
2748.2.2
by Lukáš Lalinsky
Add TestConflicts to tests.tree_implementations.test_tree. Update NEWS. |
254 |
|
255 |
||
256 |
class TestConflicts(TestCaseWithTree): |
|
257 |
||
258 |
def test_conflicts(self): |
|
259 |
"""Tree.conflicts() should return a ConflictList instance.""" |
|
260 |
work_tree = self.make_branch_and_tree('wt') |
|
261 |
tree = self._convert_tree(work_tree) |
|
|
2761.1.3
by Aaron Bentley
Update test to use assertIsInstance |
262 |
self.assertIsInstance(tree.conflicts(), conflicts.ConflictList) |
|
3363.5.4
by Aaron Bentley
Fix iteration order of iter_entries_by_dir |
263 |
|
264 |
||
265 |
class TestIterEntriesByDir(TestCaseWithTree): |
|
266 |
||
267 |
def test_iteration_order(self): |
|
268 |
work_tree = self.make_branch_and_tree('.') |
|
269 |
self.build_tree(['a/', 'a/b/', 'a/b/c', 'a/d/', 'a/d/e', 'f/', 'f/g']) |
|
270 |
work_tree.add(['a', 'a/b', 'a/b/c', 'a/d', 'a/d/e', 'f', 'f/g']) |
|
271 |
tree = self._convert_tree(work_tree) |
|
272 |
output_order = [p for p, e in tree.iter_entries_by_dir()] |
|
273 |
self.assertEqual(['', 'a', 'f', 'a/b', 'a/d', 'a/b/c', 'a/d/e', 'f/g'], |
|
274 |
output_order) |
|
|
3363.13.1
by Aaron Bentley
Implement PreviewTree.extras |
275 |
|
276 |
||
|
6471.1.3
by Jelmer Vernooij
Add Tree.iter_child_entries. |
277 |
class TestIterChildEntries(TestCaseWithTree): |
278 |
||
279 |
def test_iteration_order(self): |
|
280 |
work_tree = self.make_branch_and_tree('.') |
|
281 |
self.build_tree(['a/', 'a/b/', 'a/b/c', 'a/d/', 'a/d/e', 'f/', 'f/g']) |
|
282 |
work_tree.add(['a', 'a/b', 'a/b/c', 'a/d', 'a/d/e', 'f', 'f/g']) |
|
283 |
tree = self._convert_tree(work_tree) |
|
|
7141.7.1
by Jelmer Vernooij
Get rid of file_ids in most of Tree. |
284 |
output = [e.name for e in tree.iter_child_entries('')] |
|
6619.3.12
by Jelmer Vernooij
Use 2to3 set_literal fixer. |
285 |
self.assertEqual({'a', 'f'}, set(output)) |
|
7141.7.1
by Jelmer Vernooij
Get rid of file_ids in most of Tree. |
286 |
output = [e.name for e in tree.iter_child_entries('a')] |
|
6619.3.12
by Jelmer Vernooij
Use 2to3 set_literal fixer. |
287 |
self.assertEqual({'b', 'd'}, set(output)) |
|
6471.1.3
by Jelmer Vernooij
Add Tree.iter_child_entries. |
288 |
|
289 |
def test_does_not_exist(self): |
|
290 |
work_tree = self.make_branch_and_tree('.') |
|
291 |
self.build_tree(['a/']) |
|
292 |
work_tree.add(['a']) |
|
293 |
tree = self._convert_tree(work_tree) |
|
|
6844.1.1
by Jelmer Vernooij
Many more foreign branch fixes. |
294 |
self.assertRaises(errors.NoSuchFile, lambda: |
|
7143.15.2
by Jelmer Vernooij
Run autopep8. |
295 |
list(tree.iter_child_entries('unknown'))) |
|
6471.1.3
by Jelmer Vernooij
Add Tree.iter_child_entries. |
296 |
|
297 |
||
|
3363.13.1
by Aaron Bentley
Implement PreviewTree.extras |
298 |
class TestExtras(TestCaseWithTree): |
299 |
||
300 |
def test_extras(self): |
|
301 |
work_tree = self.make_branch_and_tree('tree') |
|
|
3363.13.4
by Aaron Bentley
Ensure versioned files are not listed by extras |
302 |
self.build_tree(['tree/file', 'tree/versioned-file']) |
303 |
work_tree.add(['file', 'versioned-file']) |
|
304 |
work_tree.commit('add files') |
|
|
3363.13.1
by Aaron Bentley
Implement PreviewTree.extras |
305 |
work_tree.remove('file') |
306 |
tree = self._convert_tree(work_tree) |
|
307 |
if isinstance(tree, |
|
308 |
(revisiontree.RevisionTree, |
|
309 |
workingtree_4.DirStateRevisionTree)): |
|
310 |
expected = [] |
|
311 |
else: |
|
312 |
expected = ['file'] |
|
313 |
tree.lock_read() |
|
314 |
self.addCleanup(tree.unlock) |
|
315 |
self.assertEqual(expected, list(tree.extras())) |
|
|
3363.15.1
by Aaron Bentley
Add test for has_id |
316 |
|
|
3363.17.3
by Aaron Bentley
Merge with has_id |
317 |
|
|
3363.15.4
by Aaron Bentley
Implement PreviewTree.get_file_sha1 properly |
318 |
class TestGetFileSha1(TestCaseWithTree): |
319 |
||
320 |
def test_get_file_sha1(self): |
|
321 |
work_tree = self.make_branch_and_tree('tree') |
|
|
6855.3.1
by Jelmer Vernooij
Several more fixes. |
322 |
self.build_tree_contents([('tree/file', b'file content')]) |
|
6745.1.1
by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking |
323 |
work_tree.add('file') |
|
3363.15.4
by Aaron Bentley
Implement PreviewTree.get_file_sha1 properly |
324 |
tree = self._convert_tree(work_tree) |
325 |
tree.lock_read() |
|
326 |
self.addCleanup(tree.unlock) |
|
|
7045.4.1
by Jelmer Vernooij
Some brz-git fixes. |
327 |
expected = osutils.sha_string(b'file content') |
|
6809.4.5
by Jelmer Vernooij
Swap arguments for get_file_*. |
328 |
self.assertEqual(expected, tree.get_file_sha1('file')) |
|
5906.1.8
by Jelmer Vernooij
Tests. |
329 |
|
330 |
||
331 |
class TestGetFileVerifier(TestCaseWithTree): |
|
332 |
||
333 |
def test_get_file_verifier(self): |
|
334 |
work_tree = self.make_branch_and_tree('tree') |
|
335 |
self.build_tree_contents([ |
|
|
6855.3.1
by Jelmer Vernooij
Several more fixes. |
336 |
('tree/file1', b'file content'), |
337 |
('tree/file2', b'file content')]) |
|
|
6745.1.1
by Jelmer Vernooij
Avoid explicitly setting file ids or guard it by checking |
338 |
work_tree.add(['file1', 'file2']) |
|
5906.1.8
by Jelmer Vernooij
Tests. |
339 |
tree = self._convert_tree(work_tree) |
340 |
tree.lock_read() |
|
341 |
self.addCleanup(tree.unlock) |
|
|
6809.4.5
by Jelmer Vernooij
Swap arguments for get_file_*. |
342 |
(kind, data) = tree.get_file_verifier('file1') |
|
6614.1.3
by Vincent Ladeuil
Fix assertEquals being deprecated by using assertEqual. |
343 |
self.assertEqual( |
|
6809.4.5
by Jelmer Vernooij
Swap arguments for get_file_*. |
344 |
tree.get_file_verifier('file1'), |
345 |
tree.get_file_verifier('file2')) |
|
|
5906.1.10
by Jelmer Vernooij
sha1 -> SHA1 |
346 |
if kind == "SHA1": |
|
7045.4.34
by Jelmer Vernooij
Fix some more tests. |
347 |
expected = osutils.sha_string(b'file content') |
|
5906.1.8
by Jelmer Vernooij
Tests. |
348 |
self.assertEqual(expected, data) |
|
6110.6.1
by Jelmer Vernooij
Add Tree.has_versioned_directories. |
349 |
|
350 |
||
351 |
class TestHasVersionedDirectories(TestCaseWithTree): |
|
352 |
||
353 |
def test_has_versioned_directories(self): |
|
354 |
work_tree = self.make_branch_and_tree('tree') |
|
355 |
tree = self._convert_tree(work_tree) |
|
|
6883.5.22
by Jelmer Vernooij
Review comments. |
356 |
self.assertIn(tree.has_versioned_directories(), (True, False)) |
|
6883.5.17
by Jelmer Vernooij
Add Tree.supports_rename_tracking(). |
357 |
|
358 |
||
359 |
class TestSupportsRenameTracking(TestCaseWithTree): |
|
360 |
||
361 |
def test_supports_rename_tracking(self): |
|
362 |
work_tree = self.make_branch_and_tree('tree') |
|
363 |
tree = self._convert_tree(work_tree) |
|
364 |
self.assertSubset([tree.supports_rename_tracking()], (True, False)) |
|
|
6929.3.3
by Jelmer Vernooij
Add Tree.versionable_kind. |
365 |
|
366 |
||
367 |
class TestSupportsVersionableKind(TestCaseWithTree): |
|
368 |
||
369 |
def test_file(self): |
|
370 |
work_tree = self.make_branch_and_tree('tree') |
|
371 |
tree = self._convert_tree(work_tree) |
|
372 |
self.assertTrue(tree.versionable_kind('file')) |
|
373 |
||
374 |
def test_unknown(self): |
|
375 |
work_tree = self.make_branch_and_tree('tree') |
|
376 |
tree = self._convert_tree(work_tree) |
|
377 |
self.assertFalse(tree.versionable_kind('unknown')) |