bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
2052.3.2
by John Arbash Meinel
Change Copyright .. by Canonical to Copyright ... Canonical |
1 |
# Copyright (C) 2006 Canonical Ltd
|
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
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
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
17 |
"""Tests for the InterTree.compare() function."""
|
|
18 |
||
|
2012.1.5
by Aaron Bentley
Implement specific file id and dangling id handling |
19 |
import os |
|
2255.7.4
by Robert Collins
Test InterTree._iter_changes with missing (absent but versioned) files. |
20 |
import shutil |
|
2012.1.5
by Aaron Bentley
Implement specific file id and dangling id handling |
21 |
|
|
1852.9.5
by Robert Collins
Add tests for require_versioned to the InterTree.compare() test suite. |
22 |
from bzrlib import errors |
|
2255.7.2
by Robert Collins
Add a (currently) disabled test for unversioned paths in the target tree with _iter_changes. |
23 |
from bzrlib.osutils import file_kind |
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
24 |
from bzrlib.tests.intertree_implementations import TestCaseWithTwoTrees |
25 |
||
|
2255.2.149
by Robert Collins
Crufty but existing _iter_changes implementation for WorkingTreeFormat4. |
26 |
# TODO: test diff unversioned dir that exists
|
27 |
# TODO: test the include_root option.
|
|
28 |
# TODO: test that renaming a directory x->y does not emit a rename for the
|
|
29 |
# child x/a->y/a.
|
|
30 |
# TODO: test that renaming a directory x-> does not emit a rename for the child
|
|
31 |
# x/a -> y/a when a supplied_files argument gives either 'x/' or 'y/a'
|
|
32 |
# -> that is, when the renamed parent is not processed by the function.
|
|
33 |
# TODO: include dangling in the diff output.
|
|
34 |
# TODO: test items are only emitted once when a specific_files list names a dir
|
|
35 |
# whose parent is now a child.
|
|
36 |
# TODO: test require_versioned
|
|
|
2255.2.151
by Robert Collins
Handle specific_files natively for WorkingTreeFormat4._iter_changes. |
37 |
# TODO: explicitly test specific_files listing a non-dir, and listing a symlink
|
38 |
# (it should not follow the link)
|
|
39 |
# TODO: test specific_files when the target tree has a file and the source a
|
|
40 |
# dir with children, same id and same path.
|
|
41 |
# TODO: test specific_files with a new unversioned path.
|
|
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
42 |
|
43 |
class TestCompare(TestCaseWithTwoTrees): |
|
44 |
||
45 |
def test_compare_empty_trees(self): |
|
46 |
tree1 = self.make_branch_and_tree('1') |
|
47 |
tree2 = self.make_to_branch_and_tree('2') |
|
48 |
tree1 = self.get_tree_no_parents_no_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
49 |
tree2 = self.get_tree_no_parents_no_content(tree2) |
50 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
|
1852.8.3
by Robert Collins
Implement an InterTreeTestProvider and a trivial test_compare test case. |
51 |
d = self.intertree_class(tree1, tree2).compare() |
|
1852.9.2
by Robert Collins
Convert stock delta tests to intertree_implementation tests of InterTree.compare. |
52 |
self.assertEqual([], d.added) |
53 |
self.assertEqual([], d.modified) |
|
54 |
self.assertEqual([], d.removed) |
|
55 |
self.assertEqual([], d.renamed) |
|
|
1852.9.4
by Robert Collins
Add minimal test for Tree.compare(extra_trees=...). |
56 |
self.assertEqual([], d.unchanged) |
|
1852.9.2
by Robert Collins
Convert stock delta tests to intertree_implementation tests of InterTree.compare. |
57 |
|
58 |
def test_empty_to_abc_content(self): |
|
59 |
tree1 = self.make_branch_and_tree('1') |
|
60 |
tree2 = self.make_to_branch_and_tree('2') |
|
61 |
tree1 = self.get_tree_no_parents_no_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
62 |
tree2 = self.get_tree_no_parents_abc_content(tree2) |
63 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
|
1852.9.2
by Robert Collins
Convert stock delta tests to intertree_implementation tests of InterTree.compare. |
64 |
d = self.intertree_class(tree1, tree2).compare() |
65 |
self.assertEqual([('a', 'a-id', 'file'), |
|
66 |
('b', 'b-id', 'directory'), |
|
67 |
('b/c', 'c-id', 'file'), |
|
68 |
], d.added) |
|
69 |
self.assertEqual([], d.modified) |
|
70 |
self.assertEqual([], d.removed) |
|
71 |
self.assertEqual([], d.renamed) |
|
|
1852.9.4
by Robert Collins
Add minimal test for Tree.compare(extra_trees=...). |
72 |
self.assertEqual([], d.unchanged) |
|
1852.9.2
by Robert Collins
Convert stock delta tests to intertree_implementation tests of InterTree.compare. |
73 |
|
|
2012.1.5
by Aaron Bentley
Implement specific file id and dangling id handling |
74 |
def test_dangling(self): |
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
75 |
# This test depends on the ability for some trees to have a difference
|
76 |
# between a 'versioned present' and 'versioned not present' (aka
|
|
77 |
# dangling) file. In this test there are two trees each with a separate
|
|
78 |
# dangling file, and the dangling files should be considered absent for
|
|
79 |
# the test.
|
|
|
2012.1.5
by Aaron Bentley
Implement specific file id and dangling id handling |
80 |
tree1 = self.make_branch_and_tree('1') |
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
81 |
tree2 = self.make_to_branch_and_tree('2') |
|
2012.1.5
by Aaron Bentley
Implement specific file id and dangling id handling |
82 |
self.build_tree(['2/a']) |
83 |
tree2.add('a') |
|
84 |
os.unlink('2/a') |
|
85 |
self.build_tree(['1/b']) |
|
86 |
tree1.add('b') |
|
87 |
os.unlink('1/b') |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
88 |
# the conversion to test trees here will leave the trees intact for the
|
89 |
# default intertree, but may perform a commit for other tree types,
|
|
90 |
# which may reduce the validity of the test. XXX: Think about how to
|
|
91 |
# address this.
|
|
92 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
|
2012.1.5
by Aaron Bentley
Implement specific file id and dangling id handling |
93 |
d = self.intertree_class(tree1, tree2).compare() |
94 |
self.assertEqual([], d.added) |
|
95 |
self.assertEqual([], d.modified) |
|
96 |
self.assertEqual([], d.removed) |
|
97 |
self.assertEqual([], d.renamed) |
|
98 |
self.assertEqual([], d.unchanged) |
|
99 |
||
|
1852.9.2
by Robert Collins
Convert stock delta tests to intertree_implementation tests of InterTree.compare. |
100 |
def test_abc_content_to_empty(self): |
101 |
tree1 = self.make_branch_and_tree('1') |
|
102 |
tree2 = self.make_to_branch_and_tree('2') |
|
103 |
tree1 = self.get_tree_no_parents_abc_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
104 |
tree2 = self.get_tree_no_parents_no_content(tree2) |
105 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
|
1852.9.2
by Robert Collins
Convert stock delta tests to intertree_implementation tests of InterTree.compare. |
106 |
d = self.intertree_class(tree1, tree2).compare() |
107 |
self.assertEqual([], d.added) |
|
108 |
self.assertEqual([], d.modified) |
|
109 |
self.assertEqual([('a', 'a-id', 'file'), |
|
110 |
('b', 'b-id', 'directory'), |
|
111 |
('b/c', 'c-id', 'file'), |
|
112 |
], d.removed) |
|
113 |
self.assertEqual([], d.renamed) |
|
|
1852.9.4
by Robert Collins
Add minimal test for Tree.compare(extra_trees=...). |
114 |
self.assertEqual([], d.unchanged) |
|
1852.9.2
by Robert Collins
Convert stock delta tests to intertree_implementation tests of InterTree.compare. |
115 |
|
116 |
def test_content_modification(self): |
|
117 |
tree1 = self.make_branch_and_tree('1') |
|
118 |
tree2 = self.make_to_branch_and_tree('2') |
|
119 |
tree1 = self.get_tree_no_parents_abc_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
120 |
tree2 = self.get_tree_no_parents_abc_content_2(tree2) |
121 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
|
1852.9.2
by Robert Collins
Convert stock delta tests to intertree_implementation tests of InterTree.compare. |
122 |
d = self.intertree_class(tree1, tree2).compare() |
123 |
self.assertEqual([], d.added) |
|
124 |
self.assertEqual([('a', 'a-id', 'file', True, False)], d.modified) |
|
125 |
self.assertEqual([], d.removed) |
|
126 |
self.assertEqual([], d.renamed) |
|
|
1852.9.4
by Robert Collins
Add minimal test for Tree.compare(extra_trees=...). |
127 |
self.assertEqual([], d.unchanged) |
|
1852.9.2
by Robert Collins
Convert stock delta tests to intertree_implementation tests of InterTree.compare. |
128 |
|
129 |
def test_meta_modification(self): |
|
130 |
tree1 = self.make_branch_and_tree('1') |
|
131 |
tree2 = self.make_to_branch_and_tree('2') |
|
132 |
tree1 = self.get_tree_no_parents_abc_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
133 |
tree2 = self.get_tree_no_parents_abc_content_3(tree2) |
134 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
|
1852.9.2
by Robert Collins
Convert stock delta tests to intertree_implementation tests of InterTree.compare. |
135 |
d = self.intertree_class(tree1, tree2).compare() |
136 |
self.assertEqual([], d.added) |
|
137 |
self.assertEqual([('b/c', 'c-id', 'file', False, True)], d.modified) |
|
138 |
self.assertEqual([], d.removed) |
|
139 |
self.assertEqual([], d.renamed) |
|
|
1852.9.4
by Robert Collins
Add minimal test for Tree.compare(extra_trees=...). |
140 |
self.assertEqual([], d.unchanged) |
|
1852.9.2
by Robert Collins
Convert stock delta tests to intertree_implementation tests of InterTree.compare. |
141 |
|
142 |
def test_file_rename(self): |
|
143 |
tree1 = self.make_branch_and_tree('1') |
|
144 |
tree2 = self.make_to_branch_and_tree('2') |
|
145 |
tree1 = self.get_tree_no_parents_abc_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
146 |
tree2 = self.get_tree_no_parents_abc_content_4(tree2) |
147 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
|
1852.9.2
by Robert Collins
Convert stock delta tests to intertree_implementation tests of InterTree.compare. |
148 |
d = self.intertree_class(tree1, tree2).compare() |
149 |
self.assertEqual([], d.added) |
|
150 |
self.assertEqual([], d.modified) |
|
151 |
self.assertEqual([], d.removed) |
|
152 |
self.assertEqual([('a', 'd', 'a-id', 'file', False, False)], d.renamed) |
|
|
1852.9.4
by Robert Collins
Add minimal test for Tree.compare(extra_trees=...). |
153 |
self.assertEqual([], d.unchanged) |
|
1852.9.2
by Robert Collins
Convert stock delta tests to intertree_implementation tests of InterTree.compare. |
154 |
|
155 |
def test_file_rename_and_modification(self): |
|
156 |
tree1 = self.make_branch_and_tree('1') |
|
157 |
tree2 = self.make_to_branch_and_tree('2') |
|
158 |
tree1 = self.get_tree_no_parents_abc_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
159 |
tree2 = self.get_tree_no_parents_abc_content_5(tree2) |
160 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
|
1852.9.2
by Robert Collins
Convert stock delta tests to intertree_implementation tests of InterTree.compare. |
161 |
d = self.intertree_class(tree1, tree2).compare() |
162 |
self.assertEqual([], d.added) |
|
163 |
self.assertEqual([], d.modified) |
|
164 |
self.assertEqual([], d.removed) |
|
165 |
self.assertEqual([('a', 'd', 'a-id', 'file', True, False)], d.renamed) |
|
|
1852.9.4
by Robert Collins
Add minimal test for Tree.compare(extra_trees=...). |
166 |
self.assertEqual([], d.unchanged) |
|
1852.9.2
by Robert Collins
Convert stock delta tests to intertree_implementation tests of InterTree.compare. |
167 |
|
168 |
def test_file_rename_and_meta_modification(self): |
|
169 |
tree1 = self.make_branch_and_tree('1') |
|
170 |
tree2 = self.make_to_branch_and_tree('2') |
|
171 |
tree1 = self.get_tree_no_parents_abc_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
172 |
tree2 = self.get_tree_no_parents_abc_content_6(tree2) |
173 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
|
1852.9.2
by Robert Collins
Convert stock delta tests to intertree_implementation tests of InterTree.compare. |
174 |
d = self.intertree_class(tree1, tree2).compare() |
175 |
self.assertEqual([], d.added) |
|
176 |
self.assertEqual([], d.modified) |
|
177 |
self.assertEqual([], d.removed) |
|
178 |
self.assertEqual([('b/c', 'e', 'c-id', 'file', False, True)], d.renamed) |
|
|
1852.9.4
by Robert Collins
Add minimal test for Tree.compare(extra_trees=...). |
179 |
self.assertEqual([], d.unchanged) |
|
1852.9.3
by Robert Collins
Convert the test_delta tests to intertree_implementation and workingtree_implementation tests as appropriate. |
180 |
|
181 |
def test_empty_to_abc_content_a_only(self): |
|
182 |
tree1 = self.make_branch_and_tree('1') |
|
183 |
tree2 = self.make_to_branch_and_tree('2') |
|
184 |
tree1 = self.get_tree_no_parents_no_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
185 |
tree2 = self.get_tree_no_parents_abc_content(tree2) |
186 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
|
1852.9.3
by Robert Collins
Convert the test_delta tests to intertree_implementation and workingtree_implementation tests as appropriate. |
187 |
d = self.intertree_class(tree1, tree2).compare(specific_files=['a']) |
188 |
self.assertEqual([('a', 'a-id', 'file')], d.added) |
|
189 |
self.assertEqual([], d.modified) |
|
190 |
self.assertEqual([], d.removed) |
|
191 |
self.assertEqual([], d.renamed) |
|
|
1852.9.4
by Robert Collins
Add minimal test for Tree.compare(extra_trees=...). |
192 |
self.assertEqual([], d.unchanged) |
|
1852.9.3
by Robert Collins
Convert the test_delta tests to intertree_implementation and workingtree_implementation tests as appropriate. |
193 |
|
194 |
def test_empty_to_abc_content_a_and_c_only(self): |
|
195 |
tree1 = self.make_branch_and_tree('1') |
|
196 |
tree2 = self.make_to_branch_and_tree('2') |
|
197 |
tree1 = self.get_tree_no_parents_no_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
198 |
tree2 = self.get_tree_no_parents_abc_content(tree2) |
199 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
|
1852.9.3
by Robert Collins
Convert the test_delta tests to intertree_implementation and workingtree_implementation tests as appropriate. |
200 |
d = self.intertree_class(tree1, tree2).compare( |
201 |
specific_files=['a', 'b/c']) |
|
202 |
self.assertEqual( |
|
203 |
[('a', 'a-id', 'file'), ('b/c', 'c-id', 'file')], |
|
204 |
d.added) |
|
205 |
self.assertEqual([], d.modified) |
|
206 |
self.assertEqual([], d.removed) |
|
207 |
self.assertEqual([], d.renamed) |
|
|
1852.9.4
by Robert Collins
Add minimal test for Tree.compare(extra_trees=...). |
208 |
self.assertEqual([], d.unchanged) |
|
1852.9.3
by Robert Collins
Convert the test_delta tests to intertree_implementation and workingtree_implementation tests as appropriate. |
209 |
|
210 |
def test_empty_to_abc_content_b_only(self): |
|
211 |
"""Restricting to a dir matches the children of the dir.""" |
|
212 |
tree1 = self.make_branch_and_tree('1') |
|
213 |
tree2 = self.make_to_branch_and_tree('2') |
|
214 |
tree1 = self.get_tree_no_parents_no_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
215 |
tree2 = self.get_tree_no_parents_abc_content(tree2) |
216 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
|
1852.9.3
by Robert Collins
Convert the test_delta tests to intertree_implementation and workingtree_implementation tests as appropriate. |
217 |
d = self.intertree_class(tree1, tree2).compare(specific_files=['b']) |
218 |
self.assertEqual( |
|
219 |
[('b', 'b-id', 'directory'),('b/c', 'c-id', 'file')], |
|
220 |
d.added) |
|
221 |
self.assertEqual([], d.modified) |
|
222 |
self.assertEqual([], d.removed) |
|
223 |
self.assertEqual([], d.renamed) |
|
|
1852.9.4
by Robert Collins
Add minimal test for Tree.compare(extra_trees=...). |
224 |
self.assertEqual([], d.unchanged) |
225 |
||
226 |
def test_unchanged_with_renames_and_modifications(self): |
|
227 |
"""want_unchanged should generate a list of unchanged entries.""" |
|
228 |
tree1 = self.make_branch_and_tree('1') |
|
229 |
tree2 = self.make_to_branch_and_tree('2') |
|
230 |
tree1 = self.get_tree_no_parents_abc_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
231 |
tree2 = self.get_tree_no_parents_abc_content_5(tree2) |
232 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
|
1852.9.4
by Robert Collins
Add minimal test for Tree.compare(extra_trees=...). |
233 |
d = self.intertree_class(tree1, tree2).compare(want_unchanged=True) |
234 |
self.assertEqual([], d.added) |
|
235 |
self.assertEqual([], d.modified) |
|
236 |
self.assertEqual([], d.removed) |
|
237 |
self.assertEqual([('a', 'd', 'a-id', 'file', True, False)], d.renamed) |
|
238 |
self.assertEqual( |
|
239 |
[(u'b', 'b-id', 'directory'), (u'b/c', 'c-id', 'file')], |
|
240 |
d.unchanged) |
|
241 |
||
242 |
def test_extra_trees_finds_ids(self): |
|
243 |
"""Ask for a delta between two trees with a path present in a third.""" |
|
244 |
tree1 = self.make_branch_and_tree('1') |
|
245 |
tree2 = self.make_to_branch_and_tree('2') |
|
246 |
tree1 = self.get_tree_no_parents_abc_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
247 |
tree2 = self.get_tree_no_parents_abc_content_3(tree2) |
248 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
249 |
d = self.intertree_class(tree1, tree2).compare(specific_files=['b']) |
|
|
1852.9.4
by Robert Collins
Add minimal test for Tree.compare(extra_trees=...). |
250 |
# the type of tree-3 does not matter - it is used as a lookup, not
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
251 |
# a dispatch. XXX: For dirstate it does speak to the optimisability of
|
252 |
# the lookup, in merged trees it can be fast-pathed. We probably want
|
|
253 |
# two tests: one as is, and one with it as a pending merge.
|
|
|
1852.9.4
by Robert Collins
Add minimal test for Tree.compare(extra_trees=...). |
254 |
tree3 = self.make_branch_and_tree('3') |
255 |
tree3 = self.get_tree_no_parents_abc_content_6(tree3) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
256 |
tree3.lock_read() |
257 |
self.addCleanup(tree3.unlock) |
|
|
1852.9.4
by Robert Collins
Add minimal test for Tree.compare(extra_trees=...). |
258 |
# tree 3 has 'e' which is 'c-id'. Tree 1 has c-id at b/c, and Tree 2
|
259 |
# has c-id at b/c with its exec flag toggled.
|
|
260 |
# without extra_trees, we should get no modifications from this
|
|
261 |
# so do one, to be sure the test is valid.
|
|
262 |
d = self.intertree_class(tree1, tree2).compare( |
|
263 |
specific_files=['e']) |
|
264 |
self.assertEqual([], d.modified) |
|
265 |
# now give it an additional lookup:
|
|
266 |
d = self.intertree_class(tree1, tree2).compare( |
|
267 |
specific_files=['e'], extra_trees=[tree3]) |
|
268 |
self.assertEqual([], d.added) |
|
269 |
self.assertEqual([('b/c', 'c-id', 'file', False, True)], d.modified) |
|
270 |
self.assertEqual([], d.removed) |
|
271 |
self.assertEqual([], d.renamed) |
|
272 |
self.assertEqual([], d.unchanged) |
|
|
1852.9.5
by Robert Collins
Add tests for require_versioned to the InterTree.compare() test suite. |
273 |
|
274 |
def test_require_versioned(self): |
|
275 |
# this does not quite robustly test, as it is passing in missing paths
|
|
276 |
# rather than present-but-not-versioned paths. At the moment there is
|
|
277 |
# no mechanism for managing the test trees (which are readonly) to
|
|
278 |
# get present-but-not-versioned files for trees that can do that.
|
|
279 |
tree1 = self.make_branch_and_tree('1') |
|
280 |
tree2 = self.make_to_branch_and_tree('2') |
|
281 |
tree1 = self.get_tree_no_parents_no_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
282 |
tree2 = self.get_tree_no_parents_abc_content(tree2) |
283 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
|
1852.9.5
by Robert Collins
Add tests for require_versioned to the InterTree.compare() test suite. |
284 |
self.assertRaises(errors.PathsNotVersionedError, |
285 |
self.intertree_class(tree1, tree2).compare, |
|
286 |
specific_files=['d'], |
|
287 |
require_versioned=True) |
|
|
2012.1.1
by Aaron Bentley
Implement change iterator |
288 |
|
289 |
||
|
2012.1.3
by Aaron Bentley
Always generate tuples (because kind is always used, even when not different) |
290 |
class TestIterChanges(TestCaseWithTwoTrees): |
|
2012.1.1
by Aaron Bentley
Implement change iterator |
291 |
"""Test the comparison iterator""" |
292 |
||
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
293 |
def do_iter_changes(self, tree1, tree2, **extra_args): |
294 |
"""Helper to run _iter_changes from tree1 to tree2. |
|
295 |
|
|
296 |
:param tree1, tree2: The source and target trees. These will be locked
|
|
297 |
automatically.
|
|
298 |
:param **extra_args: Extra args to pass to _iter_changes. This is not
|
|
299 |
inspected by this test helper.
|
|
300 |
"""
|
|
301 |
tree1.lock_read() |
|
302 |
tree2.lock_read() |
|
303 |
try: |
|
|
2255.2.149
by Robert Collins
Crufty but existing _iter_changes implementation for WorkingTreeFormat4. |
304 |
# sort order of output is not strictly defined
|
305 |
return sorted(self.intertree_class(tree1, tree2) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
306 |
._iter_changes(**extra_args)) |
307 |
finally: |
|
308 |
tree1.unlock() |
|
309 |
tree2.unlock() |
|
310 |
||
|
2255.7.15
by John Arbash Meinel
Try to create an intertree test that exposes the walkdir vs dirstate mismatch. No luck yet. |
311 |
def make_tree_with_special_names(self): |
312 |
"""Create a tree with filenames chosen to exercise the walk order.""" |
|
313 |
tree1 = self.make_branch_and_tree('tree1') |
|
314 |
tree2 = self.make_to_branch_and_tree('tree2') |
|
|
2255.8.1
by John Arbash Meinel
(broken) Update the test to actually expose the iter_changes bug. |
315 |
from_paths = ['b-ar/', 'b-ar/a', |
316 |
'b-foo/', 'b-foo/a', |
|
317 |
'b-zar/', 'b-zar/a', |
|
318 |
'bar/', 'bar/a', |
|
319 |
'bfoo/', 'bfoo/a', |
|
320 |
'bzar/', 'bzar/a', |
|
321 |
'b/', 'b/a', |
|
322 |
'b/ar/', 'b/ar/a', |
|
323 |
'b/foo/', 'b/foo/a', |
|
324 |
'b/zar/', 'b/zar/a', |
|
325 |
'b/foo-a/', 'b/foo-a/a', |
|
326 |
'b/foo-z/', 'b/foo-z/a', |
|
327 |
'b/fooa/', 'b/fooa/a', |
|
328 |
'b/fooz/', 'b/fooz/a', |
|
329 |
'b/foo/z/', 'b/foo/z/a', |
|
330 |
]
|
|
|
2255.7.15
by John Arbash Meinel
Try to create an intertree test that exposes the walkdir vs dirstate mismatch. No luck yet. |
331 |
self.build_tree(['tree2/' + p for p in from_paths]) |
332 |
paths_no_slashes = [p.strip('/') for p in from_paths] |
|
333 |
path_ids = [p.replace('/', '_') + '-id' for p in paths_no_slashes] |
|
334 |
tree2.add(paths_no_slashes, path_ids) |
|
335 |
tree2.commit('initial', rev_id='rev-1') |
|
336 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
337 |
return (tree1, tree2, paths_no_slashes, path_ids) |
|
338 |
||
|
2012.1.1
by Aaron Bentley
Implement change iterator |
339 |
def test_compare_empty_trees(self): |
340 |
tree1 = self.make_branch_and_tree('1') |
|
341 |
tree2 = self.make_to_branch_and_tree('2') |
|
342 |
tree1 = self.get_tree_no_parents_no_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
343 |
tree2 = self.get_tree_no_parents_no_content(tree2) |
344 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
345 |
self.assertEqual([], self.do_iter_changes(tree1, tree2)) |
|
|
2012.1.1
by Aaron Bentley
Implement change iterator |
346 |
|
|
2012.1.5
by Aaron Bentley
Implement specific file id and dangling id handling |
347 |
def added(self, tree, file_id): |
348 |
entry = tree.inventory[file_id] |
|
349 |
path = tree.id2path(file_id) |
|
350 |
return (file_id, path, True, (False, True), (None, entry.parent_id), |
|
|
2255.7.2
by Robert Collins
Add a (currently) disabled test for unversioned paths in the target tree with _iter_changes. |
351 |
(None, entry.name), (None, entry.kind), |
|
2012.1.5
by Aaron Bentley
Implement specific file id and dangling id handling |
352 |
(None, entry.executable)) |
353 |
||
|
2255.7.3
by Robert Collins
Add tests for _iter_changes with symlinks, disabled until unversioned file support is added, as that affects the test expected value. |
354 |
def content_changed(self, tree, file_id): |
355 |
entry = tree.inventory[file_id] |
|
356 |
path = tree.id2path(file_id) |
|
357 |
return (file_id, path, True, (True, True), (entry.parent_id, entry.parent_id), |
|
358 |
(entry.name, entry.name), (entry.kind, entry.kind), |
|
359 |
(entry.executable, entry.executable)) |
|
360 |
||
361 |
def kind_changed(self, from_tree, to_tree, file_id): |
|
362 |
old_entry = from_tree.inventory[file_id] |
|
363 |
new_entry = to_tree.inventory[file_id] |
|
364 |
path = to_tree.id2path(file_id) |
|
365 |
return (file_id, path, True, (True, True), (old_entry.parent_id, new_entry.parent_id), |
|
366 |
(old_entry.name, new_entry.name), (old_entry.kind, new_entry.kind), |
|
367 |
(old_entry.executable, new_entry.executable)) |
|
368 |
||
|
2255.7.4
by Robert Collins
Test InterTree._iter_changes with missing (absent but versioned) files. |
369 |
def missing(self, file_id, path, parent_id, kind): |
370 |
_, basename = os.path.split(path) |
|
371 |
return (file_id, path, True, (True, True), (parent_id, parent_id), |
|
372 |
(basename, basename), (kind, None), (False, False)) |
|
373 |
||
|
2012.1.5
by Aaron Bentley
Implement specific file id and dangling id handling |
374 |
def deleted(self, tree, file_id): |
375 |
entry = tree.inventory[file_id] |
|
376 |
path = tree.id2path(file_id) |
|
377 |
return (file_id, path, True, (True, False), (entry.parent_id, None), |
|
|
2255.7.2
by Robert Collins
Add a (currently) disabled test for unversioned paths in the target tree with _iter_changes. |
378 |
(entry.name, None), (entry.kind, None), |
|
2012.1.5
by Aaron Bentley
Implement specific file id and dangling id handling |
379 |
(entry.executable, None)) |
380 |
||
|
2255.7.3
by Robert Collins
Add tests for _iter_changes with symlinks, disabled until unversioned file support is added, as that affects the test expected value. |
381 |
def unchanged(self, tree, file_id): |
382 |
entry = tree.inventory[file_id] |
|
383 |
parent = entry.parent_id |
|
384 |
name = entry.name |
|
385 |
kind = entry.kind |
|
386 |
executable = entry.executable |
|
387 |
return (file_id, tree.id2path(file_id), False, (True, True), |
|
388 |
(parent, parent), (name, name), (kind, kind), |
|
389 |
(executable, executable)) |
|
390 |
||
|
2255.7.2
by Robert Collins
Add a (currently) disabled test for unversioned paths in the target tree with _iter_changes. |
391 |
def unversioned(self, tree, path): |
392 |
"""Create an unversioned result.""" |
|
393 |
_, basename = os.path.split(path) |
|
394 |
kind = file_kind(tree.abspath(path)) |
|
|
2255.7.3
by Robert Collins
Add tests for _iter_changes with symlinks, disabled until unversioned file support is added, as that affects the test expected value. |
395 |
return (None, path, True, (False, False), (None, None), |
|
2255.7.2
by Robert Collins
Add a (currently) disabled test for unversioned paths in the target tree with _iter_changes. |
396 |
(None, basename), (None, kind), |
397 |
(None, False)) |
|
398 |
||
|
2012.1.1
by Aaron Bentley
Implement change iterator |
399 |
def test_empty_to_abc_content(self): |
400 |
tree1 = self.make_branch_and_tree('1') |
|
401 |
tree2 = self.make_to_branch_and_tree('2') |
|
402 |
tree1 = self.get_tree_no_parents_no_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
403 |
tree2 = self.get_tree_no_parents_abc_content(tree2) |
404 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
|
2255.2.118
by Robert Collins
Change _iter_changes tests to lock the tested trees - its an iterator interface so implicit locks dont ensure the tree is locked - callers need to lock and thus so do our tests. |
405 |
tree1.lock_read() |
406 |
tree2.lock_read() |
|
|
2255.2.149
by Robert Collins
Crufty but existing _iter_changes implementation for WorkingTreeFormat4. |
407 |
expected_results = sorted([ |
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
408 |
self.added(tree2, 'root-id'), |
409 |
self.added(tree2, 'a-id'), |
|
410 |
self.added(tree2, 'b-id'), |
|
411 |
self.added(tree2, 'c-id'), |
|
|
2255.2.149
by Robert Collins
Crufty but existing _iter_changes implementation for WorkingTreeFormat4. |
412 |
self.deleted(tree1, 'empty-root-id')]) |
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
413 |
tree1.unlock() |
414 |
tree2.unlock() |
|
415 |
self.assertEqual(expected_results, self.do_iter_changes(tree1, tree2)) |
|
|
2012.1.1
by Aaron Bentley
Implement change iterator |
416 |
|
|
2012.1.5
by Aaron Bentley
Implement specific file id and dangling id handling |
417 |
def test_empty_to_abc_content_a_only(self): |
418 |
tree1 = self.make_branch_and_tree('1') |
|
419 |
tree2 = self.make_to_branch_and_tree('2') |
|
420 |
tree1 = self.get_tree_no_parents_no_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
421 |
tree2 = self.get_tree_no_parents_abc_content(tree2) |
422 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
423 |
tree1.lock_read() |
|
424 |
tree2.lock_read() |
|
425 |
self.assertEqual( |
|
426 |
[self.added(tree2, 'a-id')], |
|
|
2255.2.149
by Robert Collins
Crufty but existing _iter_changes implementation for WorkingTreeFormat4. |
427 |
self.do_iter_changes(tree1, tree2, specific_files=['a'])) |
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
428 |
tree1.unlock() |
429 |
tree2.unlock() |
|
430 |
||
431 |
def test_abc_content_to_empty_to_abc_content_a_only(self): |
|
432 |
tree1 = self.make_branch_and_tree('1') |
|
433 |
tree2 = self.make_to_branch_and_tree('2') |
|
434 |
tree1 = self.get_tree_no_parents_abc_content(tree1) |
|
435 |
tree2 = self.get_tree_no_parents_no_content(tree2) |
|
436 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
437 |
tree1.lock_read() |
|
438 |
tree2.lock_read() |
|
439 |
self.assertEqual( |
|
440 |
[self.deleted(tree1, 'a-id')], |
|
|
2255.2.149
by Robert Collins
Crufty but existing _iter_changes implementation for WorkingTreeFormat4. |
441 |
self.do_iter_changes(tree1, tree2, specific_files=['a'])) |
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
442 |
tree1.unlock() |
443 |
tree2.unlock() |
|
|
2012.1.5
by Aaron Bentley
Implement specific file id and dangling id handling |
444 |
|
445 |
def test_empty_to_abc_content_a_and_c_only(self): |
|
446 |
tree1 = self.make_branch_and_tree('1') |
|
447 |
tree2 = self.make_to_branch_and_tree('2') |
|
448 |
tree1 = self.get_tree_no_parents_no_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
449 |
tree2 = self.get_tree_no_parents_abc_content(tree2) |
450 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
|
2255.2.118
by Robert Collins
Change _iter_changes tests to lock the tested trees - its an iterator interface so implicit locks dont ensure the tree is locked - callers need to lock and thus so do our tests. |
451 |
tree1.lock_read() |
452 |
tree2.lock_read() |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
453 |
expected_result = [self.added(tree2, 'a-id'), self.added(tree2, 'c-id')] |
454 |
tree1.unlock() |
|
455 |
tree2.unlock() |
|
456 |
self.assertEqual(expected_result, |
|
|
2255.2.149
by Robert Collins
Crufty but existing _iter_changes implementation for WorkingTreeFormat4. |
457 |
self.do_iter_changes(tree1, tree2, specific_files=['a', 'b/c'])) |
|
2012.1.5
by Aaron Bentley
Implement specific file id and dangling id handling |
458 |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
459 |
def test_abc_content_to_empty(self): |
|
2012.1.1
by Aaron Bentley
Implement change iterator |
460 |
tree1 = self.make_branch_and_tree('1') |
461 |
tree2 = self.make_to_branch_and_tree('2') |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
462 |
tree1 = self.get_tree_no_parents_abc_content(tree1) |
463 |
tree2 = self.get_tree_no_parents_no_content(tree2) |
|
464 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
465 |
tree1.lock_read() |
|
466 |
tree2.lock_read() |
|
|
2012.1.1
by Aaron Bentley
Implement change iterator |
467 |
def deleted(file_id): |
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
468 |
entry = tree1.inventory[file_id] |
469 |
path = tree1.id2path(file_id) |
|
470 |
return (file_id, path, True, (True, False), |
|
|
2012.1.1
by Aaron Bentley
Implement change iterator |
471 |
(entry.parent_id, None), |
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
472 |
(entry.name, None), (entry.kind, None), |
|
2012.1.1
by Aaron Bentley
Implement change iterator |
473 |
(entry.executable, None)) |
|
2255.2.149
by Robert Collins
Crufty but existing _iter_changes implementation for WorkingTreeFormat4. |
474 |
expected_results = sorted([self.added(tree2, 'empty-root-id'), |
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
475 |
deleted('root-id'), deleted('a-id'), |
|
2255.2.149
by Robert Collins
Crufty but existing _iter_changes implementation for WorkingTreeFormat4. |
476 |
deleted('b-id'), deleted('c-id')]) |
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
477 |
tree1.unlock() |
478 |
tree2.unlock() |
|
479 |
self.assertEqual( |
|
480 |
expected_results, |
|
481 |
self.do_iter_changes(tree1, tree2)) |
|
|
2012.1.1
by Aaron Bentley
Implement change iterator |
482 |
|
483 |
def test_content_modification(self): |
|
484 |
tree1 = self.make_branch_and_tree('1') |
|
485 |
tree2 = self.make_to_branch_and_tree('2') |
|
486 |
tree1 = self.get_tree_no_parents_abc_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
487 |
tree2 = self.get_tree_no_parents_abc_content_2(tree2) |
488 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
489 |
root_id = tree1.path2id('') |
|
490 |
self.assertEqual([('a-id', 'a', True, (True, True), |
|
491 |
(root_id, root_id), ('a', 'a'), |
|
492 |
('file', 'file'), (False, False))], |
|
493 |
self.do_iter_changes(tree1, tree2)) |
|
|
2012.1.1
by Aaron Bentley
Implement change iterator |
494 |
|
495 |
def test_meta_modification(self): |
|
496 |
tree1 = self.make_branch_and_tree('1') |
|
497 |
tree2 = self.make_to_branch_and_tree('2') |
|
498 |
tree1 = self.get_tree_no_parents_abc_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
499 |
tree2 = self.get_tree_no_parents_abc_content_3(tree2) |
500 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
501 |
self.assertEqual([('c-id', 'b/c', False, (True, True), |
|
502 |
('b-id', 'b-id'), ('c', 'c'), ('file', 'file'), |
|
503 |
(False, True))], |
|
504 |
self.do_iter_changes(tree1, tree2)) |
|
|
2012.1.1
by Aaron Bentley
Implement change iterator |
505 |
|
|
2255.7.6
by Robert Collins
Test for iterating changes past empty directories. |
506 |
def test_empty_dir(self): |
507 |
"""an empty dir should not cause glitches to surrounding files.""" |
|
508 |
tree1 = self.make_branch_and_tree('1') |
|
509 |
tree2 = self.make_to_branch_and_tree('2') |
|
510 |
tree1 = self.get_tree_no_parents_abc_content(tree1) |
|
511 |
tree2 = self.get_tree_no_parents_abc_content(tree2) |
|
512 |
# the pathname is chosen to fall between 'a' and 'b'.
|
|
513 |
self.build_tree(['1/a-empty/', '2/a-empty/']) |
|
514 |
tree1.add(['a-empty'], ['a-empty']) |
|
515 |
tree2.add(['a-empty'], ['a-empty']) |
|
516 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
517 |
expected = [] |
|
518 |
self.assertEqual(expected, self.do_iter_changes(tree1, tree2)) |
|
519 |
||
|
2012.1.1
by Aaron Bentley
Implement change iterator |
520 |
def test_file_rename(self): |
521 |
tree1 = self.make_branch_and_tree('1') |
|
522 |
tree2 = self.make_to_branch_and_tree('2') |
|
523 |
tree1 = self.get_tree_no_parents_abc_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
524 |
tree2 = self.get_tree_no_parents_abc_content_4(tree2) |
525 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
526 |
root_id = tree1.path2id('') |
|
527 |
self.assertEqual([('a-id', 'd', False, (True, True), |
|
|
2012.1.3
by Aaron Bentley
Always generate tuples (because kind is always used, even when not different) |
528 |
(root_id, root_id), ('a', 'd'), ('file', 'file'), |
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
529 |
(False, False))], |
530 |
self.do_iter_changes(tree1, tree2)) |
|
|
2012.1.1
by Aaron Bentley
Implement change iterator |
531 |
|
532 |
def test_file_rename_and_modification(self): |
|
533 |
tree1 = self.make_branch_and_tree('1') |
|
534 |
tree2 = self.make_to_branch_and_tree('2') |
|
535 |
tree1 = self.get_tree_no_parents_abc_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
536 |
tree2 = self.get_tree_no_parents_abc_content_5(tree2) |
537 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
538 |
root_id = tree1.path2id('') |
|
539 |
self.assertEqual([('a-id', 'd', True, (True, True), |
|
|
2012.1.3
by Aaron Bentley
Always generate tuples (because kind is always used, even when not different) |
540 |
(root_id, root_id), ('a', 'd'), ('file', 'file'), |
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
541 |
(False, False))], |
542 |
self.do_iter_changes(tree1, tree2)) |
|
|
2012.1.1
by Aaron Bentley
Implement change iterator |
543 |
|
544 |
def test_file_rename_and_meta_modification(self): |
|
545 |
tree1 = self.make_branch_and_tree('1') |
|
546 |
tree2 = self.make_to_branch_and_tree('2') |
|
547 |
tree1 = self.get_tree_no_parents_abc_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
548 |
tree2 = self.get_tree_no_parents_abc_content_6(tree2) |
549 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
550 |
root_id = tree1.path2id('') |
|
551 |
self.assertEqual([('c-id', 'e', False, (True, True), |
|
552 |
('b-id', root_id), ('c', 'e'), ('file', 'file'), |
|
553 |
(False, True))], |
|
554 |
self.do_iter_changes(tree1, tree2)) |
|
|
2012.1.1
by Aaron Bentley
Implement change iterator |
555 |
|
|
2255.7.4
by Robert Collins
Test InterTree._iter_changes with missing (absent but versioned) files. |
556 |
def test_missing_in_target(self): |
557 |
"""Test with the target files versioned but absent from disk.""" |
|
558 |
tree1 = self.make_branch_and_tree('1') |
|
559 |
tree2 = self.make_to_branch_and_tree('2') |
|
560 |
tree1 = self.get_tree_no_parents_abc_content(tree1) |
|
561 |
tree2 = self.get_tree_no_parents_abc_content(tree2) |
|
562 |
os.unlink('2/a') |
|
563 |
shutil.rmtree('2/b') |
|
564 |
# TODO ? have a symlink here?
|
|
565 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
566 |
root_id = tree1.path2id('') |
|
567 |
expected = sorted([ |
|
568 |
self.missing('a-id', 'a', root_id, 'file'), |
|
569 |
self.missing('b-id', 'b', root_id, 'directory'), |
|
570 |
self.missing('c-id', 'b/c', 'b-id', 'file'), |
|
571 |
])
|
|
572 |
self.assertEqual(expected, self.do_iter_changes(tree1, tree2)) |
|
573 |
||
|
2012.1.1
by Aaron Bentley
Implement change iterator |
574 |
def test_unchanged_with_renames_and_modifications(self): |
575 |
"""want_unchanged should generate a list of unchanged entries.""" |
|
576 |
tree1 = self.make_branch_and_tree('1') |
|
577 |
tree2 = self.make_to_branch_and_tree('2') |
|
578 |
tree1 = self.get_tree_no_parents_abc_content(tree1) |
|
|
2255.2.122
by Robert Collins
Alter intertree implementation tests to let dirstate inter-trees be correctly parameterised. |
579 |
tree2 = self.get_tree_no_parents_abc_content_5(tree2) |
580 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
581 |
root_id = tree1.path2id('') |
|
|
2255.2.118
by Robert Collins
Change _iter_changes tests to lock the tested trees - its an iterator interface so implicit locks dont ensure the tree is locked - callers need to lock and thus so do our tests. |
582 |
tree1.lock_read() |
583 |
self.addCleanup(tree1.unlock) |
|
584 |
tree2.lock_read() |
|
585 |
self.addCleanup(tree2.unlock) |
|
|
2255.7.3
by Robert Collins
Add tests for _iter_changes with symlinks, disabled until unversioned file support is added, as that affects the test expected value. |
586 |
self.assertEqual(sorted([self.unchanged(tree1, root_id), |
|
2255.7.4
by Robert Collins
Test InterTree._iter_changes with missing (absent but versioned) files. |
587 |
self.unchanged(tree1, 'b-id'), ('a-id', 'd', True, (True, True), |
|
2255.7.3
by Robert Collins
Add tests for _iter_changes with symlinks, disabled until unversioned file support is added, as that affects the test expected value. |
588 |
(root_id, root_id), ('a', 'd'), ('file', 'file'), |
|
2255.7.4
by Robert Collins
Test InterTree._iter_changes with missing (absent but versioned) files. |
589 |
(False, False)), self.unchanged(tree1, 'c-id')]), |
|
2255.7.3
by Robert Collins
Add tests for _iter_changes with symlinks, disabled until unversioned file support is added, as that affects the test expected value. |
590 |
self.do_iter_changes(tree1, tree2, include_unchanged=True)) |
|
2255.7.2
by Robert Collins
Add a (currently) disabled test for unversioned paths in the target tree with _iter_changes. |
591 |
|
592 |
def _todo_test_unversioned_paths_in_tree(self): |
|
593 |
tree1 = self.make_branch_and_tree('tree1') |
|
594 |
tree2 = self.make_to_branch_and_tree('tree2') |
|
|
2255.7.3
by Robert Collins
Add tests for _iter_changes with symlinks, disabled until unversioned file support is added, as that affects the test expected value. |
595 |
self.build_tree(['tree2/file', 'tree2/dir/']) |
|
2255.7.2
by Robert Collins
Add a (currently) disabled test for unversioned paths in the target tree with _iter_changes. |
596 |
# try:
|
597 |
os.symlink('target', 'tree2/link') |
|
598 |
links_supported = True |
|
599 |
# except ???:
|
|
600 |
# links_supported = False
|
|
601 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
602 |
root_id = tree1.path2id('') |
|
603 |
tree1.lock_read() |
|
604 |
self.addCleanup(tree1.unlock) |
|
605 |
tree2.lock_read() |
|
606 |
self.addCleanup(tree2.unlock) |
|
607 |
expected = [ |
|
608 |
self.unversioned(tree2, 'file'), |
|
609 |
self.unversioned(tree2, 'dir'), |
|
610 |
]
|
|
611 |
if links_supported: |
|
612 |
expected.append(self.unversioned(tree2, 'link')) |
|
613 |
expected = sorted(expected) |
|
614 |
self.assertEqual(expected, self.do_iter_changes(tree1, tree2)) |
|
615 |
||
616 |
def _todo_test_unversioned_paths_in_tree_specific_files(self): |
|
617 |
tree1 = self.make_branch_and_tree('tree1') |
|
618 |
tree2 = self.make_to_branch_and_tree('tree2') |
|
|
2255.7.3
by Robert Collins
Add tests for _iter_changes with symlinks, disabled until unversioned file support is added, as that affects the test expected value. |
619 |
self.build_tree(['tree2/file', 'tree2/dir/']) |
|
2255.7.2
by Robert Collins
Add a (currently) disabled test for unversioned paths in the target tree with _iter_changes. |
620 |
# try:
|
621 |
os.symlink('target', 'tree2/link') |
|
622 |
links_supported = True |
|
623 |
# except ???:
|
|
624 |
# links_supported = False
|
|
625 |
tree1, tree2 = self.mutable_trees_to_test_trees(tree1, tree2) |
|
626 |
root_id = tree1.path2id('') |
|
627 |
tree1.lock_read() |
|
628 |
self.addCleanup(tree1.unlock) |
|
629 |
tree2.lock_read() |
|
630 |
self.addCleanup(tree2.unlock) |
|
631 |
expected = [ |
|
632 |
self.unversioned(tree2, 'file'), |
|
633 |
self.unversioned(tree2, 'dir'), |
|
634 |
]
|
|
635 |
specific_files=['file', 'dir'] |
|
636 |
if links_supported: |
|
637 |
expected.append(self.unversioned(tree2, 'link')) |
|
638 |
specific_files.append('link') |
|
639 |
expected = sorted(expected) |
|
640 |
self.assertEqual(expected, self.do_iter_changes(tree1, tree2, |
|
641 |
specific_files=specific_files)) |
|
|
2255.7.3
by Robert Collins
Add tests for _iter_changes with symlinks, disabled until unversioned file support is added, as that affects the test expected value. |
642 |
|
643 |
def make_trees_with_symlinks(self): |
|
644 |
tree1 = self.make_branch_and_tree('tree1') |
|
645 |
tree2 = self.make_to_branch_and_tree('tree2') |
|
646 |
self.build_tree(['tree1/fromfile', 'tree1/fromdir/']) |
|
647 |
self.build_tree(['tree2/tofile', 'tree2/todir/', 'tree2/unknown']) |
|
648 |
# try:
|
|
649 |
os.symlink('original', 'tree1/changed') |
|
650 |
os.symlink('original', 'tree1/removed') |
|
651 |
os.symlink('original', 'tree1/tofile') |
|
652 |
os.symlink('original', 'tree1/todir') |
|
653 |
# we make the unchanged link point at unknown to catch incorrect
|
|
654 |
# symlink-following code in the specified_files test.
|
|
655 |
os.symlink('unknown', 'tree1/unchanged') |
|
656 |
os.symlink('new', 'tree2/added') |
|
657 |
os.symlink('new', 'tree2/changed') |
|
658 |
os.symlink('new', 'tree2/fromfile') |
|
659 |
os.symlink('new', 'tree2/fromdir') |
|
660 |
os.symlink('unknown', 'tree2/unchanged') |
|
661 |
from_paths_and_ids = [ |
|
662 |
'fromdir', |
|
663 |
'fromfile', |
|
664 |
'changed', |
|
665 |
'removed', |
|
666 |
'todir', |
|
667 |
'tofile', |
|
668 |
'unchanged', |
|
669 |
]
|
|
670 |
to_paths_and_ids = [ |
|
671 |
'added', |
|
672 |
'fromdir', |
|
673 |
'fromfile', |
|
674 |
'changed', |
|
675 |
'todir', |
|
676 |
'tofile', |
|
677 |
'unchanged', |
|
678 |
]
|
|
679 |
tree1.add(from_paths_and_ids, from_paths_and_ids) |
|
680 |
tree2.add(to_paths_and_ids, to_paths_and_ids) |
|
681 |
# except ???:
|
|
682 |
# raise TestSkipped('OS does not support symlinks')
|
|
683 |
# links_supported = False
|
|
684 |
return self.mutable_trees_to_test_trees(tree1, tree2) |
|
685 |
||
686 |
def _disabled_test_versioned_symlinks(self): |
|
687 |
tree1, tree2 = self.make_trees_with_symlinks() |
|
688 |
root_id = tree1.path2id('') |
|
689 |
tree1.lock_read() |
|
690 |
self.addCleanup(tree1.unlock) |
|
691 |
tree2.lock_read() |
|
692 |
self.addCleanup(tree2.unlock) |
|
693 |
expected = [ |
|
694 |
self.unchanged(tree1, tree1.path2id('')), |
|
695 |
self.added(tree2, 'added'), |
|
696 |
self.content_changed(tree2, 'changed'), |
|
697 |
self.kind_changed(tree1, tree2, 'fromdir'), |
|
698 |
self.kind_changed(tree1, tree2, 'fromfile'), |
|
699 |
self.deleted(tree1, 'removed'), |
|
700 |
self.unchanged(tree2, 'unchanged'), |
|
701 |
self.unversioned(tree2, 'unknown'), |
|
702 |
self.kind_changed(tree1, tree2, 'todir'), |
|
703 |
self.kind_changed(tree1, tree2, 'tofile'), |
|
704 |
]
|
|
705 |
expected = sorted(expected) |
|
706 |
self.assertEqual(expected, self.do_iter_changes(tree1, tree2, include_unchanged=True)) |
|
707 |
||
708 |
def _disabled_test_versioned_symlinks_specific_files(self): |
|
709 |
tree1, tree2 = self.make_trees_with_symlinks() |
|
710 |
root_id = tree1.path2id('') |
|
711 |
tree1.lock_read() |
|
712 |
self.addCleanup(tree1.unlock) |
|
713 |
tree2.lock_read() |
|
714 |
self.addCleanup(tree2.unlock) |
|
715 |
expected = [ |
|
716 |
self.added(tree2, 'added'), |
|
717 |
self.content_changed(tree2, 'changed'), |
|
718 |
self.kind_changed(tree1, tree2, 'fromdir'), |
|
719 |
self.kind_changed(tree1, tree2, 'fromfile'), |
|
720 |
self.deleted(tree1, 'removed'), |
|
721 |
self.kind_changed(tree1, tree2, 'todir'), |
|
722 |
self.kind_changed(tree1, tree2, 'tofile'), |
|
723 |
]
|
|
724 |
expected = sorted(expected) |
|
725 |
# we should get back just the changed links. We pass in 'unchanged' to
|
|
726 |
# make sure that it is correctly not returned - and neither is the
|
|
727 |
# unknown path 'unknown' which it points at.
|
|
728 |
self.assertEqual(expected, self.do_iter_changes(tree1, tree2, |
|
729 |
specific_files=['added', 'changed', 'fromdir', 'fromfile', |
|
730 |
'removed', 'unchanged', 'todir', 'tofile'])) |
|
|
2255.7.15
by John Arbash Meinel
Try to create an intertree test that exposes the walkdir vs dirstate mismatch. No luck yet. |
731 |
|
732 |
def test_tree_with_special_names(self): |
|
733 |
tree1, tree2, paths, path_ids = self.make_tree_with_special_names() |
|
734 |
tree1.lock_read() |
|
735 |
self.addCleanup(tree1.unlock) |
|
736 |
tree2.lock_read() |
|
737 |
self.addCleanup(tree2.unlock) |
|
738 |
expected = sorted(self.added(tree2, f_id) for f_id in path_ids) |
|
739 |
self.assertEqual(expected, self.do_iter_changes(tree1, tree2)) |