3566.1.2
by Aaron Bentley
Fix copyright dates |
1 |
# Copyright (C) 2006, 2007, 2008 Canonical Ltd
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
1534.7.106
by Aaron Bentley
Cleaned up imports, added copyright statements |
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.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
1534.7.106
by Aaron Bentley
Cleaned up imports, added copyright statements |
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.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
1534.7.106
by Aaron Bentley
Cleaned up imports, added copyright statements |
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 |
import os |
|
2027.1.1
by John Arbash Meinel
Fix bug #56549, and write a direct test that the right path is being statted |
18 |
import stat |
3008.1.1
by Aaron Bentley
Start work allowing previews of transforms |
19 |
from StringIO import StringIO |
2027.1.1
by John Arbash Meinel
Fix bug #56549, and write a direct test that the right path is being statted |
20 |
import sys |
1558.1.3
by Aaron Bentley
Fixed deprecated op use in test suite |
21 |
|
2027.1.1
by John Arbash Meinel
Fix bug #56549, and write a direct test that the right path is being statted |
22 |
from bzrlib import ( |
2090.2.1
by Martin Pool
Fix some code which relies on assertions and breaks under python -O |
23 |
errors, |
2116.4.1
by John Arbash Meinel
Update file and revision id generators. |
24 |
generate_ids, |
3199.1.4
by Vincent Ladeuil
Fix 16 leaked tmp dirs. Probably indicates a lock handling problem with TransformPreview |
25 |
osutils, |
3008.1.17
by Aaron Bentley
Test unused parameters of preview_tree._iter_changes |
26 |
progress, |
3008.1.18
by Aaron Bentley
Get supported PreviewTree functionality under test |
27 |
revision as _mod_revision, |
2255.7.48
by Robert Collins
Deprecated and make work with DirState trees 'transform.find_interesting'. |
28 |
symbol_versioning, |
2027.1.1
by John Arbash Meinel
Fix bug #56549, and write a direct test that the right path is being statted |
29 |
tests, |
30 |
urlutils, |
|
31 |
)
|
|
1558.1.3
by Aaron Bentley
Fixed deprecated op use in test suite |
32 |
from bzrlib.bzrdir import BzrDir |
1534.10.24
by Aaron Bentley
Eliminated conflicts_to_strings, made remove_files a ConflictList member |
33 |
from bzrlib.conflicts import (DuplicateEntry, DuplicateID, MissingParent, |
3144.4.2
by Aaron Bentley
Handle non-directory parent conflicts (abentley, #177390) |
34 |
UnversionedParent, ParentLoop, DeletingParent, |
35 |
NonDirectoryParent) |
|
3008.1.1
by Aaron Bentley
Start work allowing previews of transforms |
36 |
from bzrlib.diff import show_diff_trees |
1534.7.32
by Aaron Bentley
Got conflict handling working when conflicts involve existing files |
37 |
from bzrlib.errors import (DuplicateKey, MalformedTransform, NoSuchFile, |
1551.7.17
by Aaron Bentley
Switch to PathsNotVersioned, accept extra_trees |
38 |
ReusingTransform, CantMoveRoot, |
39 |
PathsNotVersionedError, ExistingLimbo, |
|
2733.2.11
by Aaron Bentley
Detect irregularities with the pending-deletion directory |
40 |
ExistingPendingDeletion, ImmortalLimbo, |
41 |
ImmortalPendingDeletion, LockError) |
|
2949.5.1
by Alexander Belchenko
selftest: use SymlinkFeature instead of TestSkipped where appropriate |
42 |
from bzrlib.osutils import file_kind, pathjoin |
1534.7.140
by Aaron Bentley
Moved the merge stuff into merge.py |
43 |
from bzrlib.merge import Merge3Merger |
2949.5.1
by Alexander Belchenko
selftest: use SymlinkFeature instead of TestSkipped where appropriate |
44 |
from bzrlib.tests import ( |
3063.1.1
by Alexander Belchenko
Catch OSError 17 (file exists) in final phase of tree transform and show filename to user (#111758). |
45 |
CaseInsensitiveFilesystemFeature, |
3136.1.1
by Aaron Bentley
Add support for hardlinks to TreeTransform |
46 |
HardlinkFeature, |
2949.5.1
by Alexander Belchenko
selftest: use SymlinkFeature instead of TestSkipped where appropriate |
47 |
SymlinkFeature, |
48 |
TestCase, |
|
49 |
TestCaseInTempDir, |
|
50 |
TestSkipped, |
|
51 |
)
|
|
1534.7.106
by Aaron Bentley
Cleaned up imports, added copyright statements |
52 |
from bzrlib.transform import (TreeTransform, ROOT_PARENT, FinalPaths, |
1534.7.170
by Aaron Bentley
Cleaned up filesystem conflict handling |
53 |
resolve_conflicts, cook_conflicts, |
3400.3.6
by Martin Pool
Remove code deprecated prior to 1.1 and its tests |
54 |
build_tree, get_backup_name, |
55 |
_FileMover, resolve_checkout, |
|
3008.1.13
by Michael Hudson
merge bzr.dev |
56 |
TransformPreview) |
1534.7.1
by Aaron Bentley
Got creation of a versioned file working |
57 |
|
2100.3.21
by Aaron Bentley
Work on checking out by-reference trees |
58 |
class TestTreeTransform(tests.TestCaseWithTransport): |
1740.2.4
by Aaron Bentley
Update transform tests and docs |
59 |
|
1534.7.59
by Aaron Bentley
Simplified tests |
60 |
def setUp(self): |
61 |
super(TestTreeTransform, self).setUp() |
|
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
62 |
self.wt = self.make_branch_and_tree('.', format='dirstate-with-subtree') |
1534.7.161
by Aaron Bentley
Used appropriate control_files |
63 |
os.chdir('..') |
1534.7.59
by Aaron Bentley
Simplified tests |
64 |
|
65 |
def get_transform(self): |
|
66 |
transform = TreeTransform(self.wt) |
|
3453.2.7
by Aaron Bentley
Remove test kipple |
67 |
self.addCleanup(transform.finalize) |
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
68 |
return transform, transform.root |
1534.7.59
by Aaron Bentley
Simplified tests |
69 |
|
1534.7.162
by Aaron Bentley
Handle failures creating/deleting the Limbo directory |
70 |
def test_existing_limbo(self): |
71 |
transform, root = self.get_transform() |
|
2733.2.6
by Aaron Bentley
Make TreeTransform commits rollbackable |
72 |
limbo_name = transform._limbodir |
73 |
deletion_path = transform._deletiondir |
|
1534.7.176
by abentley
Fixed up tests for Windows |
74 |
os.mkdir(pathjoin(limbo_name, 'hehe')) |
1534.7.162
by Aaron Bentley
Handle failures creating/deleting the Limbo directory |
75 |
self.assertRaises(ImmortalLimbo, transform.apply) |
76 |
self.assertRaises(LockError, self.wt.unlock) |
|
77 |
self.assertRaises(ExistingLimbo, self.get_transform) |
|
78 |
self.assertRaises(LockError, self.wt.unlock) |
|
1534.7.176
by abentley
Fixed up tests for Windows |
79 |
os.rmdir(pathjoin(limbo_name, 'hehe')) |
1534.7.162
by Aaron Bentley
Handle failures creating/deleting the Limbo directory |
80 |
os.rmdir(limbo_name) |
2733.2.6
by Aaron Bentley
Make TreeTransform commits rollbackable |
81 |
os.rmdir(deletion_path) |
1534.7.162
by Aaron Bentley
Handle failures creating/deleting the Limbo directory |
82 |
transform, root = self.get_transform() |
83 |
transform.apply() |
|
1534.7.59
by Aaron Bentley
Simplified tests |
84 |
|
2733.2.11
by Aaron Bentley
Detect irregularities with the pending-deletion directory |
85 |
def test_existing_pending_deletion(self): |
86 |
transform, root = self.get_transform() |
|
87 |
deletion_path = self._limbodir = urlutils.local_path_from_url( |
|
3407.2.8
by Martin Pool
Deprecate LockableFiles.controlfilename |
88 |
transform._tree._transport.abspath('pending-deletion')) |
2733.2.11
by Aaron Bentley
Detect irregularities with the pending-deletion directory |
89 |
os.mkdir(pathjoin(deletion_path, 'blocking-directory')) |
90 |
self.assertRaises(ImmortalPendingDeletion, transform.apply) |
|
91 |
self.assertRaises(LockError, self.wt.unlock) |
|
92 |
self.assertRaises(ExistingPendingDeletion, self.get_transform) |
|
93 |
||
1534.7.1
by Aaron Bentley
Got creation of a versioned file working |
94 |
def test_build(self): |
3034.2.1
by Aaron Bentley
Fix is_executable tests for win32 |
95 |
transform, root = self.get_transform() |
96 |
self.wt.lock_tree_write() |
|
97 |
self.addCleanup(self.wt.unlock) |
|
1534.7.59
by Aaron Bentley
Simplified tests |
98 |
self.assertIs(transform.get_tree_parent(root), ROOT_PARENT) |
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
99 |
imaginary_id = transform.trans_id_tree_path('imaginary') |
1534.10.32
by Aaron Bentley
Test and fix case where name has trailing slash |
100 |
imaginary_id2 = transform.trans_id_tree_path('imaginary/') |
101 |
self.assertEqual(imaginary_id, imaginary_id2) |
|
1534.7.59
by Aaron Bentley
Simplified tests |
102 |
self.assertEqual(transform.get_tree_parent(imaginary_id), root) |
103 |
self.assertEqual(transform.final_kind(root), 'directory') |
|
104 |
self.assertEqual(transform.final_file_id(root), self.wt.get_root_id()) |
|
105 |
trans_id = transform.create_path('name', root) |
|
106 |
self.assertIs(transform.final_file_id(trans_id), None) |
|
107 |
self.assertRaises(NoSuchFile, transform.final_kind, trans_id) |
|
108 |
transform.create_file('contents', trans_id) |
|
109 |
transform.set_executability(True, trans_id) |
|
110 |
transform.version_file('my_pretties', trans_id) |
|
111 |
self.assertRaises(DuplicateKey, transform.version_file, |
|
112 |
'my_pretties', trans_id) |
|
113 |
self.assertEqual(transform.final_file_id(trans_id), 'my_pretties') |
|
114 |
self.assertEqual(transform.final_parent(trans_id), root) |
|
115 |
self.assertIs(transform.final_parent(root), ROOT_PARENT) |
|
116 |
self.assertIs(transform.get_tree_parent(root), ROOT_PARENT) |
|
117 |
oz_id = transform.create_path('oz', root) |
|
118 |
transform.create_directory(oz_id) |
|
119 |
transform.version_file('ozzie', oz_id) |
|
120 |
trans_id2 = transform.create_path('name2', root) |
|
121 |
transform.create_file('contents', trans_id2) |
|
122 |
transform.set_executability(False, trans_id2) |
|
123 |
transform.version_file('my_pretties2', trans_id2) |
|
1534.7.191
by Aaron Bentley
Got transform.apply to list modified paths |
124 |
modified_paths = transform.apply().modified_paths |
1534.7.100
by Aaron Bentley
Fixed path-relative test cases |
125 |
self.assertEqual('contents', self.wt.get_file_byname('name').read()) |
1534.7.59
by Aaron Bentley
Simplified tests |
126 |
self.assertEqual(self.wt.path2id('name'), 'my_pretties') |
127 |
self.assertIs(self.wt.is_executable('my_pretties'), True) |
|
128 |
self.assertIs(self.wt.is_executable('my_pretties2'), False) |
|
1534.7.100
by Aaron Bentley
Fixed path-relative test cases |
129 |
self.assertEqual('directory', file_kind(self.wt.abspath('oz'))) |
1534.7.191
by Aaron Bentley
Got transform.apply to list modified paths |
130 |
self.assertEqual(len(modified_paths), 3) |
131 |
tree_mod_paths = [self.wt.id2abspath(f) for f in |
|
132 |
('ozzie', 'my_pretties', 'my_pretties2')] |
|
133 |
self.assertSubset(tree_mod_paths, modified_paths) |
|
1534.7.1
by Aaron Bentley
Got creation of a versioned file working |
134 |
# is it safe to finalize repeatedly?
|
135 |
transform.finalize() |
|
1534.7.59
by Aaron Bentley
Simplified tests |
136 |
transform.finalize() |
1534.7.2
by Aaron Bentley
Added convenience function |
137 |
|
3136.1.1
by Aaron Bentley
Add support for hardlinks to TreeTransform |
138 |
def test_hardlink(self): |
139 |
self.requireFeature(HardlinkFeature) |
|
140 |
transform, root = self.get_transform() |
|
141 |
transform.new_file('file1', root, 'contents') |
|
142 |
transform.apply() |
|
143 |
target = self.make_branch_and_tree('target') |
|
144 |
target_transform = TreeTransform(target) |
|
145 |
trans_id = target_transform.create_path('file1', target_transform.root) |
|
146 |
target_transform.create_hardlink(self.wt.abspath('file1'), trans_id) |
|
147 |
target_transform.apply() |
|
148 |
self.failUnlessExists('target/file1') |
|
149 |
source_stat = os.stat(self.wt.abspath('file1')) |
|
150 |
target_stat = os.stat('target/file1') |
|
151 |
self.assertEqual(source_stat, target_stat) |
|
152 |
||
1534.7.2
by Aaron Bentley
Added convenience function |
153 |
def test_convenience(self): |
1534.7.59
by Aaron Bentley
Simplified tests |
154 |
transform, root = self.get_transform() |
3034.2.1
by Aaron Bentley
Fix is_executable tests for win32 |
155 |
self.wt.lock_tree_write() |
156 |
self.addCleanup(self.wt.unlock) |
|
1534.7.59
by Aaron Bentley
Simplified tests |
157 |
trans_id = transform.new_file('name', root, 'contents', |
158 |
'my_pretties', True) |
|
159 |
oz = transform.new_directory('oz', root, 'oz-id') |
|
160 |
dorothy = transform.new_directory('dorothy', oz, 'dorothy-id') |
|
161 |
toto = transform.new_file('toto', dorothy, 'toto-contents', |
|
162 |
'toto-id', False) |
|
163 |
||
164 |
self.assertEqual(len(transform.find_conflicts()), 0) |
|
165 |
transform.apply() |
|
166 |
self.assertRaises(ReusingTransform, transform.find_conflicts) |
|
1534.7.100
by Aaron Bentley
Fixed path-relative test cases |
167 |
self.assertEqual('contents', file(self.wt.abspath('name')).read()) |
1534.7.59
by Aaron Bentley
Simplified tests |
168 |
self.assertEqual(self.wt.path2id('name'), 'my_pretties') |
169 |
self.assertIs(self.wt.is_executable('my_pretties'), True) |
|
170 |
self.assertEqual(self.wt.path2id('oz'), 'oz-id') |
|
171 |
self.assertEqual(self.wt.path2id('oz/dorothy'), 'dorothy-id') |
|
172 |
self.assertEqual(self.wt.path2id('oz/dorothy/toto'), 'toto-id') |
|
173 |
||
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
174 |
self.assertEqual('toto-contents', |
1534.7.100
by Aaron Bentley
Fixed path-relative test cases |
175 |
self.wt.get_file_byname('oz/dorothy/toto').read()) |
1534.7.59
by Aaron Bentley
Simplified tests |
176 |
self.assertIs(self.wt.is_executable('toto-id'), False) |
1534.7.6
by Aaron Bentley
Added conflict handling |
177 |
|
2100.3.21
by Aaron Bentley
Work on checking out by-reference trees |
178 |
def test_tree_reference(self): |
179 |
transform, root = self.get_transform() |
|
180 |
tree = transform._tree |
|
181 |
trans_id = transform.new_directory('reference', root, 'subtree-id') |
|
182 |
transform.set_tree_reference('subtree-revision', trans_id) |
|
183 |
transform.apply() |
|
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
184 |
tree.lock_read() |
185 |
self.addCleanup(tree.unlock) |
|
186 |
self.assertEqual('subtree-revision', |
|
2100.3.21
by Aaron Bentley
Work on checking out by-reference trees |
187 |
tree.inventory['subtree-id'].reference_revision) |
188 |
||
1534.7.6
by Aaron Bentley
Added conflict handling |
189 |
def test_conflicts(self): |
1534.7.59
by Aaron Bentley
Simplified tests |
190 |
transform, root = self.get_transform() |
191 |
trans_id = transform.new_file('name', root, 'contents', |
|
192 |
'my_pretties') |
|
193 |
self.assertEqual(len(transform.find_conflicts()), 0) |
|
194 |
trans_id2 = transform.new_file('name', root, 'Crontents', 'toto') |
|
195 |
self.assertEqual(transform.find_conflicts(), |
|
196 |
[('duplicate', trans_id, trans_id2, 'name')]) |
|
197 |
self.assertRaises(MalformedTransform, transform.apply) |
|
198 |
transform.adjust_path('name', trans_id, trans_id2) |
|
199 |
self.assertEqual(transform.find_conflicts(), |
|
200 |
[('non-directory parent', trans_id)]) |
|
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
201 |
tinman_id = transform.trans_id_tree_path('tinman') |
1534.7.59
by Aaron Bentley
Simplified tests |
202 |
transform.adjust_path('name', tinman_id, trans_id2) |
203 |
self.assertEqual(transform.find_conflicts(), |
|
204 |
[('unversioned parent', tinman_id), |
|
205 |
('missing parent', tinman_id)]) |
|
206 |
lion_id = transform.create_path('lion', root) |
|
207 |
self.assertEqual(transform.find_conflicts(), |
|
208 |
[('unversioned parent', tinman_id), |
|
209 |
('missing parent', tinman_id)]) |
|
210 |
transform.adjust_path('name', lion_id, trans_id2) |
|
211 |
self.assertEqual(transform.find_conflicts(), |
|
212 |
[('unversioned parent', lion_id), |
|
213 |
('missing parent', lion_id)]) |
|
214 |
transform.version_file("Courage", lion_id) |
|
215 |
self.assertEqual(transform.find_conflicts(), |
|
216 |
[('missing parent', lion_id), |
|
217 |
('versioning no contents', lion_id)]) |
|
218 |
transform.adjust_path('name2', root, trans_id2) |
|
219 |
self.assertEqual(transform.find_conflicts(), |
|
220 |
[('versioning no contents', lion_id)]) |
|
221 |
transform.create_file('Contents, okay?', lion_id) |
|
222 |
transform.adjust_path('name2', trans_id2, trans_id2) |
|
223 |
self.assertEqual(transform.find_conflicts(), |
|
224 |
[('parent loop', trans_id2), |
|
225 |
('non-directory parent', trans_id2)]) |
|
226 |
transform.adjust_path('name2', root, trans_id2) |
|
227 |
oz_id = transform.new_directory('oz', root) |
|
228 |
transform.set_executability(True, oz_id) |
|
229 |
self.assertEqual(transform.find_conflicts(), |
|
230 |
[('unversioned executability', oz_id)]) |
|
231 |
transform.version_file('oz-id', oz_id) |
|
232 |
self.assertEqual(transform.find_conflicts(), |
|
233 |
[('non-file executability', oz_id)]) |
|
234 |
transform.set_executability(None, oz_id) |
|
1534.7.71
by abentley
All tests pass under Windows |
235 |
tip_id = transform.new_file('tip', oz_id, 'ozma', 'tip-id') |
1534.7.59
by Aaron Bentley
Simplified tests |
236 |
transform.apply() |
237 |
self.assertEqual(self.wt.path2id('name'), 'my_pretties') |
|
238 |
self.assertEqual('contents', file(self.wt.abspath('name')).read()) |
|
239 |
transform2, root = self.get_transform() |
|
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
240 |
oz_id = transform2.trans_id_tree_file_id('oz-id') |
1534.7.59
by Aaron Bentley
Simplified tests |
241 |
newtip = transform2.new_file('tip', oz_id, 'other', 'tip-id') |
242 |
result = transform2.find_conflicts() |
|
1534.7.135
by Aaron Bentley
Fixed deletion handling |
243 |
fp = FinalPaths(transform2) |
1534.7.59
by Aaron Bentley
Simplified tests |
244 |
self.assert_('oz/tip' in transform2._tree_path_ids) |
1534.7.176
by abentley
Fixed up tests for Windows |
245 |
self.assertEqual(fp.get_path(newtip), pathjoin('oz', 'tip')) |
1534.7.59
by Aaron Bentley
Simplified tests |
246 |
self.assertEqual(len(result), 2) |
247 |
self.assertEqual((result[0][0], result[0][1]), |
|
248 |
('duplicate', newtip)) |
|
249 |
self.assertEqual((result[1][0], result[1][2]), |
|
250 |
('duplicate id', newtip)) |
|
1534.7.73
by Aaron Bentley
Changed model again. Now iterator is used immediately. |
251 |
transform2.finalize() |
1534.7.59
by Aaron Bentley
Simplified tests |
252 |
transform3 = TreeTransform(self.wt) |
253 |
self.addCleanup(transform3.finalize) |
|
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
254 |
oz_id = transform3.trans_id_tree_file_id('oz-id') |
1534.7.59
by Aaron Bentley
Simplified tests |
255 |
transform3.delete_contents(oz_id) |
256 |
self.assertEqual(transform3.find_conflicts(), |
|
257 |
[('missing parent', oz_id)]) |
|
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
258 |
root_id = transform3.root |
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
259 |
tip_id = transform3.trans_id_tree_file_id('tip-id') |
1534.7.59
by Aaron Bentley
Simplified tests |
260 |
transform3.adjust_path('tip', root_id, tip_id) |
261 |
transform3.apply() |
|
1534.7.36
by Aaron Bentley
Added rename tests |
262 |
|
3034.4.1
by Aaron Bentley
Start handling case-insensitivity |
263 |
def test_conflict_on_case_insensitive(self): |
264 |
tree = self.make_branch_and_tree('tree') |
|
265 |
# Don't try this at home, kids!
|
|
266 |
# Force the tree to report that it is case sensitive, for conflict
|
|
267 |
# resolution tests
|
|
268 |
tree.case_sensitive = True |
|
269 |
transform = TreeTransform(tree) |
|
270 |
self.addCleanup(transform.finalize) |
|
271 |
transform.new_file('file', transform.root, 'content') |
|
272 |
transform.new_file('FiLe', transform.root, 'content') |
|
273 |
result = transform.find_conflicts() |
|
274 |
self.assertEqual([], result) |
|
3008.1.15
by Aaron Bentley
Make case_sensitive an aspect of the transform, not the source tree |
275 |
transform.finalize() |
3034.4.1
by Aaron Bentley
Start handling case-insensitivity |
276 |
# Force the tree to report that it is case insensitive, for conflict
|
277 |
# generation tests
|
|
278 |
tree.case_sensitive = False |
|
3008.1.15
by Aaron Bentley
Make case_sensitive an aspect of the transform, not the source tree |
279 |
transform = TreeTransform(tree) |
280 |
self.addCleanup(transform.finalize) |
|
281 |
transform.new_file('file', transform.root, 'content') |
|
282 |
transform.new_file('FiLe', transform.root, 'content') |
|
3034.4.1
by Aaron Bentley
Start handling case-insensitivity |
283 |
result = transform.find_conflicts() |
284 |
self.assertEqual([('duplicate', 'new-1', 'new-2', 'file')], result) |
|
285 |
||
3034.4.7
by Aaron Bentley
Add test for filename conflicts with existing files |
286 |
def test_conflict_on_case_insensitive_existing(self): |
287 |
tree = self.make_branch_and_tree('tree') |
|
288 |
self.build_tree(['tree/FiLe']) |
|
289 |
# Don't try this at home, kids!
|
|
290 |
# Force the tree to report that it is case sensitive, for conflict
|
|
291 |
# resolution tests
|
|
292 |
tree.case_sensitive = True |
|
293 |
transform = TreeTransform(tree) |
|
294 |
self.addCleanup(transform.finalize) |
|
295 |
transform.new_file('file', transform.root, 'content') |
|
296 |
result = transform.find_conflicts() |
|
297 |
self.assertEqual([], result) |
|
3008.1.15
by Aaron Bentley
Make case_sensitive an aspect of the transform, not the source tree |
298 |
transform.finalize() |
3034.4.7
by Aaron Bentley
Add test for filename conflicts with existing files |
299 |
# Force the tree to report that it is case insensitive, for conflict
|
300 |
# generation tests
|
|
301 |
tree.case_sensitive = False |
|
3008.1.15
by Aaron Bentley
Make case_sensitive an aspect of the transform, not the source tree |
302 |
transform = TreeTransform(tree) |
303 |
self.addCleanup(transform.finalize) |
|
304 |
transform.new_file('file', transform.root, 'content') |
|
3034.4.7
by Aaron Bentley
Add test for filename conflicts with existing files |
305 |
result = transform.find_conflicts() |
306 |
self.assertEqual([('duplicate', 'new-1', 'new-2', 'file')], result) |
|
307 |
||
3034.4.1
by Aaron Bentley
Start handling case-insensitivity |
308 |
def test_resolve_case_insensitive_conflict(self): |
309 |
tree = self.make_branch_and_tree('tree') |
|
310 |
# Don't try this at home, kids!
|
|
311 |
# Force the tree to report that it is case insensitive, for conflict
|
|
312 |
# resolution tests
|
|
313 |
tree.case_sensitive = False |
|
314 |
transform = TreeTransform(tree) |
|
315 |
self.addCleanup(transform.finalize) |
|
316 |
transform.new_file('file', transform.root, 'content') |
|
317 |
transform.new_file('FiLe', transform.root, 'content') |
|
318 |
resolve_conflicts(transform) |
|
319 |
transform.apply() |
|
320 |
self.failUnlessExists('tree/file') |
|
321 |
self.failUnlessExists('tree/FiLe.moved') |
|
322 |
||
3034.4.2
by Aaron Bentley
Get conflict handling and case-insensitive tree creation under test |
323 |
def test_resolve_checkout_case_conflict(self): |
3034.4.1
by Aaron Bentley
Start handling case-insensitivity |
324 |
tree = self.make_branch_and_tree('tree') |
325 |
# Don't try this at home, kids!
|
|
326 |
# Force the tree to report that it is case insensitive, for conflict
|
|
327 |
# resolution tests
|
|
328 |
tree.case_sensitive = False |
|
329 |
transform = TreeTransform(tree) |
|
330 |
self.addCleanup(transform.finalize) |
|
331 |
transform.new_file('file', transform.root, 'content') |
|
332 |
transform.new_file('FiLe', transform.root, 'content') |
|
3034.4.2
by Aaron Bentley
Get conflict handling and case-insensitive tree creation under test |
333 |
resolve_conflicts(transform, |
334 |
pass_func=lambda t, c: resolve_checkout(t, c, [])) |
|
3034.4.1
by Aaron Bentley
Start handling case-insensitivity |
335 |
transform.apply() |
336 |
self.failUnlessExists('tree/file') |
|
337 |
self.failUnlessExists('tree/FiLe.moved') |
|
338 |
||
3034.4.2
by Aaron Bentley
Get conflict handling and case-insensitive tree creation under test |
339 |
def test_apply_case_conflict(self): |
3034.4.6
by Aaron Bentley
Update apply_case_conflict tests |
340 |
"""Ensure that a transform with case conflicts can always be applied"""
|
3034.4.2
by Aaron Bentley
Get conflict handling and case-insensitive tree creation under test |
341 |
tree = self.make_branch_and_tree('tree') |
342 |
transform = TreeTransform(tree) |
|
343 |
self.addCleanup(transform.finalize) |
|
344 |
transform.new_file('file', transform.root, 'content') |
|
345 |
transform.new_file('FiLe', transform.root, 'content') |
|
3034.4.6
by Aaron Bentley
Update apply_case_conflict tests |
346 |
dir = transform.new_directory('dir', transform.root) |
347 |
transform.new_file('dirfile', dir, 'content') |
|
348 |
transform.new_file('dirFiLe', dir, 'content') |
|
349 |
resolve_conflicts(transform) |
|
3034.4.2
by Aaron Bentley
Get conflict handling and case-insensitive tree creation under test |
350 |
transform.apply() |
3034.4.3
by Aaron Bentley
Add case-sensitivity handling to WorkingTree |
351 |
self.failUnlessExists('tree/file') |
352 |
if not os.path.exists('tree/FiLe.moved'): |
|
353 |
self.failUnlessExists('tree/FiLe') |
|
3034.4.6
by Aaron Bentley
Update apply_case_conflict tests |
354 |
self.failUnlessExists('tree/dir/dirfile') |
355 |
if not os.path.exists('tree/dir/dirFiLe.moved'): |
|
356 |
self.failUnlessExists('tree/dir/dirFiLe') |
|
3034.4.2
by Aaron Bentley
Get conflict handling and case-insensitive tree creation under test |
357 |
|
3034.4.1
by Aaron Bentley
Start handling case-insensitivity |
358 |
def test_case_insensitive_limbo(self): |
359 |
tree = self.make_branch_and_tree('tree') |
|
360 |
# Don't try this at home, kids!
|
|
361 |
# Force the tree to report that it is case insensitive
|
|
362 |
tree.case_sensitive = False |
|
363 |
transform = TreeTransform(tree) |
|
364 |
self.addCleanup(transform.finalize) |
|
365 |
dir = transform.new_directory('dir', transform.root) |
|
366 |
first = transform.new_file('file', dir, 'content') |
|
367 |
second = transform.new_file('FiLe', dir, 'content') |
|
368 |
self.assertContainsRe(transform._limbo_name(first), 'new-1/file') |
|
369 |
self.assertNotContainsRe(transform._limbo_name(second), 'new-1/FiLe') |
|
370 |
||
1558.7.11
by Aaron Bentley
Avoid spurious conflict on add/delete |
371 |
def test_add_del(self): |
372 |
start, root = self.get_transform() |
|
373 |
start.new_directory('a', root, 'a') |
|
374 |
start.apply() |
|
375 |
transform, root = self.get_transform() |
|
376 |
transform.delete_versioned(transform.trans_id_tree_file_id('a')) |
|
377 |
transform.new_directory('a', root, 'a') |
|
378 |
transform.apply() |
|
379 |
||
1534.7.46
by Aaron Bentley
Ensured a conflict when parents of versioned files are unversioned |
380 |
def test_unversioning(self): |
1534.7.59
by Aaron Bentley
Simplified tests |
381 |
create_tree, root = self.get_transform() |
382 |
parent_id = create_tree.new_directory('parent', root, 'parent-id') |
|
383 |
create_tree.new_file('child', parent_id, 'child', 'child-id') |
|
384 |
create_tree.apply() |
|
385 |
unversion = TreeTransform(self.wt) |
|
386 |
self.addCleanup(unversion.finalize) |
|
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
387 |
parent = unversion.trans_id_tree_path('parent') |
1534.7.59
by Aaron Bentley
Simplified tests |
388 |
unversion.unversion_file(parent) |
389 |
self.assertEqual(unversion.find_conflicts(), |
|
390 |
[('unversioned parent', parent_id)]) |
|
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
391 |
file_id = unversion.trans_id_tree_file_id('child-id') |
1534.7.59
by Aaron Bentley
Simplified tests |
392 |
unversion.unversion_file(file_id) |
393 |
unversion.apply() |
|
1534.7.46
by Aaron Bentley
Ensured a conflict when parents of versioned files are unversioned |
394 |
|
1534.7.36
by Aaron Bentley
Added rename tests |
395 |
def test_name_invariants(self): |
1534.7.59
by Aaron Bentley
Simplified tests |
396 |
create_tree, root = self.get_transform() |
397 |
# prepare tree
|
|
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
398 |
root = create_tree.root |
1534.7.59
by Aaron Bentley
Simplified tests |
399 |
create_tree.new_file('name1', root, 'hello1', 'name1') |
400 |
create_tree.new_file('name2', root, 'hello2', 'name2') |
|
401 |
ddir = create_tree.new_directory('dying_directory', root, 'ddir') |
|
402 |
create_tree.new_file('dying_file', ddir, 'goodbye1', 'dfile') |
|
403 |
create_tree.new_file('moving_file', ddir, 'later1', 'mfile') |
|
404 |
create_tree.new_file('moving_file2', root, 'later2', 'mfile2') |
|
405 |
create_tree.apply() |
|
406 |
||
407 |
mangle_tree,root = self.get_transform() |
|
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
408 |
root = mangle_tree.root |
1534.7.59
by Aaron Bentley
Simplified tests |
409 |
#swap names
|
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
410 |
name1 = mangle_tree.trans_id_tree_file_id('name1') |
411 |
name2 = mangle_tree.trans_id_tree_file_id('name2') |
|
1534.7.59
by Aaron Bentley
Simplified tests |
412 |
mangle_tree.adjust_path('name2', root, name1) |
413 |
mangle_tree.adjust_path('name1', root, name2) |
|
414 |
||
415 |
#tests for deleting parent directories
|
|
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
416 |
ddir = mangle_tree.trans_id_tree_file_id('ddir') |
1534.7.59
by Aaron Bentley
Simplified tests |
417 |
mangle_tree.delete_contents(ddir) |
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
418 |
dfile = mangle_tree.trans_id_tree_file_id('dfile') |
1534.7.59
by Aaron Bentley
Simplified tests |
419 |
mangle_tree.delete_versioned(dfile) |
420 |
mangle_tree.unversion_file(dfile) |
|
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
421 |
mfile = mangle_tree.trans_id_tree_file_id('mfile') |
1534.7.59
by Aaron Bentley
Simplified tests |
422 |
mangle_tree.adjust_path('mfile', root, mfile) |
423 |
||
424 |
#tests for adding parent directories
|
|
425 |
newdir = mangle_tree.new_directory('new_directory', root, 'newdir') |
|
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
426 |
mfile2 = mangle_tree.trans_id_tree_file_id('mfile2') |
1534.7.59
by Aaron Bentley
Simplified tests |
427 |
mangle_tree.adjust_path('mfile2', newdir, mfile2) |
428 |
mangle_tree.new_file('newfile', newdir, 'hello3', 'dfile') |
|
429 |
self.assertEqual(mangle_tree.final_file_id(mfile2), 'mfile2') |
|
430 |
self.assertEqual(mangle_tree.final_parent(mfile2), newdir) |
|
431 |
self.assertEqual(mangle_tree.final_file_id(mfile2), 'mfile2') |
|
432 |
mangle_tree.apply() |
|
433 |
self.assertEqual(file(self.wt.abspath('name1')).read(), 'hello2') |
|
434 |
self.assertEqual(file(self.wt.abspath('name2')).read(), 'hello1') |
|
1534.7.176
by abentley
Fixed up tests for Windows |
435 |
mfile2_path = self.wt.abspath(pathjoin('new_directory','mfile2')) |
1534.7.41
by Aaron Bentley
Got inventory ID movement working |
436 |
self.assertEqual(mangle_tree.final_parent(mfile2), newdir) |
1534.7.38
by Aaron Bentley
Tested adding paths |
437 |
self.assertEqual(file(mfile2_path).read(), 'later2') |
1534.7.59
by Aaron Bentley
Simplified tests |
438 |
self.assertEqual(self.wt.id2path('mfile2'), 'new_directory/mfile2') |
439 |
self.assertEqual(self.wt.path2id('new_directory/mfile2'), 'mfile2') |
|
1534.7.176
by abentley
Fixed up tests for Windows |
440 |
newfile_path = self.wt.abspath(pathjoin('new_directory','newfile')) |
1534.7.38
by Aaron Bentley
Tested adding paths |
441 |
self.assertEqual(file(newfile_path).read(), 'hello3') |
1534.7.59
by Aaron Bentley
Simplified tests |
442 |
self.assertEqual(self.wt.path2id('dying_directory'), 'ddir') |
443 |
self.assertIs(self.wt.path2id('dying_directory/dying_file'), None) |
|
1534.7.176
by abentley
Fixed up tests for Windows |
444 |
mfile2_path = self.wt.abspath(pathjoin('new_directory','mfile2')) |
1534.7.43
by abentley
Fixed some Windows bugs, introduced a conflicts bug |
445 |
|
1534.7.150
by Aaron Bentley
Handled simultaneous renames of parent and child better |
446 |
def test_both_rename(self): |
447 |
create_tree,root = self.get_transform() |
|
448 |
newdir = create_tree.new_directory('selftest', root, 'selftest-id') |
|
449 |
create_tree.new_file('blackbox.py', newdir, 'hello1', 'blackbox-id') |
|
450 |
create_tree.apply() |
|
451 |
mangle_tree,root = self.get_transform() |
|
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
452 |
selftest = mangle_tree.trans_id_tree_file_id('selftest-id') |
453 |
blackbox = mangle_tree.trans_id_tree_file_id('blackbox-id') |
|
1534.7.150
by Aaron Bentley
Handled simultaneous renames of parent and child better |
454 |
mangle_tree.adjust_path('test', root, selftest) |
455 |
mangle_tree.adjust_path('test_too_much', root, selftest) |
|
456 |
mangle_tree.set_executability(True, blackbox) |
|
457 |
mangle_tree.apply() |
|
458 |
||
459 |
def test_both_rename2(self): |
|
460 |
create_tree,root = self.get_transform() |
|
461 |
bzrlib = create_tree.new_directory('bzrlib', root, 'bzrlib-id') |
|
462 |
tests = create_tree.new_directory('tests', bzrlib, 'tests-id') |
|
463 |
blackbox = create_tree.new_directory('blackbox', tests, 'blackbox-id') |
|
464 |
create_tree.new_file('test_too_much.py', blackbox, 'hello1', |
|
465 |
'test_too_much-id') |
|
466 |
create_tree.apply() |
|
467 |
mangle_tree,root = self.get_transform() |
|
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
468 |
bzrlib = mangle_tree.trans_id_tree_file_id('bzrlib-id') |
469 |
tests = mangle_tree.trans_id_tree_file_id('tests-id') |
|
470 |
test_too_much = mangle_tree.trans_id_tree_file_id('test_too_much-id') |
|
1534.7.150
by Aaron Bentley
Handled simultaneous renames of parent and child better |
471 |
mangle_tree.adjust_path('selftest', bzrlib, tests) |
472 |
mangle_tree.adjust_path('blackbox.py', tests, test_too_much) |
|
473 |
mangle_tree.set_executability(True, test_too_much) |
|
474 |
mangle_tree.apply() |
|
475 |
||
476 |
def test_both_rename3(self): |
|
477 |
create_tree,root = self.get_transform() |
|
478 |
tests = create_tree.new_directory('tests', root, 'tests-id') |
|
479 |
create_tree.new_file('test_too_much.py', tests, 'hello1', |
|
480 |
'test_too_much-id') |
|
481 |
create_tree.apply() |
|
482 |
mangle_tree,root = self.get_transform() |
|
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
483 |
tests = mangle_tree.trans_id_tree_file_id('tests-id') |
484 |
test_too_much = mangle_tree.trans_id_tree_file_id('test_too_much-id') |
|
1534.7.150
by Aaron Bentley
Handled simultaneous renames of parent and child better |
485 |
mangle_tree.adjust_path('selftest', root, tests) |
486 |
mangle_tree.adjust_path('blackbox.py', tests, test_too_much) |
|
487 |
mangle_tree.set_executability(True, test_too_much) |
|
488 |
mangle_tree.apply() |
|
489 |
||
1534.7.48
by Aaron Bentley
Ensured we can move/rename dangling inventory entries |
490 |
def test_move_dangling_ie(self): |
1534.7.59
by Aaron Bentley
Simplified tests |
491 |
create_tree, root = self.get_transform() |
492 |
# prepare tree
|
|
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
493 |
root = create_tree.root |
1534.7.59
by Aaron Bentley
Simplified tests |
494 |
create_tree.new_file('name1', root, 'hello1', 'name1') |
495 |
create_tree.apply() |
|
496 |
delete_contents, root = self.get_transform() |
|
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
497 |
file = delete_contents.trans_id_tree_file_id('name1') |
1534.7.59
by Aaron Bentley
Simplified tests |
498 |
delete_contents.delete_contents(file) |
499 |
delete_contents.apply() |
|
500 |
move_id, root = self.get_transform() |
|
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
501 |
name1 = move_id.trans_id_tree_file_id('name1') |
1534.7.59
by Aaron Bentley
Simplified tests |
502 |
newdir = move_id.new_directory('dir', root, 'newdir') |
503 |
move_id.adjust_path('name2', newdir, name1) |
|
504 |
move_id.apply() |
|
1534.7.48
by Aaron Bentley
Ensured we can move/rename dangling inventory entries |
505 |
|
1534.7.50
by Aaron Bentley
Detect duplicate inventory ids |
506 |
def test_replace_dangling_ie(self): |
1534.7.59
by Aaron Bentley
Simplified tests |
507 |
create_tree, root = self.get_transform() |
508 |
# prepare tree
|
|
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
509 |
root = create_tree.root |
1534.7.59
by Aaron Bentley
Simplified tests |
510 |
create_tree.new_file('name1', root, 'hello1', 'name1') |
511 |
create_tree.apply() |
|
512 |
delete_contents = TreeTransform(self.wt) |
|
513 |
self.addCleanup(delete_contents.finalize) |
|
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
514 |
file = delete_contents.trans_id_tree_file_id('name1') |
1534.7.59
by Aaron Bentley
Simplified tests |
515 |
delete_contents.delete_contents(file) |
516 |
delete_contents.apply() |
|
517 |
delete_contents.finalize() |
|
518 |
replace = TreeTransform(self.wt) |
|
519 |
self.addCleanup(replace.finalize) |
|
520 |
name2 = replace.new_file('name2', root, 'hello2', 'name1') |
|
521 |
conflicts = replace.find_conflicts() |
|
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
522 |
name1 = replace.trans_id_tree_file_id('name1') |
1534.7.59
by Aaron Bentley
Simplified tests |
523 |
self.assertEqual(conflicts, [('duplicate id', name1, name2)]) |
524 |
resolve_conflicts(replace) |
|
525 |
replace.apply() |
|
1534.7.48
by Aaron Bentley
Ensured we can move/rename dangling inventory entries |
526 |
|
1534.7.43
by abentley
Fixed some Windows bugs, introduced a conflicts bug |
527 |
def test_symlinks(self): |
2949.5.1
by Alexander Belchenko
selftest: use SymlinkFeature instead of TestSkipped where appropriate |
528 |
self.requireFeature(SymlinkFeature) |
1534.7.59
by Aaron Bentley
Simplified tests |
529 |
transform,root = self.get_transform() |
530 |
oz_id = transform.new_directory('oz', root, 'oz-id') |
|
531 |
wizard = transform.new_symlink('wizard', oz_id, 'wizard-target', |
|
532 |
'wizard-id') |
|
533 |
wiz_id = transform.create_path('wizard2', oz_id) |
|
534 |
transform.create_symlink('behind_curtain', wiz_id) |
|
535 |
transform.version_file('wiz-id2', wiz_id) |
|
1534.7.71
by abentley
All tests pass under Windows |
536 |
transform.set_executability(True, wiz_id) |
537 |
self.assertEqual(transform.find_conflicts(), |
|
538 |
[('non-file executability', wiz_id)]) |
|
539 |
transform.set_executability(None, wiz_id) |
|
1534.7.59
by Aaron Bentley
Simplified tests |
540 |
transform.apply() |
541 |
self.assertEqual(self.wt.path2id('oz/wizard'), 'wizard-id') |
|
1534.7.100
by Aaron Bentley
Fixed path-relative test cases |
542 |
self.assertEqual(file_kind(self.wt.abspath('oz/wizard')), 'symlink') |
543 |
self.assertEqual(os.readlink(self.wt.abspath('oz/wizard2')), |
|
544 |
'behind_curtain') |
|
545 |
self.assertEqual(os.readlink(self.wt.abspath('oz/wizard')), |
|
546 |
'wizard-target') |
|
1534.7.60
by Aaron Bentley
Tested existing conflict resolution functionality |
547 |
|
3006.2.2
by Alexander Belchenko
tests added. |
548 |
def test_unable_create_symlink(self): |
549 |
def tt_helper(): |
|
550 |
wt = self.make_branch_and_tree('.') |
|
551 |
tt = TreeTransform(wt) # TreeTransform obtains write lock |
|
552 |
try: |
|
553 |
tt.new_symlink('foo', tt.root, 'bar') |
|
554 |
tt.apply() |
|
555 |
finally: |
|
556 |
wt.unlock() |
|
557 |
os_symlink = getattr(os, 'symlink', None) |
|
558 |
os.symlink = None |
|
559 |
try: |
|
560 |
err = self.assertRaises(errors.UnableCreateSymlink, tt_helper) |
|
561 |
self.assertEquals( |
|
562 |
"Unable to create symlink 'foo' on this platform", |
|
563 |
str(err)) |
|
564 |
finally: |
|
565 |
if os_symlink: |
|
566 |
os.symlink = os_symlink |
|
567 |
||
1534.7.170
by Aaron Bentley
Cleaned up filesystem conflict handling |
568 |
def get_conflicted(self): |
1534.7.60
by Aaron Bentley
Tested existing conflict resolution functionality |
569 |
create,root = self.get_transform() |
570 |
create.new_file('dorothy', root, 'dorothy', 'dorothy-id') |
|
1534.7.61
by Aaron Bentley
Handled parent loops, missing parents, unversioned parents |
571 |
oz = create.new_directory('oz', root, 'oz-id') |
572 |
create.new_directory('emeraldcity', oz, 'emerald-id') |
|
1534.7.60
by Aaron Bentley
Tested existing conflict resolution functionality |
573 |
create.apply() |
574 |
conflicts,root = self.get_transform() |
|
1534.7.65
by Aaron Bentley
Text cleaup/docs |
575 |
# set up duplicate entry, duplicate id
|
1534.7.60
by Aaron Bentley
Tested existing conflict resolution functionality |
576 |
new_dorothy = conflicts.new_file('dorothy', root, 'dorothy', |
577 |
'dorothy-id') |
|
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
578 |
old_dorothy = conflicts.trans_id_tree_file_id('dorothy-id') |
579 |
oz = conflicts.trans_id_tree_file_id('oz-id') |
|
1551.8.22
by Aaron Bentley
Improve message when OTHER deletes an in-use tree |
580 |
# set up DeletedParent parent conflict
|
1534.7.65
by Aaron Bentley
Text cleaup/docs |
581 |
conflicts.delete_versioned(oz) |
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
582 |
emerald = conflicts.trans_id_tree_file_id('emerald-id') |
1551.8.22
by Aaron Bentley
Improve message when OTHER deletes an in-use tree |
583 |
# set up MissingParent conflict
|
584 |
munchkincity = conflicts.trans_id_file_id('munchkincity-id') |
|
585 |
conflicts.adjust_path('munchkincity', root, munchkincity) |
|
586 |
conflicts.new_directory('auntem', munchkincity, 'auntem-id') |
|
1534.7.65
by Aaron Bentley
Text cleaup/docs |
587 |
# set up parent loop
|
1534.7.61
by Aaron Bentley
Handled parent loops, missing parents, unversioned parents |
588 |
conflicts.adjust_path('emeraldcity', emerald, emerald) |
1534.7.170
by Aaron Bentley
Cleaned up filesystem conflict handling |
589 |
return conflicts, emerald, oz, old_dorothy, new_dorothy |
590 |
||
591 |
def test_conflict_resolution(self): |
|
592 |
conflicts, emerald, oz, old_dorothy, new_dorothy =\ |
|
593 |
self.get_conflicted() |
|
1534.7.60
by Aaron Bentley
Tested existing conflict resolution functionality |
594 |
resolve_conflicts(conflicts) |
595 |
self.assertEqual(conflicts.final_name(old_dorothy), 'dorothy.moved') |
|
596 |
self.assertIs(conflicts.final_file_id(old_dorothy), None) |
|
597 |
self.assertEqual(conflicts.final_name(new_dorothy), 'dorothy') |
|
1534.7.170
by Aaron Bentley
Cleaned up filesystem conflict handling |
598 |
self.assertEqual(conflicts.final_file_id(new_dorothy), 'dorothy-id') |
1534.7.64
by Aaron Bentley
Extra testing |
599 |
self.assertEqual(conflicts.final_parent(emerald), oz) |
1534.7.63
by Aaron Bentley
Ensure transform can be applied after resolution |
600 |
conflicts.apply() |
1534.7.62
by Aaron Bentley
Fixed moving versioned directories |
601 |
|
1534.7.170
by Aaron Bentley
Cleaned up filesystem conflict handling |
602 |
def test_cook_conflicts(self): |
603 |
tt, emerald, oz, old_dorothy, new_dorothy = self.get_conflicted() |
|
604 |
raw_conflicts = resolve_conflicts(tt) |
|
605 |
cooked_conflicts = cook_conflicts(raw_conflicts, tt) |
|
1534.10.20
by Aaron Bentley
Got all tests passing |
606 |
duplicate = DuplicateEntry('Moved existing file to', 'dorothy.moved', |
607 |
'dorothy', None, 'dorothy-id') |
|
1534.7.170
by Aaron Bentley
Cleaned up filesystem conflict handling |
608 |
self.assertEqual(cooked_conflicts[0], duplicate) |
1534.10.20
by Aaron Bentley
Got all tests passing |
609 |
duplicate_id = DuplicateID('Unversioned existing file', |
610 |
'dorothy.moved', 'dorothy', None, |
|
611 |
'dorothy-id') |
|
1534.7.170
by Aaron Bentley
Cleaned up filesystem conflict handling |
612 |
self.assertEqual(cooked_conflicts[1], duplicate_id) |
1551.8.22
by Aaron Bentley
Improve message when OTHER deletes an in-use tree |
613 |
missing_parent = MissingParent('Created directory', 'munchkincity', |
614 |
'munchkincity-id') |
|
615 |
deleted_parent = DeletingParent('Not deleting', 'oz', 'oz-id') |
|
1534.7.170
by Aaron Bentley
Cleaned up filesystem conflict handling |
616 |
self.assertEqual(cooked_conflicts[2], missing_parent) |
1551.8.22
by Aaron Bentley
Improve message when OTHER deletes an in-use tree |
617 |
unversioned_parent = UnversionedParent('Versioned directory', |
618 |
'munchkincity', |
|
619 |
'munchkincity-id') |
|
620 |
unversioned_parent2 = UnversionedParent('Versioned directory', 'oz', |
|
1534.10.20
by Aaron Bentley
Got all tests passing |
621 |
'oz-id') |
1534.7.170
by Aaron Bentley
Cleaned up filesystem conflict handling |
622 |
self.assertEqual(cooked_conflicts[3], unversioned_parent) |
1534.10.20
by Aaron Bentley
Got all tests passing |
623 |
parent_loop = ParentLoop('Cancelled move', 'oz/emeraldcity', |
624 |
'oz/emeraldcity', 'emerald-id', 'emerald-id') |
|
1551.8.22
by Aaron Bentley
Improve message when OTHER deletes an in-use tree |
625 |
self.assertEqual(cooked_conflicts[4], deleted_parent) |
626 |
self.assertEqual(cooked_conflicts[5], unversioned_parent2) |
|
627 |
self.assertEqual(cooked_conflicts[6], parent_loop) |
|
628 |
self.assertEqual(len(cooked_conflicts), 7) |
|
1534.7.170
by Aaron Bentley
Cleaned up filesystem conflict handling |
629 |
tt.finalize() |
630 |
||
631 |
def test_string_conflicts(self): |
|
632 |
tt, emerald, oz, old_dorothy, new_dorothy = self.get_conflicted() |
|
633 |
raw_conflicts = resolve_conflicts(tt) |
|
634 |
cooked_conflicts = cook_conflicts(raw_conflicts, tt) |
|
635 |
tt.finalize() |
|
1534.10.24
by Aaron Bentley
Eliminated conflicts_to_strings, made remove_files a ConflictList member |
636 |
conflicts_s = [str(c) for c in cooked_conflicts] |
1534.7.171
by Aaron Bentley
Implemented stringifying filesystem conflicts |
637 |
self.assertEqual(len(cooked_conflicts), len(conflicts_s)) |
638 |
self.assertEqual(conflicts_s[0], 'Conflict adding file dorothy. ' |
|
639 |
'Moved existing file to '
|
|
640 |
'dorothy.moved.') |
|
641 |
self.assertEqual(conflicts_s[1], 'Conflict adding id to dorothy. ' |
|
642 |
'Unversioned existing file '
|
|
643 |
'dorothy.moved.') |
|
1551.8.22
by Aaron Bentley
Improve message when OTHER deletes an in-use tree |
644 |
self.assertEqual(conflicts_s[2], 'Conflict adding files to' |
645 |
' munchkincity. Created directory.') |
|
646 |
self.assertEqual(conflicts_s[3], 'Conflict because munchkincity is not' |
|
647 |
' versioned, but has versioned'
|
|
648 |
' children. Versioned directory.') |
|
1551.8.23
by Aaron Bentley
Tweaked conflict message to be more understandable |
649 |
self.assertEqualDiff(conflicts_s[4], "Conflict: can't delete oz because it" |
650 |
" is not empty. Not deleting.") |
|
1551.8.22
by Aaron Bentley
Improve message when OTHER deletes an in-use tree |
651 |
self.assertEqual(conflicts_s[5], 'Conflict because oz is not' |
652 |
' versioned, but has versioned'
|
|
653 |
' children. Versioned directory.') |
|
654 |
self.assertEqual(conflicts_s[6], 'Conflict moving oz/emeraldcity into' |
|
1534.7.171
by Aaron Bentley
Implemented stringifying filesystem conflicts |
655 |
' oz/emeraldcity. Cancelled move.') |
1534.7.170
by Aaron Bentley
Cleaned up filesystem conflict handling |
656 |
|
3144.4.2
by Aaron Bentley
Handle non-directory parent conflicts (abentley, #177390) |
657 |
def prepare_wrong_parent_kind(self): |
658 |
tt, root = self.get_transform() |
|
659 |
tt.new_file('parent', root, 'contents', 'parent-id') |
|
660 |
tt.apply() |
|
661 |
tt, root = self.get_transform() |
|
662 |
parent_id = tt.trans_id_file_id('parent-id') |
|
663 |
tt.new_file('child,', parent_id, 'contents2', 'file-id') |
|
664 |
return tt |
|
665 |
||
3144.4.1
by Aaron Bentley
Handle trying to list parents of a non-directory |
666 |
def test_find_conflicts_wrong_parent_kind(self): |
3144.4.2
by Aaron Bentley
Handle non-directory parent conflicts (abentley, #177390) |
667 |
tt = self.prepare_wrong_parent_kind() |
3144.4.1
by Aaron Bentley
Handle trying to list parents of a non-directory |
668 |
tt.find_conflicts() |
669 |
||
3144.4.2
by Aaron Bentley
Handle non-directory parent conflicts (abentley, #177390) |
670 |
def test_resolve_conflicts_wrong_existing_parent_kind(self): |
671 |
tt = self.prepare_wrong_parent_kind() |
|
672 |
raw_conflicts = resolve_conflicts(tt) |
|
673 |
self.assertEqual(set([('non-directory parent', 'Created directory', |
|
674 |
'new-3')]), raw_conflicts) |
|
675 |
cooked_conflicts = cook_conflicts(raw_conflicts, tt) |
|
676 |
self.assertEqual([NonDirectoryParent('Created directory', 'parent.new', |
|
677 |
'parent-id')], cooked_conflicts) |
|
678 |
tt.apply() |
|
679 |
self.assertEqual(None, self.wt.path2id('parent')) |
|
680 |
self.assertEqual('parent-id', self.wt.path2id('parent.new')) |
|
681 |
||
682 |
def test_resolve_conflicts_wrong_new_parent_kind(self): |
|
683 |
tt, root = self.get_transform() |
|
684 |
parent_id = tt.new_directory('parent', root, 'parent-id') |
|
685 |
tt.new_file('child,', parent_id, 'contents2', 'file-id') |
|
686 |
tt.apply() |
|
687 |
tt, root = self.get_transform() |
|
688 |
parent_id = tt.trans_id_file_id('parent-id') |
|
689 |
tt.delete_contents(parent_id) |
|
690 |
tt.create_file('contents', parent_id) |
|
691 |
raw_conflicts = resolve_conflicts(tt) |
|
692 |
self.assertEqual(set([('non-directory parent', 'Created directory', |
|
693 |
'new-3')]), raw_conflicts) |
|
694 |
tt.apply() |
|
695 |
self.assertEqual(None, self.wt.path2id('parent')) |
|
696 |
self.assertEqual('parent-id', self.wt.path2id('parent.new')) |
|
697 |
||
698 |
def test_resolve_conflicts_wrong_parent_kind_unversioned(self): |
|
699 |
tt, root = self.get_transform() |
|
700 |
parent_id = tt.new_directory('parent', root) |
|
701 |
tt.new_file('child,', parent_id, 'contents2') |
|
702 |
tt.apply() |
|
703 |
tt, root = self.get_transform() |
|
704 |
parent_id = tt.trans_id_tree_path('parent') |
|
705 |
tt.delete_contents(parent_id) |
|
706 |
tt.create_file('contents', parent_id) |
|
707 |
resolve_conflicts(tt) |
|
708 |
tt.apply() |
|
709 |
self.assertIs(None, self.wt.path2id('parent')) |
|
710 |
self.assertIs(None, self.wt.path2id('parent.new')) |
|
711 |
||
1534.7.62
by Aaron Bentley
Fixed moving versioned directories |
712 |
def test_moving_versioned_directories(self): |
713 |
create, root = self.get_transform() |
|
714 |
kansas = create.new_directory('kansas', root, 'kansas-id') |
|
715 |
create.new_directory('house', kansas, 'house-id') |
|
716 |
create.new_directory('oz', root, 'oz-id') |
|
717 |
create.apply() |
|
718 |
cyclone, root = self.get_transform() |
|
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
719 |
oz = cyclone.trans_id_tree_file_id('oz-id') |
720 |
house = cyclone.trans_id_tree_file_id('house-id') |
|
1534.7.62
by Aaron Bentley
Fixed moving versioned directories |
721 |
cyclone.adjust_path('house', oz, house) |
722 |
cyclone.apply() |
|
1534.7.66
by Aaron Bentley
Ensured we don't accidentally move the root directory |
723 |
|
724 |
def test_moving_root(self): |
|
1534.7.68
by Aaron Bentley
Got semi-reasonable root directory renaming working |
725 |
create, root = self.get_transform() |
726 |
fun = create.new_directory('fun', root, 'fun-id') |
|
727 |
create.new_directory('sun', root, 'sun-id') |
|
728 |
create.new_directory('moon', root, 'moon') |
|
729 |
create.apply() |
|
1534.7.66
by Aaron Bentley
Ensured we don't accidentally move the root directory |
730 |
transform, root = self.get_transform() |
1534.7.68
by Aaron Bentley
Got semi-reasonable root directory renaming working |
731 |
transform.adjust_root_path('oldroot', fun) |
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
732 |
new_root=transform.trans_id_tree_path('') |
1534.7.69
by Aaron Bentley
Got real root moves working |
733 |
transform.version_file('new-root', new_root) |
1534.7.68
by Aaron Bentley
Got semi-reasonable root directory renaming working |
734 |
transform.apply() |
1534.7.93
by Aaron Bentley
Added text merge test |
735 |
|
1534.7.114
by Aaron Bentley
Added file renaming test case |
736 |
def test_renames(self): |
737 |
create, root = self.get_transform() |
|
738 |
old = create.new_directory('old-parent', root, 'old-id') |
|
739 |
intermediate = create.new_directory('intermediate', old, 'im-id') |
|
740 |
myfile = create.new_file('myfile', intermediate, 'myfile-text', |
|
741 |
'myfile-id') |
|
742 |
create.apply() |
|
743 |
rename, root = self.get_transform() |
|
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
744 |
old = rename.trans_id_file_id('old-id') |
1534.7.114
by Aaron Bentley
Added file renaming test case |
745 |
rename.adjust_path('new', root, old) |
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
746 |
myfile = rename.trans_id_file_id('myfile-id') |
1534.7.114
by Aaron Bentley
Added file renaming test case |
747 |
rename.set_executability(True, myfile) |
748 |
rename.apply() |
|
749 |
||
1740.2.4
by Aaron Bentley
Update transform tests and docs |
750 |
def test_set_executability_order(self): |
751 |
"""Ensure that executability behaves the same, no matter what order.
|
|
752 |
|
|
753 |
- create file and set executability simultaneously
|
|
754 |
- create file and set executability afterward
|
|
755 |
- unsetting the executability of a file whose executability has not been
|
|
756 |
declared should throw an exception (this may happen when a
|
|
757 |
merge attempts to create a file with a duplicate ID)
|
|
758 |
"""
|
|
759 |
transform, root = self.get_transform() |
|
760 |
wt = transform._tree |
|
3034.2.1
by Aaron Bentley
Fix is_executable tests for win32 |
761 |
wt.lock_read() |
762 |
self.addCleanup(wt.unlock) |
|
1740.2.4
by Aaron Bentley
Update transform tests and docs |
763 |
transform.new_file('set_on_creation', root, 'Set on creation', 'soc', |
764 |
True) |
|
2502.1.1
by Aaron Bentley
Ensure renames only root children are renamed when building trees |
765 |
sac = transform.new_file('set_after_creation', root, |
766 |
'Set after creation', 'sac') |
|
1740.2.4
by Aaron Bentley
Update transform tests and docs |
767 |
transform.set_executability(True, sac) |
2502.1.1
by Aaron Bentley
Ensure renames only root children are renamed when building trees |
768 |
uws = transform.new_file('unset_without_set', root, 'Unset badly', |
769 |
'uws') |
|
1740.2.4
by Aaron Bentley
Update transform tests and docs |
770 |
self.assertRaises(KeyError, transform.set_executability, None, uws) |
771 |
transform.apply() |
|
772 |
self.assertTrue(wt.is_executable('soc')) |
|
773 |
self.assertTrue(wt.is_executable('sac')) |
|
774 |
||
1534.12.2
by Aaron Bentley
Added test for preserving file mode |
775 |
def test_preserve_mode(self): |
776 |
"""File mode is preserved when replacing content"""
|
|
777 |
if sys.platform == 'win32': |
|
778 |
raise TestSkipped('chmod has no effect on win32') |
|
779 |
transform, root = self.get_transform() |
|
780 |
transform.new_file('file1', root, 'contents', 'file1-id', True) |
|
781 |
transform.apply() |
|
3146.4.12
by Aaron Bentley
Add needed write lock to test |
782 |
self.wt.lock_write() |
783 |
self.addCleanup(self.wt.unlock) |
|
1534.12.2
by Aaron Bentley
Added test for preserving file mode |
784 |
self.assertTrue(self.wt.is_executable('file1-id')) |
785 |
transform, root = self.get_transform() |
|
786 |
file1_id = transform.trans_id_tree_file_id('file1-id') |
|
787 |
transform.delete_contents(file1_id) |
|
788 |
transform.create_file('contents2', file1_id) |
|
789 |
transform.apply() |
|
790 |
self.assertTrue(self.wt.is_executable('file1-id')) |
|
791 |
||
2027.1.1
by John Arbash Meinel
Fix bug #56549, and write a direct test that the right path is being statted |
792 |
def test__set_mode_stats_correctly(self): |
793 |
"""_set_mode stats to determine file mode."""
|
|
794 |
if sys.platform == 'win32': |
|
795 |
raise TestSkipped('chmod has no effect on win32') |
|
796 |
||
797 |
stat_paths = [] |
|
798 |
real_stat = os.stat |
|
799 |
def instrumented_stat(path): |
|
800 |
stat_paths.append(path) |
|
801 |
return real_stat(path) |
|
802 |
||
803 |
transform, root = self.get_transform() |
|
804 |
||
805 |
bar1_id = transform.new_file('bar', root, 'bar contents 1\n', |
|
806 |
file_id='bar-id-1', executable=False) |
|
807 |
transform.apply() |
|
808 |
||
809 |
transform, root = self.get_transform() |
|
810 |
bar1_id = transform.trans_id_tree_path('bar') |
|
811 |
bar2_id = transform.trans_id_tree_path('bar2') |
|
812 |
try: |
|
813 |
os.stat = instrumented_stat |
|
814 |
transform.create_file('bar2 contents\n', bar2_id, mode_id=bar1_id) |
|
815 |
finally: |
|
816 |
os.stat = real_stat |
|
817 |
transform.finalize() |
|
818 |
||
819 |
bar1_abspath = self.wt.abspath('bar') |
|
820 |
self.assertEqual([bar1_abspath], stat_paths) |
|
821 |
||
1551.11.1
by Aaron Bentley
Initial work on converting TreeTransform to iter_changes format |
822 |
def test_iter_changes(self): |
2100.3.33
by Aaron Bentley
Handle unique roots in tests for TreeTransform.iter_changes |
823 |
self.wt.set_root_id('eert_toor') |
1551.11.1
by Aaron Bentley
Initial work on converting TreeTransform to iter_changes format |
824 |
transform, root = self.get_transform() |
825 |
transform.new_file('old', root, 'blah', 'id-1', True) |
|
826 |
transform.apply() |
|
827 |
transform, root = self.get_transform() |
|
828 |
try: |
|
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
829 |
self.assertEqual([], list(transform.iter_changes())) |
1551.11.1
by Aaron Bentley
Initial work on converting TreeTransform to iter_changes format |
830 |
old = transform.trans_id_tree_file_id('id-1') |
831 |
transform.unversion_file(old) |
|
2255.7.96
by Robert Collins
Change _iter_changes interface to yield both old and new paths. |
832 |
self.assertEqual([('id-1', ('old', None), False, (True, False), |
2100.3.33
by Aaron Bentley
Handle unique roots in tests for TreeTransform.iter_changes |
833 |
('eert_toor', 'eert_toor'), ('old', 'old'), ('file', 'file'), |
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
834 |
(True, True))], list(transform.iter_changes())) |
1551.11.1
by Aaron Bentley
Initial work on converting TreeTransform to iter_changes format |
835 |
transform.new_directory('new', root, 'id-1') |
2255.7.96
by Robert Collins
Change _iter_changes interface to yield both old and new paths. |
836 |
self.assertEqual([('id-1', ('old', 'new'), True, (True, True), |
2100.3.33
by Aaron Bentley
Handle unique roots in tests for TreeTransform.iter_changes |
837 |
('eert_toor', 'eert_toor'), ('old', 'new'), |
1551.11.1
by Aaron Bentley
Initial work on converting TreeTransform to iter_changes format |
838 |
('file', 'directory'), |
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
839 |
(True, False))], list(transform.iter_changes())) |
1551.11.1
by Aaron Bentley
Initial work on converting TreeTransform to iter_changes format |
840 |
finally: |
841 |
transform.finalize() |
|
842 |
||
843 |
def test_iter_changes_new(self): |
|
2100.3.33
by Aaron Bentley
Handle unique roots in tests for TreeTransform.iter_changes |
844 |
self.wt.set_root_id('eert_toor') |
1551.11.1
by Aaron Bentley
Initial work on converting TreeTransform to iter_changes format |
845 |
transform, root = self.get_transform() |
846 |
transform.new_file('old', root, 'blah') |
|
847 |
transform.apply() |
|
848 |
transform, root = self.get_transform() |
|
849 |
try: |
|
850 |
old = transform.trans_id_tree_path('old') |
|
851 |
transform.version_file('id-1', old) |
|
2255.7.96
by Robert Collins
Change _iter_changes interface to yield both old and new paths. |
852 |
self.assertEqual([('id-1', (None, 'old'), False, (False, True), |
2100.3.33
by Aaron Bentley
Handle unique roots in tests for TreeTransform.iter_changes |
853 |
('eert_toor', 'eert_toor'), ('old', 'old'), ('file', 'file'), |
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
854 |
(False, False))], list(transform.iter_changes())) |
1551.11.1
by Aaron Bentley
Initial work on converting TreeTransform to iter_changes format |
855 |
finally: |
856 |
transform.finalize() |
|
857 |
||
1551.11.2
by Aaron Bentley
Get kind change detection working for iter_changes |
858 |
def test_iter_changes_modifications(self): |
2100.3.33
by Aaron Bentley
Handle unique roots in tests for TreeTransform.iter_changes |
859 |
self.wt.set_root_id('eert_toor') |
1551.11.2
by Aaron Bentley
Get kind change detection working for iter_changes |
860 |
transform, root = self.get_transform() |
861 |
transform.new_file('old', root, 'blah', 'id-1') |
|
862 |
transform.new_file('new', root, 'blah') |
|
863 |
transform.new_directory('subdir', root, 'subdir-id') |
|
864 |
transform.apply() |
|
865 |
transform, root = self.get_transform() |
|
866 |
try: |
|
867 |
old = transform.trans_id_tree_path('old') |
|
868 |
subdir = transform.trans_id_tree_file_id('subdir-id') |
|
869 |
new = transform.trans_id_tree_path('new') |
|
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
870 |
self.assertEqual([], list(transform.iter_changes())) |
1551.11.2
by Aaron Bentley
Get kind change detection working for iter_changes |
871 |
|
872 |
#content deletion
|
|
873 |
transform.delete_contents(old) |
|
2255.7.96
by Robert Collins
Change _iter_changes interface to yield both old and new paths. |
874 |
self.assertEqual([('id-1', ('old', 'old'), True, (True, True), |
2100.3.33
by Aaron Bentley
Handle unique roots in tests for TreeTransform.iter_changes |
875 |
('eert_toor', 'eert_toor'), ('old', 'old'), ('file', None), |
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
876 |
(False, False))], list(transform.iter_changes())) |
1551.11.2
by Aaron Bentley
Get kind change detection working for iter_changes |
877 |
|
878 |
#content change
|
|
879 |
transform.create_file('blah', old) |
|
2255.7.96
by Robert Collins
Change _iter_changes interface to yield both old and new paths. |
880 |
self.assertEqual([('id-1', ('old', 'old'), True, (True, True), |
2100.3.33
by Aaron Bentley
Handle unique roots in tests for TreeTransform.iter_changes |
881 |
('eert_toor', 'eert_toor'), ('old', 'old'), ('file', 'file'), |
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
882 |
(False, False))], list(transform.iter_changes())) |
1551.11.2
by Aaron Bentley
Get kind change detection working for iter_changes |
883 |
transform.cancel_deletion(old) |
2255.7.96
by Robert Collins
Change _iter_changes interface to yield both old and new paths. |
884 |
self.assertEqual([('id-1', ('old', 'old'), True, (True, True), |
2100.3.33
by Aaron Bentley
Handle unique roots in tests for TreeTransform.iter_changes |
885 |
('eert_toor', 'eert_toor'), ('old', 'old'), ('file', 'file'), |
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
886 |
(False, False))], list(transform.iter_changes())) |
1551.11.2
by Aaron Bentley
Get kind change detection working for iter_changes |
887 |
transform.cancel_creation(old) |
888 |
||
889 |
# move file_id to a different file
|
|
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
890 |
self.assertEqual([], list(transform.iter_changes())) |
1551.11.2
by Aaron Bentley
Get kind change detection working for iter_changes |
891 |
transform.unversion_file(old) |
892 |
transform.version_file('id-1', new) |
|
893 |
transform.adjust_path('old', root, new) |
|
2255.7.96
by Robert Collins
Change _iter_changes interface to yield both old and new paths. |
894 |
self.assertEqual([('id-1', ('old', 'old'), True, (True, True), |
2100.3.33
by Aaron Bentley
Handle unique roots in tests for TreeTransform.iter_changes |
895 |
('eert_toor', 'eert_toor'), ('old', 'old'), ('file', 'file'), |
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
896 |
(False, False))], list(transform.iter_changes())) |
1551.11.2
by Aaron Bentley
Get kind change detection working for iter_changes |
897 |
transform.cancel_versioning(new) |
898 |
transform._removed_id = set() |
|
899 |
||
900 |
#execute bit
|
|
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
901 |
self.assertEqual([], list(transform.iter_changes())) |
1551.11.2
by Aaron Bentley
Get kind change detection working for iter_changes |
902 |
transform.set_executability(True, old) |
2255.7.96
by Robert Collins
Change _iter_changes interface to yield both old and new paths. |
903 |
self.assertEqual([('id-1', ('old', 'old'), False, (True, True), |
2100.3.33
by Aaron Bentley
Handle unique roots in tests for TreeTransform.iter_changes |
904 |
('eert_toor', 'eert_toor'), ('old', 'old'), ('file', 'file'), |
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
905 |
(False, True))], list(transform.iter_changes())) |
1551.11.2
by Aaron Bentley
Get kind change detection working for iter_changes |
906 |
transform.set_executability(None, old) |
907 |
||
908 |
# filename
|
|
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
909 |
self.assertEqual([], list(transform.iter_changes())) |
1551.11.2
by Aaron Bentley
Get kind change detection working for iter_changes |
910 |
transform.adjust_path('new', root, old) |
911 |
transform._new_parent = {} |
|
2255.7.96
by Robert Collins
Change _iter_changes interface to yield both old and new paths. |
912 |
self.assertEqual([('id-1', ('old', 'new'), False, (True, True), |
2100.3.33
by Aaron Bentley
Handle unique roots in tests for TreeTransform.iter_changes |
913 |
('eert_toor', 'eert_toor'), ('old', 'new'), ('file', 'file'), |
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
914 |
(False, False))], list(transform.iter_changes())) |
1551.11.2
by Aaron Bentley
Get kind change detection working for iter_changes |
915 |
transform._new_name = {} |
916 |
||
917 |
# parent directory
|
|
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
918 |
self.assertEqual([], list(transform.iter_changes())) |
1551.11.2
by Aaron Bentley
Get kind change detection working for iter_changes |
919 |
transform.adjust_path('new', subdir, old) |
920 |
transform._new_name = {} |
|
2255.7.96
by Robert Collins
Change _iter_changes interface to yield both old and new paths. |
921 |
self.assertEqual([('id-1', ('old', 'subdir/old'), False, |
2255.2.180
by Martin Pool
merge dirstate |
922 |
(True, True), ('eert_toor', 'subdir-id'), ('old', 'old'), |
2255.7.96
by Robert Collins
Change _iter_changes interface to yield both old and new paths. |
923 |
('file', 'file'), (False, False))], |
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
924 |
list(transform.iter_changes())) |
1551.11.2
by Aaron Bentley
Get kind change detection working for iter_changes |
925 |
transform._new_path = {} |
926 |
||
927 |
finally: |
|
928 |
transform.finalize() |
|
929 |
||
1551.11.7
by Aaron Bentley
Stop modified flag bleeding into later changes |
930 |
def test_iter_changes_modified_bleed(self): |
2100.3.33
by Aaron Bentley
Handle unique roots in tests for TreeTransform.iter_changes |
931 |
self.wt.set_root_id('eert_toor') |
1551.11.7
by Aaron Bentley
Stop modified flag bleeding into later changes |
932 |
"""Modified flag should not bleed from one change to another"""
|
933 |
# unfortunately, we have no guarantee that file1 (which is modified)
|
|
934 |
# will be applied before file2. And if it's applied after file2, it
|
|
935 |
# obviously can't bleed into file2's change output. But for now, it
|
|
936 |
# works.
|
|
937 |
transform, root = self.get_transform() |
|
938 |
transform.new_file('file1', root, 'blah', 'id-1') |
|
939 |
transform.new_file('file2', root, 'blah', 'id-2') |
|
940 |
transform.apply() |
|
941 |
transform, root = self.get_transform() |
|
942 |
try: |
|
943 |
transform.delete_contents(transform.trans_id_file_id('id-1')) |
|
944 |
transform.set_executability(True, |
|
945 |
transform.trans_id_file_id('id-2')) |
|
2255.7.96
by Robert Collins
Change _iter_changes interface to yield both old and new paths. |
946 |
self.assertEqual([('id-1', (u'file1', u'file1'), True, (True, True), |
2100.3.33
by Aaron Bentley
Handle unique roots in tests for TreeTransform.iter_changes |
947 |
('eert_toor', 'eert_toor'), ('file1', u'file1'), |
1551.11.7
by Aaron Bentley
Stop modified flag bleeding into later changes |
948 |
('file', None), (False, False)), |
2255.7.96
by Robert Collins
Change _iter_changes interface to yield both old and new paths. |
949 |
('id-2', (u'file2', u'file2'), False, (True, True), |
2100.3.33
by Aaron Bentley
Handle unique roots in tests for TreeTransform.iter_changes |
950 |
('eert_toor', 'eert_toor'), ('file2', u'file2'), |
1551.11.7
by Aaron Bentley
Stop modified flag bleeding into later changes |
951 |
('file', 'file'), (False, True))], |
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
952 |
list(transform.iter_changes())) |
1551.11.7
by Aaron Bentley
Stop modified flag bleeding into later changes |
953 |
finally: |
954 |
transform.finalize() |
|
955 |
||
1551.10.37
by Aaron Bentley
recommit of TreeTransform._iter_changes fix with missing files |
956 |
def test_iter_changes_move_missing(self): |
957 |
"""Test moving ids with no files around"""
|
|
958 |
self.wt.set_root_id('toor_eert') |
|
959 |
# Need two steps because versioning a non-existant file is a conflict.
|
|
960 |
transform, root = self.get_transform() |
|
961 |
transform.new_directory('floater', root, 'floater-id') |
|
962 |
transform.apply() |
|
963 |
transform, root = self.get_transform() |
|
964 |
transform.delete_contents(transform.trans_id_tree_path('floater')) |
|
965 |
transform.apply() |
|
966 |
transform, root = self.get_transform() |
|
967 |
floater = transform.trans_id_tree_path('floater') |
|
968 |
try: |
|
969 |
transform.adjust_path('flitter', root, floater) |
|
970 |
self.assertEqual([('floater-id', ('floater', 'flitter'), False, |
|
971 |
(True, True), ('toor_eert', 'toor_eert'), ('floater', 'flitter'), |
|
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
972 |
(None, None), (False, False))], list(transform.iter_changes())) |
1551.10.37
by Aaron Bentley
recommit of TreeTransform._iter_changes fix with missing files |
973 |
finally: |
974 |
transform.finalize() |
|
975 |
||
1551.11.2
by Aaron Bentley
Get kind change detection working for iter_changes |
976 |
def test_iter_changes_pointless(self): |
977 |
"""Ensure that no-ops are not treated as modifications"""
|
|
2100.3.33
by Aaron Bentley
Handle unique roots in tests for TreeTransform.iter_changes |
978 |
self.wt.set_root_id('eert_toor') |
1551.11.2
by Aaron Bentley
Get kind change detection working for iter_changes |
979 |
transform, root = self.get_transform() |
980 |
transform.new_file('old', root, 'blah', 'id-1') |
|
981 |
transform.new_directory('subdir', root, 'subdir-id') |
|
982 |
transform.apply() |
|
983 |
transform, root = self.get_transform() |
|
984 |
try: |
|
985 |
old = transform.trans_id_tree_path('old') |
|
986 |
subdir = transform.trans_id_tree_file_id('subdir-id') |
|
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
987 |
self.assertEqual([], list(transform.iter_changes())) |
1551.11.2
by Aaron Bentley
Get kind change detection working for iter_changes |
988 |
transform.delete_contents(subdir) |
989 |
transform.create_directory(subdir) |
|
990 |
transform.set_executability(False, old) |
|
991 |
transform.unversion_file(old) |
|
992 |
transform.version_file('id-1', old) |
|
993 |
transform.adjust_path('old', root, old) |
|
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
994 |
self.assertEqual([], list(transform.iter_changes())) |
1551.11.2
by Aaron Bentley
Get kind change detection working for iter_changes |
995 |
finally: |
996 |
transform.finalize() |
|
1534.7.93
by Aaron Bentley
Added text merge test |
997 |
|
2502.1.1
by Aaron Bentley
Ensure renames only root children are renamed when building trees |
998 |
def test_rename_count(self): |
999 |
transform, root = self.get_transform() |
|
2502.1.8
by Aaron Bentley
Updates from review comments |
1000 |
transform.new_file('name1', root, 'contents') |
2502.1.1
by Aaron Bentley
Ensure renames only root children are renamed when building trees |
1001 |
self.assertEqual(transform.rename_count, 0) |
1002 |
transform.apply() |
|
1003 |
self.assertEqual(transform.rename_count, 1) |
|
1004 |
transform2, root = self.get_transform() |
|
2502.1.8
by Aaron Bentley
Updates from review comments |
1005 |
transform2.adjust_path('name2', root, |
1006 |
transform2.trans_id_tree_path('name1')) |
|
2502.1.1
by Aaron Bentley
Ensure renames only root children are renamed when building trees |
1007 |
self.assertEqual(transform2.rename_count, 0) |
1008 |
transform2.apply() |
|
1009 |
self.assertEqual(transform2.rename_count, 2) |
|
1010 |
||
2502.1.2
by Aaron Bentley
Make the limited-renames functionality safer in the general case |
1011 |
def test_change_parent(self): |
2502.1.8
by Aaron Bentley
Updates from review comments |
1012 |
"""Ensure that after we change a parent, the results are still right.
|
1013 |
||
1014 |
Renames and parent changes on pending transforms can happen as part
|
|
1015 |
of conflict resolution, and are explicitly permitted by the
|
|
1016 |
TreeTransform API.
|
|
1017 |
||
1018 |
This test ensures they work correctly with the rename-avoidance
|
|
1019 |
optimization.
|
|
1020 |
"""
|
|
2502.1.2
by Aaron Bentley
Make the limited-renames functionality safer in the general case |
1021 |
transform, root = self.get_transform() |
2502.1.8
by Aaron Bentley
Updates from review comments |
1022 |
parent1 = transform.new_directory('parent1', root) |
1023 |
child1 = transform.new_file('child1', parent1, 'contents') |
|
1024 |
parent2 = transform.new_directory('parent2', root) |
|
1025 |
transform.adjust_path('child1', parent2, child1) |
|
2502.1.2
by Aaron Bentley
Make the limited-renames functionality safer in the general case |
1026 |
transform.apply() |
2502.1.8
by Aaron Bentley
Updates from review comments |
1027 |
self.failIfExists(self.wt.abspath('parent1/child1')) |
1028 |
self.failUnlessExists(self.wt.abspath('parent2/child1')) |
|
1029 |
# rename limbo/new-1 => parent1, rename limbo/new-3 => parent2
|
|
1030 |
# no rename for child1 (counting only renames during apply)
|
|
2502.1.2
by Aaron Bentley
Make the limited-renames functionality safer in the general case |
1031 |
self.failUnlessEqual(2, transform.rename_count) |
1032 |
||
1033 |
def test_cancel_parent(self): |
|
1034 |
"""Cancelling a parent doesn't cause deletion of a non-empty directory
|
|
1035 |
||
1036 |
This is like the test_change_parent, except that we cancel the parent
|
|
1037 |
before adjusting the path. The transform must detect that the
|
|
1038 |
directory is non-empty, and move children to safe locations.
|
|
1039 |
"""
|
|
1040 |
transform, root = self.get_transform() |
|
2502.1.8
by Aaron Bentley
Updates from review comments |
1041 |
parent1 = transform.new_directory('parent1', root) |
1042 |
child1 = transform.new_file('child1', parent1, 'contents') |
|
1043 |
child2 = transform.new_file('child2', parent1, 'contents') |
|
1044 |
try: |
|
1045 |
transform.cancel_creation(parent1) |
|
1046 |
except OSError: |
|
1047 |
self.fail('Failed to move child1 before deleting parent1') |
|
1048 |
transform.cancel_creation(child2) |
|
1049 |
transform.create_directory(parent1) |
|
1050 |
try: |
|
1051 |
transform.cancel_creation(parent1) |
|
1052 |
# If the transform incorrectly believes that child2 is still in
|
|
1053 |
# parent1's limbo directory, it will try to rename it and fail
|
|
1054 |
# because was already moved by the first cancel_creation.
|
|
1055 |
except OSError: |
|
1056 |
self.fail('Transform still thinks child2 is a child of parent1') |
|
1057 |
parent2 = transform.new_directory('parent2', root) |
|
1058 |
transform.adjust_path('child1', parent2, child1) |
|
2502.1.2
by Aaron Bentley
Make the limited-renames functionality safer in the general case |
1059 |
transform.apply() |
2502.1.8
by Aaron Bentley
Updates from review comments |
1060 |
self.failIfExists(self.wt.abspath('parent1')) |
1061 |
self.failUnlessExists(self.wt.abspath('parent2/child1')) |
|
1062 |
# rename limbo/new-3 => parent2, rename limbo/new-2 => child1
|
|
2502.1.2
by Aaron Bentley
Make the limited-renames functionality safer in the general case |
1063 |
self.failUnlessEqual(2, transform.rename_count) |
1064 |
||
1065 |
def test_adjust_and_cancel(self): |
|
2502.1.8
by Aaron Bentley
Updates from review comments |
1066 |
"""Make sure adjust_path keeps track of limbo children properly"""
|
2502.1.2
by Aaron Bentley
Make the limited-renames functionality safer in the general case |
1067 |
transform, root = self.get_transform() |
2502.1.8
by Aaron Bentley
Updates from review comments |
1068 |
parent1 = transform.new_directory('parent1', root) |
1069 |
child1 = transform.new_file('child1', parent1, 'contents') |
|
1070 |
parent2 = transform.new_directory('parent2', root) |
|
1071 |
transform.adjust_path('child1', parent2, child1) |
|
1072 |
transform.cancel_creation(child1) |
|
2502.1.2
by Aaron Bentley
Make the limited-renames functionality safer in the general case |
1073 |
try: |
2502.1.8
by Aaron Bentley
Updates from review comments |
1074 |
transform.cancel_creation(parent1) |
1075 |
# if the transform thinks child1 is still in parent1's limbo
|
|
1076 |
# directory, it will attempt to move it and fail.
|
|
2502.1.2
by Aaron Bentley
Make the limited-renames functionality safer in the general case |
1077 |
except OSError: |
2502.1.8
by Aaron Bentley
Updates from review comments |
1078 |
self.fail('Transform still thinks child1 is a child of parent1') |
2502.1.2
by Aaron Bentley
Make the limited-renames functionality safer in the general case |
1079 |
transform.finalize() |
1080 |
||
2502.1.3
by Aaron Bentley
Don't cause errors when creating contents for trans_ids with no parent/name |
1081 |
def test_noname_contents(self): |
2502.1.8
by Aaron Bentley
Updates from review comments |
1082 |
"""TreeTransform should permit deferring naming files."""
|
2502.1.3
by Aaron Bentley
Don't cause errors when creating contents for trans_ids with no parent/name |
1083 |
transform, root = self.get_transform() |
2502.1.8
by Aaron Bentley
Updates from review comments |
1084 |
parent = transform.trans_id_file_id('parent-id') |
2502.1.3
by Aaron Bentley
Don't cause errors when creating contents for trans_ids with no parent/name |
1085 |
try: |
2502.1.8
by Aaron Bentley
Updates from review comments |
1086 |
transform.create_directory(parent) |
2502.1.3
by Aaron Bentley
Don't cause errors when creating contents for trans_ids with no parent/name |
1087 |
except KeyError: |
1088 |
self.fail("Can't handle contents with no name") |
|
1089 |
transform.finalize() |
|
1090 |
||
2502.1.9
by Aaron Bentley
Add additional test for no-name contents |
1091 |
def test_noname_contents_nested(self): |
1092 |
"""TreeTransform should permit deferring naming files."""
|
|
1093 |
transform, root = self.get_transform() |
|
1094 |
parent = transform.trans_id_file_id('parent-id') |
|
1095 |
try: |
|
1096 |
transform.create_directory(parent) |
|
1097 |
except KeyError: |
|
1098 |
self.fail("Can't handle contents with no name") |
|
1099 |
child = transform.new_directory('child', parent) |
|
1100 |
transform.adjust_path('parent', root, parent) |
|
1101 |
transform.apply() |
|
1102 |
self.failUnlessExists(self.wt.abspath('parent/child')) |
|
1103 |
self.assertEqual(1, transform.rename_count) |
|
1104 |
||
2502.1.4
by Aaron Bentley
Ensure we only reuse limbo names appropriately |
1105 |
def test_reuse_name(self): |
1106 |
"""Avoid reusing the same limbo name for different files"""
|
|
1107 |
transform, root = self.get_transform() |
|
2502.1.8
by Aaron Bentley
Updates from review comments |
1108 |
parent = transform.new_directory('parent', root) |
1109 |
child1 = transform.new_directory('child', parent) |
|
2502.1.4
by Aaron Bentley
Ensure we only reuse limbo names appropriately |
1110 |
try: |
2502.1.8
by Aaron Bentley
Updates from review comments |
1111 |
child2 = transform.new_directory('child', parent) |
2502.1.4
by Aaron Bentley
Ensure we only reuse limbo names appropriately |
1112 |
except OSError: |
1113 |
self.fail('Tranform tried to use the same limbo name twice') |
|
2502.1.8
by Aaron Bentley
Updates from review comments |
1114 |
transform.adjust_path('child2', parent, child2) |
2502.1.4
by Aaron Bentley
Ensure we only reuse limbo names appropriately |
1115 |
transform.apply() |
2502.1.8
by Aaron Bentley
Updates from review comments |
1116 |
# limbo/new-1 => parent, limbo/new-3 => parent/child2
|
1117 |
# child2 is put into top-level limbo because child1 has already
|
|
1118 |
# claimed the direct limbo path when child2 is created. There is no
|
|
1119 |
# advantage in renaming files once they're in top-level limbo, except
|
|
1120 |
# as part of apply.
|
|
2502.1.4
by Aaron Bentley
Ensure we only reuse limbo names appropriately |
1121 |
self.assertEqual(2, transform.rename_count) |
1122 |
||
1123 |
def test_reuse_when_first_moved(self): |
|
1124 |
"""Don't avoid direct paths when it is safe to use them"""
|
|
1125 |
transform, root = self.get_transform() |
|
2502.1.8
by Aaron Bentley
Updates from review comments |
1126 |
parent = transform.new_directory('parent', root) |
1127 |
child1 = transform.new_directory('child', parent) |
|
1128 |
transform.adjust_path('child1', parent, child1) |
|
1129 |
child2 = transform.new_directory('child', parent) |
|
2502.1.4
by Aaron Bentley
Ensure we only reuse limbo names appropriately |
1130 |
transform.apply() |
2502.1.8
by Aaron Bentley
Updates from review comments |
1131 |
# limbo/new-1 => parent
|
2502.1.4
by Aaron Bentley
Ensure we only reuse limbo names appropriately |
1132 |
self.assertEqual(1, transform.rename_count) |
1133 |
||
1134 |
def test_reuse_after_cancel(self): |
|
1135 |
"""Don't avoid direct paths when it is safe to use them"""
|
|
1136 |
transform, root = self.get_transform() |
|
2502.1.8
by Aaron Bentley
Updates from review comments |
1137 |
parent2 = transform.new_directory('parent2', root) |
1138 |
child1 = transform.new_directory('child1', parent2) |
|
1139 |
transform.cancel_creation(parent2) |
|
1140 |
transform.create_directory(parent2) |
|
1141 |
child2 = transform.new_directory('child1', parent2) |
|
1142 |
transform.adjust_path('child2', parent2, child1) |
|
2502.1.4
by Aaron Bentley
Ensure we only reuse limbo names appropriately |
1143 |
transform.apply() |
2502.1.8
by Aaron Bentley
Updates from review comments |
1144 |
# limbo/new-1 => parent2, limbo/new-2 => parent2/child1
|
2502.1.4
by Aaron Bentley
Ensure we only reuse limbo names appropriately |
1145 |
self.assertEqual(2, transform.rename_count) |
1146 |
||
2502.1.7
by Aaron Bentley
Fix finalize deletion ordering |
1147 |
def test_finalize_order(self): |
2502.1.8
by Aaron Bentley
Updates from review comments |
1148 |
"""Finalize must be done in child-to-parent order"""
|
2502.1.7
by Aaron Bentley
Fix finalize deletion ordering |
1149 |
transform, root = self.get_transform() |
2502.1.8
by Aaron Bentley
Updates from review comments |
1150 |
parent = transform.new_directory('parent', root) |
1151 |
child = transform.new_directory('child', parent) |
|
2502.1.7
by Aaron Bentley
Fix finalize deletion ordering |
1152 |
try: |
1153 |
transform.finalize() |
|
1154 |
except OSError: |
|
2502.1.8
by Aaron Bentley
Updates from review comments |
1155 |
self.fail('Tried to remove parent before child1') |
2502.1.7
by Aaron Bentley
Fix finalize deletion ordering |
1156 |
|
2502.1.13
by Aaron Bentley
Updates from review |
1157 |
def test_cancel_with_cancelled_child_should_succeed(self): |
2502.1.12
by Aaron Bentley
Avoid renaming children with no content |
1158 |
transform, root = self.get_transform() |
1159 |
parent = transform.new_directory('parent', root) |
|
1160 |
child = transform.new_directory('child', parent) |
|
1161 |
transform.cancel_creation(child) |
|
2502.1.13
by Aaron Bentley
Updates from review |
1162 |
transform.cancel_creation(parent) |
2502.1.12
by Aaron Bentley
Avoid renaming children with no content |
1163 |
transform.finalize() |
1164 |
||
3063.1.1
by Alexander Belchenko
Catch OSError 17 (file exists) in final phase of tree transform and show filename to user (#111758). |
1165 |
def test_case_insensitive_clash(self): |
1166 |
self.requireFeature(CaseInsensitiveFilesystemFeature) |
|
1167 |
def tt_helper(): |
|
1168 |
wt = self.make_branch_and_tree('.') |
|
1169 |
tt = TreeTransform(wt) # TreeTransform obtains write lock |
|
1170 |
try: |
|
1171 |
tt.new_file('foo', tt.root, 'bar') |
|
1172 |
tt.new_file('Foo', tt.root, 'spam') |
|
3063.1.3
by Aaron Bentley
Update for Linux |
1173 |
# Lie to tt that we've already resolved all conflicts.
|
3063.1.1
by Alexander Belchenko
Catch OSError 17 (file exists) in final phase of tree transform and show filename to user (#111758). |
1174 |
tt.apply(no_conflicts=True) |
3063.1.3
by Aaron Bentley
Update for Linux |
1175 |
except: |
3063.1.1
by Alexander Belchenko
Catch OSError 17 (file exists) in final phase of tree transform and show filename to user (#111758). |
1176 |
wt.unlock() |
3063.1.3
by Aaron Bentley
Update for Linux |
1177 |
raise
|
3063.1.1
by Alexander Belchenko
Catch OSError 17 (file exists) in final phase of tree transform and show filename to user (#111758). |
1178 |
err = self.assertRaises(errors.FileExists, tt_helper) |
1179 |
self.assertContainsRe(str(err), |
|
1180 |
"^File exists: .+/foo") |
|
1181 |
||
3063.1.2
by Alexander Belchenko
test for two directories clash |
1182 |
def test_two_directories_clash(self): |
1183 |
def tt_helper(): |
|
1184 |
wt = self.make_branch_and_tree('.') |
|
1185 |
tt = TreeTransform(wt) # TreeTransform obtains write lock |
|
1186 |
try: |
|
3063.1.3
by Aaron Bentley
Update for Linux |
1187 |
foo_1 = tt.new_directory('foo', tt.root) |
1188 |
tt.new_directory('bar', foo_1) |
|
1189 |
foo_2 = tt.new_directory('foo', tt.root) |
|
1190 |
tt.new_directory('baz', foo_2) |
|
1191 |
# Lie to tt that we've already resolved all conflicts.
|
|
3063.1.2
by Alexander Belchenko
test for two directories clash |
1192 |
tt.apply(no_conflicts=True) |
3063.1.3
by Aaron Bentley
Update for Linux |
1193 |
except: |
3063.1.2
by Alexander Belchenko
test for two directories clash |
1194 |
wt.unlock() |
3063.1.3
by Aaron Bentley
Update for Linux |
1195 |
raise
|
3063.1.2
by Alexander Belchenko
test for two directories clash |
1196 |
err = self.assertRaises(errors.FileExists, tt_helper) |
1197 |
self.assertContainsRe(str(err), |
|
1198 |
"^File exists: .+/foo") |
|
1199 |
||
3100.1.1
by Aaron Bentley
Fix ImmortalLimbo errors when transforms fail |
1200 |
def test_two_directories_clash_finalize(self): |
1201 |
def tt_helper(): |
|
1202 |
wt = self.make_branch_and_tree('.') |
|
1203 |
tt = TreeTransform(wt) # TreeTransform obtains write lock |
|
1204 |
try: |
|
1205 |
foo_1 = tt.new_directory('foo', tt.root) |
|
1206 |
tt.new_directory('bar', foo_1) |
|
1207 |
foo_2 = tt.new_directory('foo', tt.root) |
|
1208 |
tt.new_directory('baz', foo_2) |
|
1209 |
# Lie to tt that we've already resolved all conflicts.
|
|
1210 |
tt.apply(no_conflicts=True) |
|
1211 |
except: |
|
1212 |
tt.finalize() |
|
1213 |
raise
|
|
1214 |
err = self.assertRaises(errors.FileExists, tt_helper) |
|
1215 |
self.assertContainsRe(str(err), |
|
1216 |
"^File exists: .+/foo") |
|
1217 |
||
3535.6.1
by James Westby
Handle a file turning in to a directory in TreeTransform. |
1218 |
def test_file_to_directory(self): |
1219 |
wt = self.make_branch_and_tree('.') |
|
3535.6.2
by James Westby
Fixes from review. Thanks Aaron and John. |
1220 |
self.build_tree(['foo']) |
3535.6.1
by James Westby
Handle a file turning in to a directory in TreeTransform. |
1221 |
wt.add(['foo']) |
1222 |
tt = TreeTransform(wt) |
|
3535.6.2
by James Westby
Fixes from review. Thanks Aaron and John. |
1223 |
self.addCleanup(tt.finalize) |
3535.6.3
by James Westby
Fix the test to not create transform conflicts. |
1224 |
foo_trans_id = tt.trans_id_tree_path("foo") |
1225 |
tt.delete_contents(foo_trans_id) |
|
1226 |
tt.create_directory(foo_trans_id) |
|
1227 |
bar_trans_id = tt.trans_id_tree_path("foo/bar") |
|
1228 |
tt.create_file(["aa\n"], bar_trans_id) |
|
1229 |
tt.version_file("bar-1", bar_trans_id) |
|
3535.6.2
by James Westby
Fixes from review. Thanks Aaron and John. |
1230 |
tt.apply() |
3535.6.1
by James Westby
Handle a file turning in to a directory in TreeTransform. |
1231 |
self.failUnlessExists("foo/bar") |
1232 |
||
2502.1.3
by Aaron Bentley
Don't cause errors when creating contents for trans_ids with no parent/name |
1233 |
|
1534.7.93
by Aaron Bentley
Added text merge test |
1234 |
class TransformGroup(object): |
3063.1.1
by Alexander Belchenko
Catch OSError 17 (file exists) in final phase of tree transform and show filename to user (#111758). |
1235 |
|
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
1236 |
def __init__(self, dirname, root_id): |
1534.7.101
by Aaron Bentley
Got conflicts on symlinks working properly |
1237 |
self.name = dirname |
1534.7.93
by Aaron Bentley
Added text merge test |
1238 |
os.mkdir(dirname) |
1558.1.3
by Aaron Bentley
Fixed deprecated op use in test suite |
1239 |
self.wt = BzrDir.create_standalone_workingtree(dirname) |
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
1240 |
self.wt.set_root_id(root_id) |
1558.1.3
by Aaron Bentley
Fixed deprecated op use in test suite |
1241 |
self.b = self.wt.branch |
1534.7.93
by Aaron Bentley
Added text merge test |
1242 |
self.tt = TreeTransform(self.wt) |
1534.7.181
by Aaron Bentley
Renamed a bunch of functions |
1243 |
self.root = self.tt.trans_id_tree_file_id(self.wt.get_root_id()) |
1534.7.93
by Aaron Bentley
Added text merge test |
1244 |
|
1551.11.1
by Aaron Bentley
Initial work on converting TreeTransform to iter_changes format |
1245 |
|
1534.7.95
by Aaron Bentley
Added more text merge tests |
1246 |
def conflict_text(tree, merge): |
1247 |
template = '%s TREE\n%s%s\n%s%s MERGE-SOURCE\n' |
|
1248 |
return template % ('<' * 7, tree, '=' * 7, merge, '>' * 7) |
|
1249 |
||
1534.7.93
by Aaron Bentley
Added text merge test |
1250 |
|
1251 |
class TestTransformMerge(TestCaseInTempDir): |
|
3199.1.5
by Vincent Ladeuil
Fix two more leaking tmp dirs, by reworking TransformPreview lock handling. |
1252 |
|
1534.7.93
by Aaron Bentley
Added text merge test |
1253 |
def test_text_merge(self): |
2116.4.1
by John Arbash Meinel
Update file and revision id generators. |
1254 |
root_id = generate_ids.gen_root_id() |
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
1255 |
base = TransformGroup("base", root_id) |
1534.7.93
by Aaron Bentley
Added text merge test |
1256 |
base.tt.new_file('a', base.root, 'a\nb\nc\nd\be\n', 'a') |
1534.7.95
by Aaron Bentley
Added more text merge tests |
1257 |
base.tt.new_file('b', base.root, 'b1', 'b') |
1258 |
base.tt.new_file('c', base.root, 'c', 'c') |
|
1259 |
base.tt.new_file('d', base.root, 'd', 'd') |
|
1260 |
base.tt.new_file('e', base.root, 'e', 'e') |
|
1261 |
base.tt.new_file('f', base.root, 'f', 'f') |
|
1534.7.96
by Aaron Bentley
Tested with BASE as directory |
1262 |
base.tt.new_directory('g', base.root, 'g') |
1534.7.97
by Aaron Bentley
Ensured foo.BASE is a directory if there's a conflict |
1263 |
base.tt.new_directory('h', base.root, 'h') |
1534.7.93
by Aaron Bentley
Added text merge test |
1264 |
base.tt.apply() |
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
1265 |
other = TransformGroup("other", root_id) |
1534.7.93
by Aaron Bentley
Added text merge test |
1266 |
other.tt.new_file('a', other.root, 'y\nb\nc\nd\be\n', 'a') |
1534.7.95
by Aaron Bentley
Added more text merge tests |
1267 |
other.tt.new_file('b', other.root, 'b2', 'b') |
1268 |
other.tt.new_file('c', other.root, 'c2', 'c') |
|
1269 |
other.tt.new_file('d', other.root, 'd', 'd') |
|
1270 |
other.tt.new_file('e', other.root, 'e2', 'e') |
|
1271 |
other.tt.new_file('f', other.root, 'f', 'f') |
|
1534.7.96
by Aaron Bentley
Tested with BASE as directory |
1272 |
other.tt.new_file('g', other.root, 'g', 'g') |
1534.7.97
by Aaron Bentley
Ensured foo.BASE is a directory if there's a conflict |
1273 |
other.tt.new_file('h', other.root, 'h\ni\nj\nk\n', 'h') |
1534.7.99
by Aaron Bentley
Handle non-existent BASE properly |
1274 |
other.tt.new_file('i', other.root, 'h\ni\nj\nk\n', 'i') |
1534.7.93
by Aaron Bentley
Added text merge test |
1275 |
other.tt.apply() |
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
1276 |
this = TransformGroup("this", root_id) |
1534.7.93
by Aaron Bentley
Added text merge test |
1277 |
this.tt.new_file('a', this.root, 'a\nb\nc\nd\bz\n', 'a') |
1534.7.95
by Aaron Bentley
Added more text merge tests |
1278 |
this.tt.new_file('b', this.root, 'b', 'b') |
1279 |
this.tt.new_file('c', this.root, 'c', 'c') |
|
1280 |
this.tt.new_file('d', this.root, 'd2', 'd') |
|
1281 |
this.tt.new_file('e', this.root, 'e2', 'e') |
|
1282 |
this.tt.new_file('f', this.root, 'f', 'f') |
|
1534.7.96
by Aaron Bentley
Tested with BASE as directory |
1283 |
this.tt.new_file('g', this.root, 'g', 'g') |
1534.7.97
by Aaron Bentley
Ensured foo.BASE is a directory if there's a conflict |
1284 |
this.tt.new_file('h', this.root, '1\n2\n3\n4\n', 'h') |
1534.7.99
by Aaron Bentley
Handle non-existent BASE properly |
1285 |
this.tt.new_file('i', this.root, '1\n2\n3\n4\n', 'i') |
1534.7.93
by Aaron Bentley
Added text merge test |
1286 |
this.tt.apply() |
3008.1.11
by Michael Hudson
restore the default behaviour of Merge3Merger.__init__(). |
1287 |
Merge3Merger(this.wt, this.wt, base.wt, other.wt) |
3008.1.6
by Michael Hudson
chop up Merge3Merger.__init__ into pieces |
1288 |
|
1534.7.95
by Aaron Bentley
Added more text merge tests |
1289 |
# textual merge
|
1534.7.93
by Aaron Bentley
Added text merge test |
1290 |
self.assertEqual(this.wt.get_file('a').read(), 'y\nb\nc\nd\bz\n') |
1534.7.95
by Aaron Bentley
Added more text merge tests |
1291 |
# three-way text conflict
|
1292 |
self.assertEqual(this.wt.get_file('b').read(), |
|
1293 |
conflict_text('b', 'b2')) |
|
1294 |
# OTHER wins
|
|
1295 |
self.assertEqual(this.wt.get_file('c').read(), 'c2') |
|
1296 |
# THIS wins
|
|
1297 |
self.assertEqual(this.wt.get_file('d').read(), 'd2') |
|
1298 |
# Ambigious clean merge
|
|
1299 |
self.assertEqual(this.wt.get_file('e').read(), 'e2') |
|
1300 |
# No change
|
|
1301 |
self.assertEqual(this.wt.get_file('f').read(), 'f') |
|
1534.7.97
by Aaron Bentley
Ensured foo.BASE is a directory if there's a conflict |
1302 |
# Correct correct results when THIS == OTHER
|
1534.7.96
by Aaron Bentley
Tested with BASE as directory |
1303 |
self.assertEqual(this.wt.get_file('g').read(), 'g') |
1534.7.97
by Aaron Bentley
Ensured foo.BASE is a directory if there's a conflict |
1304 |
# Text conflict when THIS & OTHER are text and BASE is dir
|
1305 |
self.assertEqual(this.wt.get_file('h').read(), |
|
1306 |
conflict_text('1\n2\n3\n4\n', 'h\ni\nj\nk\n')) |
|
1307 |
self.assertEqual(this.wt.get_file_byname('h.THIS').read(), |
|
1308 |
'1\n2\n3\n4\n') |
|
1309 |
self.assertEqual(this.wt.get_file_byname('h.OTHER').read(), |
|
1310 |
'h\ni\nj\nk\n') |
|
1311 |
self.assertEqual(file_kind(this.wt.abspath('h.BASE')), 'directory') |
|
1534.7.99
by Aaron Bentley
Handle non-existent BASE properly |
1312 |
self.assertEqual(this.wt.get_file('i').read(), |
1313 |
conflict_text('1\n2\n3\n4\n', 'h\ni\nj\nk\n')) |
|
1314 |
self.assertEqual(this.wt.get_file_byname('i.THIS').read(), |
|
1315 |
'1\n2\n3\n4\n') |
|
1316 |
self.assertEqual(this.wt.get_file_byname('i.OTHER').read(), |
|
1317 |
'h\ni\nj\nk\n') |
|
1318 |
self.assertEqual(os.path.exists(this.wt.abspath('i.BASE')), False) |
|
1534.7.192
by Aaron Bentley
Record hashes produced by merges |
1319 |
modified = ['a', 'b', 'c', 'h', 'i'] |
1320 |
merge_modified = this.wt.merge_modified() |
|
1321 |
self.assertSubset(merge_modified, modified) |
|
1322 |
self.assertEqual(len(merge_modified), len(modified)) |
|
1323 |
file(this.wt.id2abspath('a'), 'wb').write('booga') |
|
1324 |
modified.pop(0) |
|
1325 |
merge_modified = this.wt.merge_modified() |
|
1326 |
self.assertSubset(merge_modified, modified) |
|
1327 |
self.assertEqual(len(merge_modified), len(modified)) |
|
1558.12.10
by Aaron Bentley
Be robust when merge_hash file_id not in inventory |
1328 |
this.wt.remove('b') |
2796.1.4
by Aaron Bentley
Fix up various test cases |
1329 |
this.wt.revert() |
1534.7.101
by Aaron Bentley
Got conflicts on symlinks working properly |
1330 |
|
1331 |
def test_file_merge(self): |
|
2949.5.1
by Alexander Belchenko
selftest: use SymlinkFeature instead of TestSkipped where appropriate |
1332 |
self.requireFeature(SymlinkFeature) |
2116.4.1
by John Arbash Meinel
Update file and revision id generators. |
1333 |
root_id = generate_ids.gen_root_id() |
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
1334 |
base = TransformGroup("BASE", root_id) |
1335 |
this = TransformGroup("THIS", root_id) |
|
1336 |
other = TransformGroup("OTHER", root_id) |
|
1534.7.101
by Aaron Bentley
Got conflicts on symlinks working properly |
1337 |
for tg in this, base, other: |
1338 |
tg.tt.new_directory('a', tg.root, 'a') |
|
1339 |
tg.tt.new_symlink('b', tg.root, 'b', 'b') |
|
1340 |
tg.tt.new_file('c', tg.root, 'c', 'c') |
|
1341 |
tg.tt.new_symlink('d', tg.root, tg.name, 'd') |
|
1534.7.104
by Aaron Bentley
Fixed set_versioned, enhanced conflict testing |
1342 |
targets = ((base, 'base-e', 'base-f', None, None), |
1343 |
(this, 'other-e', 'this-f', 'other-g', 'this-h'), |
|
1344 |
(other, 'other-e', None, 'other-g', 'other-h')) |
|
1345 |
for tg, e_target, f_target, g_target, h_target in targets: |
|
1346 |
for link, target in (('e', e_target), ('f', f_target), |
|
1347 |
('g', g_target), ('h', h_target)): |
|
1348 |
if target is not None: |
|
1349 |
tg.tt.new_symlink(link, tg.root, target, link) |
|
1534.7.102
by Aaron Bentley
Deleted old pre-conflict contents |
1350 |
|
1351 |
for tg in this, base, other: |
|
1534.7.101
by Aaron Bentley
Got conflicts on symlinks working properly |
1352 |
tg.tt.apply() |
3008.1.11
by Michael Hudson
restore the default behaviour of Merge3Merger.__init__(). |
1353 |
Merge3Merger(this.wt, this.wt, base.wt, other.wt) |
1534.7.101
by Aaron Bentley
Got conflicts on symlinks working properly |
1354 |
self.assertIs(os.path.isdir(this.wt.abspath('a')), True) |
1355 |
self.assertIs(os.path.islink(this.wt.abspath('b')), True) |
|
1356 |
self.assertIs(os.path.isfile(this.wt.abspath('c')), True) |
|
1357 |
for suffix in ('THIS', 'BASE', 'OTHER'): |
|
1358 |
self.assertEqual(os.readlink(this.wt.abspath('d.'+suffix)), suffix) |
|
1534.7.102
by Aaron Bentley
Deleted old pre-conflict contents |
1359 |
self.assertIs(os.path.lexists(this.wt.abspath('d')), False) |
1534.7.104
by Aaron Bentley
Fixed set_versioned, enhanced conflict testing |
1360 |
self.assertEqual(this.wt.id2path('d'), 'd.OTHER') |
1361 |
self.assertEqual(this.wt.id2path('f'), 'f.THIS') |
|
1534.7.102
by Aaron Bentley
Deleted old pre-conflict contents |
1362 |
self.assertEqual(os.readlink(this.wt.abspath('e')), 'other-e') |
1363 |
self.assertIs(os.path.lexists(this.wt.abspath('e.THIS')), False) |
|
1364 |
self.assertIs(os.path.lexists(this.wt.abspath('e.OTHER')), False) |
|
1365 |
self.assertIs(os.path.lexists(this.wt.abspath('e.BASE')), False) |
|
1534.7.104
by Aaron Bentley
Fixed set_versioned, enhanced conflict testing |
1366 |
self.assertIs(os.path.lexists(this.wt.abspath('g')), True) |
1367 |
self.assertIs(os.path.lexists(this.wt.abspath('g.BASE')), False) |
|
1368 |
self.assertIs(os.path.lexists(this.wt.abspath('h')), False) |
|
1369 |
self.assertIs(os.path.lexists(this.wt.abspath('h.BASE')), False) |
|
1370 |
self.assertIs(os.path.lexists(this.wt.abspath('h.THIS')), True) |
|
1371 |
self.assertIs(os.path.lexists(this.wt.abspath('h.OTHER')), True) |
|
1534.7.105
by Aaron Bentley
Got merge with rename working |
1372 |
|
1373 |
def test_filename_merge(self): |
|
2116.4.1
by John Arbash Meinel
Update file and revision id generators. |
1374 |
root_id = generate_ids.gen_root_id() |
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
1375 |
base = TransformGroup("BASE", root_id) |
1376 |
this = TransformGroup("THIS", root_id) |
|
1377 |
other = TransformGroup("OTHER", root_id) |
|
1534.7.105
by Aaron Bentley
Got merge with rename working |
1378 |
base_a, this_a, other_a = [t.tt.new_directory('a', t.root, 'a') |
1379 |
for t in [base, this, other]] |
|
1380 |
base_b, this_b, other_b = [t.tt.new_directory('b', t.root, 'b') |
|
1381 |
for t in [base, this, other]] |
|
1382 |
base.tt.new_directory('c', base_a, 'c') |
|
1383 |
this.tt.new_directory('c1', this_a, 'c') |
|
1384 |
other.tt.new_directory('c', other_b, 'c') |
|
1385 |
||
1386 |
base.tt.new_directory('d', base_a, 'd') |
|
1387 |
this.tt.new_directory('d1', this_b, 'd') |
|
1388 |
other.tt.new_directory('d', other_a, 'd') |
|
1389 |
||
1390 |
base.tt.new_directory('e', base_a, 'e') |
|
1391 |
this.tt.new_directory('e', this_a, 'e') |
|
1392 |
other.tt.new_directory('e1', other_b, 'e') |
|
1393 |
||
1394 |
base.tt.new_directory('f', base_a, 'f') |
|
1395 |
this.tt.new_directory('f1', this_b, 'f') |
|
1396 |
other.tt.new_directory('f1', other_b, 'f') |
|
1397 |
||
1398 |
for tg in [this, base, other]: |
|
1399 |
tg.tt.apply() |
|
3008.1.11
by Michael Hudson
restore the default behaviour of Merge3Merger.__init__(). |
1400 |
Merge3Merger(this.wt, this.wt, base.wt, other.wt) |
1534.7.176
by abentley
Fixed up tests for Windows |
1401 |
self.assertEqual(this.wt.id2path('c'), pathjoin('b/c1')) |
1402 |
self.assertEqual(this.wt.id2path('d'), pathjoin('b/d1')) |
|
1403 |
self.assertEqual(this.wt.id2path('e'), pathjoin('b/e1')) |
|
1404 |
self.assertEqual(this.wt.id2path('f'), pathjoin('b/f1')) |
|
1534.7.105
by Aaron Bentley
Got merge with rename working |
1405 |
|
1406 |
def test_filename_merge_conflicts(self): |
|
2116.4.1
by John Arbash Meinel
Update file and revision id generators. |
1407 |
root_id = generate_ids.gen_root_id() |
1731.1.33
by Aaron Bentley
Revert no-special-root changes |
1408 |
base = TransformGroup("BASE", root_id) |
1409 |
this = TransformGroup("THIS", root_id) |
|
1410 |
other = TransformGroup("OTHER", root_id) |
|
1534.7.105
by Aaron Bentley
Got merge with rename working |
1411 |
base_a, this_a, other_a = [t.tt.new_directory('a', t.root, 'a') |
1412 |
for t in [base, this, other]] |
|
1413 |
base_b, this_b, other_b = [t.tt.new_directory('b', t.root, 'b') |
|
1414 |
for t in [base, this, other]] |
|
1415 |
||
1416 |
base.tt.new_file('g', base_a, 'g', 'g') |
|
1417 |
other.tt.new_file('g1', other_b, 'g1', 'g') |
|
1418 |
||
1419 |
base.tt.new_file('h', base_a, 'h', 'h') |
|
1420 |
this.tt.new_file('h1', this_b, 'h1', 'h') |
|
1421 |
||
1422 |
base.tt.new_file('i', base.root, 'i', 'i') |
|
1534.7.153
by Aaron Bentley
Handled test cases involving symlinks |
1423 |
other.tt.new_directory('i1', this_b, 'i') |
1534.7.105
by Aaron Bentley
Got merge with rename working |
1424 |
|
1425 |
for tg in [this, base, other]: |
|
1426 |
tg.tt.apply() |
|
3008.1.11
by Michael Hudson
restore the default behaviour of Merge3Merger.__init__(). |
1427 |
Merge3Merger(this.wt, this.wt, base.wt, other.wt) |
1534.7.105
by Aaron Bentley
Got merge with rename working |
1428 |
|
1534.7.176
by abentley
Fixed up tests for Windows |
1429 |
self.assertEqual(this.wt.id2path('g'), pathjoin('b/g1.OTHER')) |
1534.7.105
by Aaron Bentley
Got merge with rename working |
1430 |
self.assertIs(os.path.lexists(this.wt.abspath('b/g1.BASE')), True) |
1431 |
self.assertIs(os.path.lexists(this.wt.abspath('b/g1.THIS')), False) |
|
1534.7.176
by abentley
Fixed up tests for Windows |
1432 |
self.assertEqual(this.wt.id2path('h'), pathjoin('b/h1.THIS')) |
1534.7.105
by Aaron Bentley
Got merge with rename working |
1433 |
self.assertIs(os.path.lexists(this.wt.abspath('b/h1.BASE')), True) |
1434 |
self.assertIs(os.path.lexists(this.wt.abspath('b/h1.OTHER')), False) |
|
1534.7.176
by abentley
Fixed up tests for Windows |
1435 |
self.assertEqual(this.wt.id2path('i'), pathjoin('b/i1.OTHER')) |
1534.7.183
by Aaron Bentley
Fixed build_tree with symlinks |
1436 |
|
2027.1.1
by John Arbash Meinel
Fix bug #56549, and write a direct test that the right path is being statted |
1437 |
|
1966.1.1
by Aaron Bentley
Implement disk-content merge and conflict resolution for build_tree |
1438 |
class TestBuildTree(tests.TestCaseWithTransport): |
1439 |
||
3006.2.2
by Alexander Belchenko
tests added. |
1440 |
def test_build_tree_with_symlinks(self): |
2949.5.1
by Alexander Belchenko
selftest: use SymlinkFeature instead of TestSkipped where appropriate |
1441 |
self.requireFeature(SymlinkFeature) |
1534.7.183
by Aaron Bentley
Fixed build_tree with symlinks |
1442 |
os.mkdir('a') |
1443 |
a = BzrDir.create_standalone_workingtree('a') |
|
1444 |
os.mkdir('a/foo') |
|
1445 |
file('a/foo/bar', 'wb').write('contents') |
|
1446 |
os.symlink('a/foo/bar', 'a/foo/baz') |
|
1447 |
a.add(['foo', 'foo/bar', 'foo/baz']) |
|
1448 |
a.commit('initial commit') |
|
1449 |
b = BzrDir.create_standalone_workingtree('b') |
|
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
1450 |
basis = a.basis_tree() |
1451 |
basis.lock_read() |
|
1452 |
self.addCleanup(basis.unlock) |
|
1453 |
build_tree(basis, b) |
|
1534.7.183
by Aaron Bentley
Fixed build_tree with symlinks |
1454 |
self.assertIs(os.path.isdir('b/foo'), True) |
1455 |
self.assertEqual(file('b/foo/bar', 'rb').read(), "contents") |
|
1456 |
self.assertEqual(os.readlink('b/foo/baz'), 'a/foo/bar') |
|
1966.1.1
by Aaron Bentley
Implement disk-content merge and conflict resolution for build_tree |
1457 |
|
2100.3.21
by Aaron Bentley
Work on checking out by-reference trees |
1458 |
def test_build_with_references(self): |
2255.2.194
by Robert Collins
[BROKEN] Many updates to stop using experimental formats in tests. |
1459 |
tree = self.make_branch_and_tree('source', |
1460 |
format='dirstate-with-subtree') |
|
1461 |
subtree = self.make_branch_and_tree('source/subtree', |
|
1462 |
format='dirstate-with-subtree') |
|
2100.3.21
by Aaron Bentley
Work on checking out by-reference trees |
1463 |
tree.add_reference(subtree) |
1464 |
tree.commit('a revision') |
|
1465 |
tree.branch.create_checkout('target') |
|
1466 |
self.failUnlessExists('target') |
|
1467 |
self.failUnlessExists('target/subtree') |
|
1468 |
||
1966.1.1
by Aaron Bentley
Implement disk-content merge and conflict resolution for build_tree |
1469 |
def test_file_conflict_handling(self): |
1470 |
"""Ensure that when building trees, conflict handling is done"""
|
|
1471 |
source = self.make_branch_and_tree('source') |
|
1472 |
target = self.make_branch_and_tree('target') |
|
1473 |
self.build_tree(['source/file', 'target/file']) |
|
1966.1.2
by Aaron Bentley
Divert files instead of failing to create them, update from review |
1474 |
source.add('file', 'new-file') |
1966.1.1
by Aaron Bentley
Implement disk-content merge and conflict resolution for build_tree |
1475 |
source.commit('added file') |
1476 |
build_tree(source.basis_tree(), target) |
|
1966.1.2
by Aaron Bentley
Divert files instead of failing to create them, update from review |
1477 |
self.assertEqual([DuplicateEntry('Moved existing file to', |
1478 |
'file.moved', 'file', None, 'new-file')], |
|
1479 |
target.conflicts()) |
|
1966.1.1
by Aaron Bentley
Implement disk-content merge and conflict resolution for build_tree |
1480 |
target2 = self.make_branch_and_tree('target2') |
1481 |
target_file = file('target2/file', 'wb') |
|
1482 |
try: |
|
1966.1.2
by Aaron Bentley
Divert files instead of failing to create them, update from review |
1483 |
source_file = file('source/file', 'rb') |
1484 |
try: |
|
1485 |
target_file.write(source_file.read()) |
|
1486 |
finally: |
|
1487 |
source_file.close() |
|
1966.1.1
by Aaron Bentley
Implement disk-content merge and conflict resolution for build_tree |
1488 |
finally: |
1489 |
target_file.close() |
|
1490 |
build_tree(source.basis_tree(), target2) |
|
1966.1.2
by Aaron Bentley
Divert files instead of failing to create them, update from review |
1491 |
self.assertEqual([], target2.conflicts()) |
1966.1.1
by Aaron Bentley
Implement disk-content merge and conflict resolution for build_tree |
1492 |
|
1493 |
def test_symlink_conflict_handling(self): |
|
1494 |
"""Ensure that when building trees, conflict handling is done"""
|
|
2949.5.1
by Alexander Belchenko
selftest: use SymlinkFeature instead of TestSkipped where appropriate |
1495 |
self.requireFeature(SymlinkFeature) |
1966.1.1
by Aaron Bentley
Implement disk-content merge and conflict resolution for build_tree |
1496 |
source = self.make_branch_and_tree('source') |
1497 |
os.symlink('foo', 'source/symlink') |
|
1966.1.2
by Aaron Bentley
Divert files instead of failing to create them, update from review |
1498 |
source.add('symlink', 'new-symlink') |
1966.1.1
by Aaron Bentley
Implement disk-content merge and conflict resolution for build_tree |
1499 |
source.commit('added file') |
1500 |
target = self.make_branch_and_tree('target') |
|
1501 |
os.symlink('bar', 'target/symlink') |
|
1502 |
build_tree(source.basis_tree(), target) |
|
1966.1.2
by Aaron Bentley
Divert files instead of failing to create them, update from review |
1503 |
self.assertEqual([DuplicateEntry('Moved existing file to', |
1504 |
'symlink.moved', 'symlink', None, 'new-symlink')], |
|
1505 |
target.conflicts()) |
|
1966.1.1
by Aaron Bentley
Implement disk-content merge and conflict resolution for build_tree |
1506 |
target = self.make_branch_and_tree('target2') |
1507 |
os.symlink('foo', 'target2/symlink') |
|
1508 |
build_tree(source.basis_tree(), target) |
|
1966.1.2
by Aaron Bentley
Divert files instead of failing to create them, update from review |
1509 |
self.assertEqual([], target.conflicts()) |
1966.1.1
by Aaron Bentley
Implement disk-content merge and conflict resolution for build_tree |
1510 |
|
1511 |
def test_directory_conflict_handling(self): |
|
1512 |
"""Ensure that when building trees, conflict handling is done"""
|
|
1513 |
source = self.make_branch_and_tree('source') |
|
1514 |
target = self.make_branch_and_tree('target') |
|
1515 |
self.build_tree(['source/dir1/', 'source/dir1/file', 'target/dir1/']) |
|
1966.1.2
by Aaron Bentley
Divert files instead of failing to create them, update from review |
1516 |
source.add(['dir1', 'dir1/file'], ['new-dir1', 'new-file']) |
1966.1.1
by Aaron Bentley
Implement disk-content merge and conflict resolution for build_tree |
1517 |
source.commit('added file') |
1518 |
build_tree(source.basis_tree(), target) |
|
1966.1.2
by Aaron Bentley
Divert files instead of failing to create them, update from review |
1519 |
self.assertEqual([], target.conflicts()) |
1966.1.1
by Aaron Bentley
Implement disk-content merge and conflict resolution for build_tree |
1520 |
self.failUnlessExists('target/dir1/file') |
1521 |
||
1522 |
# Ensure contents are merged
|
|
1523 |
target = self.make_branch_and_tree('target2') |
|
1524 |
self.build_tree(['target2/dir1/', 'target2/dir1/file2']) |
|
1525 |
build_tree(source.basis_tree(), target) |
|
1966.1.2
by Aaron Bentley
Divert files instead of failing to create them, update from review |
1526 |
self.assertEqual([], target.conflicts()) |
1966.1.1
by Aaron Bentley
Implement disk-content merge and conflict resolution for build_tree |
1527 |
self.failUnlessExists('target2/dir1/file2') |
1528 |
self.failUnlessExists('target2/dir1/file') |
|
1529 |
||
1530 |
# Ensure new contents are suppressed for existing branches
|
|
1966.1.2
by Aaron Bentley
Divert files instead of failing to create them, update from review |
1531 |
target = self.make_branch_and_tree('target3') |
1532 |
self.make_branch('target3/dir1') |
|
1966.1.1
by Aaron Bentley
Implement disk-content merge and conflict resolution for build_tree |
1533 |
self.build_tree(['target3/dir1/file2']) |
1534 |
build_tree(source.basis_tree(), target) |
|
1966.1.2
by Aaron Bentley
Divert files instead of failing to create them, update from review |
1535 |
self.failIfExists('target3/dir1/file') |
1966.1.1
by Aaron Bentley
Implement disk-content merge and conflict resolution for build_tree |
1536 |
self.failUnlessExists('target3/dir1/file2') |
1966.1.2
by Aaron Bentley
Divert files instead of failing to create them, update from review |
1537 |
self.failUnlessExists('target3/dir1.diverted/file') |
1538 |
self.assertEqual([DuplicateEntry('Diverted to', |
|
1539 |
'dir1.diverted', 'dir1', 'new-dir1', None)], |
|
1540 |
target.conflicts()) |
|
1541 |
||
1542 |
target = self.make_branch_and_tree('target4') |
|
1543 |
self.build_tree(['target4/dir1/']) |
|
1544 |
self.make_branch('target4/dir1/file') |
|
1545 |
build_tree(source.basis_tree(), target) |
|
1546 |
self.failUnlessExists('target4/dir1/file') |
|
1547 |
self.assertEqual('directory', file_kind('target4/dir1/file')) |
|
1548 |
self.failUnlessExists('target4/dir1/file.diverted') |
|
1549 |
self.assertEqual([DuplicateEntry('Diverted to', |
|
1550 |
'dir1/file.diverted', 'dir1/file', 'new-file', None)], |
|
1551 |
target.conflicts()) |
|
1966.1.1
by Aaron Bentley
Implement disk-content merge and conflict resolution for build_tree |
1552 |
|
1553 |
def test_mixed_conflict_handling(self): |
|
1554 |
"""Ensure that when building trees, conflict handling is done"""
|
|
1555 |
source = self.make_branch_and_tree('source') |
|
1556 |
target = self.make_branch_and_tree('target') |
|
1557 |
self.build_tree(['source/name', 'target/name/']) |
|
1966.1.2
by Aaron Bentley
Divert files instead of failing to create them, update from review |
1558 |
source.add('name', 'new-name') |
1559 |
source.commit('added file') |
|
1560 |
build_tree(source.basis_tree(), target) |
|
1561 |
self.assertEqual([DuplicateEntry('Moved existing file to', |
|
1562 |
'name.moved', 'name', None, 'new-name')], target.conflicts()) |
|
1563 |
||
1564 |
def test_raises_in_populated(self): |
|
1565 |
source = self.make_branch_and_tree('source') |
|
1566 |
self.build_tree(['source/name']) |
|
1966.1.1
by Aaron Bentley
Implement disk-content merge and conflict resolution for build_tree |
1567 |
source.add('name') |
1966.1.2
by Aaron Bentley
Divert files instead of failing to create them, update from review |
1568 |
source.commit('added name') |
1569 |
target = self.make_branch_and_tree('target') |
|
1570 |
self.build_tree(['target/name']) |
|
1571 |
target.add('name') |
|
2090.2.1
by Martin Pool
Fix some code which relies on assertions and breaks under python -O |
1572 |
self.assertRaises(errors.WorkingTreeAlreadyPopulated, |
1573 |
build_tree, source.basis_tree(), target) |
|
1966.1.1
by Aaron Bentley
Implement disk-content merge and conflict resolution for build_tree |
1574 |
|
2502.1.1
by Aaron Bentley
Ensure renames only root children are renamed when building trees |
1575 |
def test_build_tree_rename_count(self): |
1576 |
source = self.make_branch_and_tree('source') |
|
1577 |
self.build_tree(['source/file1', 'source/dir1/']) |
|
1578 |
source.add(['file1', 'dir1']) |
|
1579 |
source.commit('add1') |
|
1580 |
target1 = self.make_branch_and_tree('target1') |
|
2502.1.6
by Aaron Bentley
Update from review comments |
1581 |
transform_result = build_tree(source.basis_tree(), target1) |
1582 |
self.assertEqual(2, transform_result.rename_count) |
|
2502.1.1
by Aaron Bentley
Ensure renames only root children are renamed when building trees |
1583 |
|
1584 |
self.build_tree(['source/dir1/file2']) |
|
1585 |
source.add(['dir1/file2']) |
|
1586 |
source.commit('add3') |
|
1587 |
target2 = self.make_branch_and_tree('target2') |
|
2502.1.6
by Aaron Bentley
Update from review comments |
1588 |
transform_result = build_tree(source.basis_tree(), target2) |
2502.1.1
by Aaron Bentley
Ensure renames only root children are renamed when building trees |
1589 |
# children of non-root directories should not be renamed
|
2502.1.6
by Aaron Bentley
Update from review comments |
1590 |
self.assertEqual(2, transform_result.rename_count) |
2502.1.1
by Aaron Bentley
Ensure renames only root children are renamed when building trees |
1591 |
|
3136.1.2
by Aaron Bentley
Implement hard-linking for build_tree |
1592 |
def create_ab_tree(self): |
1593 |
"""Create a committed test tree with two files"""
|
|
1594 |
source = self.make_branch_and_tree('source') |
|
1595 |
self.build_tree_contents([('source/file1', 'A')]) |
|
1596 |
self.build_tree_contents([('source/file2', 'B')]) |
|
1597 |
source.add(['file1', 'file2'], ['file1-id', 'file2-id']) |
|
1598 |
source.commit('commit files') |
|
1599 |
source.lock_write() |
|
1600 |
self.addCleanup(source.unlock) |
|
1601 |
return source |
|
1602 |
||
3123.5.1
by Aaron Bentley
Make build-tree able to use an additional 'accelerator' tree |
1603 |
def test_build_tree_accelerator_tree(self): |
3136.1.2
by Aaron Bentley
Implement hard-linking for build_tree |
1604 |
source = self.create_ab_tree() |
3123.5.1
by Aaron Bentley
Make build-tree able to use an additional 'accelerator' tree |
1605 |
self.build_tree_contents([('source/file2', 'C')]) |
1606 |
calls = [] |
|
1607 |
real_source_get_file = source.get_file |
|
1608 |
def get_file(file_id, path=None): |
|
1609 |
calls.append(file_id) |
|
1610 |
return real_source_get_file(file_id, path) |
|
1611 |
source.get_file = get_file |
|
1612 |
target = self.make_branch_and_tree('target') |
|
3123.5.19
by Aaron Bentley
Ensure content is exactly the same, when accelerator used |
1613 |
revision_tree = source.basis_tree() |
1614 |
revision_tree.lock_read() |
|
1615 |
self.addCleanup(revision_tree.unlock) |
|
1616 |
build_tree(revision_tree, target, source) |
|
3123.5.1
by Aaron Bentley
Make build-tree able to use an additional 'accelerator' tree |
1617 |
self.assertEqual(['file1-id'], calls) |
3123.5.19
by Aaron Bentley
Ensure content is exactly the same, when accelerator used |
1618 |
target.lock_read() |
1619 |
self.addCleanup(target.unlock) |
|
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
1620 |
self.assertEqual([], list(target.iter_changes(revision_tree))) |
3123.5.1
by Aaron Bentley
Make build-tree able to use an additional 'accelerator' tree |
1621 |
|
3123.5.4
by Aaron Bentley
Use an accelerator tree when branching, handle no-such-id correctly |
1622 |
def test_build_tree_accelerator_tree_missing_file(self): |
3136.1.2
by Aaron Bentley
Implement hard-linking for build_tree |
1623 |
source = self.create_ab_tree() |
3123.5.4
by Aaron Bentley
Use an accelerator tree when branching, handle no-such-id correctly |
1624 |
os.unlink('source/file1') |
1625 |
source.remove(['file2']) |
|
1626 |
target = self.make_branch_and_tree('target') |
|
3123.5.19
by Aaron Bentley
Ensure content is exactly the same, when accelerator used |
1627 |
revision_tree = source.basis_tree() |
1628 |
revision_tree.lock_read() |
|
1629 |
self.addCleanup(revision_tree.unlock) |
|
1630 |
build_tree(revision_tree, target, source) |
|
1631 |
target.lock_read() |
|
1632 |
self.addCleanup(target.unlock) |
|
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
1633 |
self.assertEqual([], list(target.iter_changes(revision_tree))) |
3123.5.4
by Aaron Bentley
Use an accelerator tree when branching, handle no-such-id correctly |
1634 |
|
3123.5.16
by Aaron Bentley
Test handling of conversion to non-file |
1635 |
def test_build_tree_accelerator_wrong_kind(self): |
3146.4.8
by Aaron Bentley
Add missing symlink requirement |
1636 |
self.requireFeature(SymlinkFeature) |
3123.5.16
by Aaron Bentley
Test handling of conversion to non-file |
1637 |
source = self.make_branch_and_tree('source') |
1638 |
self.build_tree_contents([('source/file1', '')]) |
|
1639 |
self.build_tree_contents([('source/file2', '')]) |
|
1640 |
source.add(['file1', 'file2'], ['file1-id', 'file2-id']) |
|
1641 |
source.commit('commit files') |
|
1642 |
os.unlink('source/file2') |
|
1643 |
self.build_tree_contents([('source/file2/', 'C')]) |
|
1644 |
os.unlink('source/file1') |
|
1645 |
os.symlink('file2', 'source/file1') |
|
1646 |
calls = [] |
|
1647 |
real_source_get_file = source.get_file |
|
1648 |
def get_file(file_id, path=None): |
|
1649 |
calls.append(file_id) |
|
1650 |
return real_source_get_file(file_id, path) |
|
1651 |
source.get_file = get_file |
|
1652 |
target = self.make_branch_and_tree('target') |
|
3123.5.19
by Aaron Bentley
Ensure content is exactly the same, when accelerator used |
1653 |
revision_tree = source.basis_tree() |
1654 |
revision_tree.lock_read() |
|
1655 |
self.addCleanup(revision_tree.unlock) |
|
1656 |
build_tree(revision_tree, target, source) |
|
3123.5.16
by Aaron Bentley
Test handling of conversion to non-file |
1657 |
self.assertEqual([], calls) |
3123.5.19
by Aaron Bentley
Ensure content is exactly the same, when accelerator used |
1658 |
target.lock_read() |
1659 |
self.addCleanup(target.unlock) |
|
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
1660 |
self.assertEqual([], list(target.iter_changes(revision_tree))) |
3123.5.16
by Aaron Bentley
Test handling of conversion to non-file |
1661 |
|
3136.1.2
by Aaron Bentley
Implement hard-linking for build_tree |
1662 |
def test_build_tree_hardlink(self): |
1663 |
self.requireFeature(HardlinkFeature) |
|
1664 |
source = self.create_ab_tree() |
|
1665 |
target = self.make_branch_and_tree('target') |
|
1666 |
revision_tree = source.basis_tree() |
|
1667 |
revision_tree.lock_read() |
|
1668 |
self.addCleanup(revision_tree.unlock) |
|
1669 |
build_tree(revision_tree, target, source, hardlink=True) |
|
1670 |
target.lock_read() |
|
1671 |
self.addCleanup(target.unlock) |
|
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
1672 |
self.assertEqual([], list(target.iter_changes(revision_tree))) |
3136.1.2
by Aaron Bentley
Implement hard-linking for build_tree |
1673 |
source_stat = os.stat('source/file1') |
1674 |
target_stat = os.stat('target/file1') |
|
1675 |
self.assertEqual(source_stat, target_stat) |
|
1676 |
||
1677 |
# Explicitly disallowing hardlinks should prevent them.
|
|
1678 |
target2 = self.make_branch_and_tree('target2') |
|
1679 |
build_tree(revision_tree, target2, source, hardlink=False) |
|
1680 |
target2.lock_read() |
|
1681 |
self.addCleanup(target2.unlock) |
|
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
1682 |
self.assertEqual([], list(target2.iter_changes(revision_tree))) |
3136.1.2
by Aaron Bentley
Implement hard-linking for build_tree |
1683 |
source_stat = os.stat('source/file1') |
1684 |
target2_stat = os.stat('target2/file1') |
|
1685 |
self.assertNotEqual(source_stat, target2_stat) |
|
1686 |
||
3137.1.1
by Aaron Bentley
Fix build_tree acceleration when file is moved in accelerator_tree |
1687 |
def test_build_tree_accelerator_tree_moved(self): |
1688 |
source = self.make_branch_and_tree('source') |
|
1689 |
self.build_tree_contents([('source/file1', 'A')]) |
|
1690 |
source.add(['file1'], ['file1-id']) |
|
1691 |
source.commit('commit files') |
|
1692 |
source.rename_one('file1', 'file2') |
|
1693 |
source.lock_read() |
|
1694 |
self.addCleanup(source.unlock) |
|
1695 |
target = self.make_branch_and_tree('target') |
|
1696 |
revision_tree = source.basis_tree() |
|
1697 |
revision_tree.lock_read() |
|
1698 |
self.addCleanup(revision_tree.unlock) |
|
1699 |
build_tree(revision_tree, target, source) |
|
1700 |
target.lock_read() |
|
1701 |
self.addCleanup(target.unlock) |
|
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
1702 |
self.assertEqual([], list(target.iter_changes(revision_tree))) |
3137.1.1
by Aaron Bentley
Fix build_tree acceleration when file is moved in accelerator_tree |
1703 |
|
3136.1.2
by Aaron Bentley
Implement hard-linking for build_tree |
1704 |
def test_build_tree_hardlinks_preserve_execute(self): |
1705 |
self.requireFeature(HardlinkFeature) |
|
1706 |
source = self.create_ab_tree() |
|
1707 |
tt = TreeTransform(source) |
|
1708 |
trans_id = tt.trans_id_tree_file_id('file1-id') |
|
1709 |
tt.set_executability(True, trans_id) |
|
1710 |
tt.apply() |
|
1711 |
self.assertTrue(source.is_executable('file1-id')) |
|
1712 |
target = self.make_branch_and_tree('target') |
|
1713 |
revision_tree = source.basis_tree() |
|
1714 |
revision_tree.lock_read() |
|
1715 |
self.addCleanup(revision_tree.unlock) |
|
1716 |
build_tree(revision_tree, target, source, hardlink=True) |
|
1717 |
target.lock_read() |
|
1718 |
self.addCleanup(target.unlock) |
|
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
1719 |
self.assertEqual([], list(target.iter_changes(revision_tree))) |
3136.1.2
by Aaron Bentley
Implement hard-linking for build_tree |
1720 |
self.assertTrue(source.is_executable('file1-id')) |
1721 |
||
3453.2.4
by Aaron Bentley
Disable fast-path when conflicts are encountered |
1722 |
def test_case_insensitive_build_tree_inventory(self): |
1723 |
source = self.make_branch_and_tree('source') |
|
1724 |
self.build_tree(['source/file', 'source/FILE']) |
|
1725 |
source.add(['file', 'FILE'], ['lower-id', 'upper-id']) |
|
1726 |
source.commit('added files') |
|
1727 |
# Don't try this at home, kids!
|
|
1728 |
# Force the tree to report that it is case insensitive
|
|
1729 |
target = self.make_branch_and_tree('target') |
|
1730 |
target.case_sensitive = False |
|
3453.2.6
by Aaron Bentley
Rename mutate_tree to delta_from_tree, add comment |
1731 |
build_tree(source.basis_tree(), target, source, delta_from_tree=True) |
3453.2.4
by Aaron Bentley
Disable fast-path when conflicts are encountered |
1732 |
self.assertEqual('file.moved', target.id2path('lower-id')) |
1733 |
self.assertEqual('FILE', target.id2path('upper-id')) |
|
1734 |
||
1966.1.1
by Aaron Bentley
Implement disk-content merge and conflict resolution for build_tree |
1735 |
|
1534.10.28
by Aaron Bentley
Use numbered backup files |
1736 |
class MockTransform(object): |
1737 |
||
1738 |
def has_named_child(self, by_parent, parent_id, name): |
|
1739 |
for child_id in by_parent[parent_id]: |
|
1740 |
if child_id == '0': |
|
1741 |
if name == "name~": |
|
1742 |
return True |
|
1534.10.29
by Aaron Bentley
Fixed backup numbering to match GNU standard better |
1743 |
elif name == "name.~%s~" % child_id: |
1534.10.28
by Aaron Bentley
Use numbered backup files |
1744 |
return True |
1745 |
return False |
|
1746 |
||
2502.1.1
by Aaron Bentley
Ensure renames only root children are renamed when building trees |
1747 |
|
1534.10.28
by Aaron Bentley
Use numbered backup files |
1748 |
class MockEntry(object): |
1749 |
def __init__(self): |
|
1750 |
object.__init__(self) |
|
1751 |
self.name = "name" |
|
1752 |
||
3063.1.1
by Alexander Belchenko
Catch OSError 17 (file exists) in final phase of tree transform and show filename to user (#111758). |
1753 |
|
1534.10.28
by Aaron Bentley
Use numbered backup files |
1754 |
class TestGetBackupName(TestCase): |
1755 |
def test_get_backup_name(self): |
|
1756 |
tt = MockTransform() |
|
1757 |
name = get_backup_name(MockEntry(), {'a':[]}, 'a', tt) |
|
1534.10.29
by Aaron Bentley
Fixed backup numbering to match GNU standard better |
1758 |
self.assertEqual(name, 'name.~1~') |
1759 |
name = get_backup_name(MockEntry(), {'a':['1']}, 'a', tt) |
|
1760 |
self.assertEqual(name, 'name.~2~') |
|
1534.10.28
by Aaron Bentley
Use numbered backup files |
1761 |
name = get_backup_name(MockEntry(), {'a':['2']}, 'a', tt) |
1534.10.29
by Aaron Bentley
Fixed backup numbering to match GNU standard better |
1762 |
self.assertEqual(name, 'name.~1~') |
1534.10.28
by Aaron Bentley
Use numbered backup files |
1763 |
name = get_backup_name(MockEntry(), {'a':['2'], 'b':[]}, 'b', tt) |
1534.10.29
by Aaron Bentley
Fixed backup numbering to match GNU standard better |
1764 |
self.assertEqual(name, 'name.~1~') |
1765 |
name = get_backup_name(MockEntry(), {'a':['1', '2', '3']}, 'a', tt) |
|
1766 |
self.assertEqual(name, 'name.~4~') |
|
2733.2.1
by Aaron Bentley
Implement FileMover, to support TreeTransform rollback |
1767 |
|
1768 |
||
1769 |
class TestFileMover(tests.TestCaseWithTransport): |
|
1770 |
||
1771 |
def test_file_mover(self): |
|
1772 |
self.build_tree(['a/', 'a/b', 'c/', 'c/d']) |
|
1773 |
mover = _FileMover() |
|
1774 |
mover.rename('a', 'q') |
|
1775 |
self.failUnlessExists('q') |
|
1776 |
self.failIfExists('a') |
|
2733.2.12
by Aaron Bentley
Updates from review |
1777 |
self.failUnlessExists('q/b') |
1778 |
self.failUnlessExists('c') |
|
1779 |
self.failUnlessExists('c/d') |
|
2733.2.1
by Aaron Bentley
Implement FileMover, to support TreeTransform rollback |
1780 |
|
2733.2.5
by Aaron Bentley
Implement FileMover.pre_delete and FileMover.apply_deletions |
1781 |
def test_pre_delete_rollback(self): |
1782 |
self.build_tree(['a/']) |
|
1783 |
mover = _FileMover() |
|
1784 |
mover.pre_delete('a', 'q') |
|
1785 |
self.failUnlessExists('q') |
|
1786 |
self.failIfExists('a') |
|
1787 |
mover.rollback() |
|
1788 |
self.failIfExists('q') |
|
1789 |
self.failUnlessExists('a') |
|
1790 |
||
1791 |
def test_apply_deletions(self): |
|
2733.2.12
by Aaron Bentley
Updates from review |
1792 |
self.build_tree(['a/', 'b/']) |
2733.2.5
by Aaron Bentley
Implement FileMover.pre_delete and FileMover.apply_deletions |
1793 |
mover = _FileMover() |
1794 |
mover.pre_delete('a', 'q') |
|
2733.2.12
by Aaron Bentley
Updates from review |
1795 |
mover.pre_delete('b', 'r') |
2733.2.5
by Aaron Bentley
Implement FileMover.pre_delete and FileMover.apply_deletions |
1796 |
self.failUnlessExists('q') |
2733.2.12
by Aaron Bentley
Updates from review |
1797 |
self.failUnlessExists('r') |
2733.2.5
by Aaron Bentley
Implement FileMover.pre_delete and FileMover.apply_deletions |
1798 |
self.failIfExists('a') |
2733.2.12
by Aaron Bentley
Updates from review |
1799 |
self.failIfExists('b') |
2733.2.5
by Aaron Bentley
Implement FileMover.pre_delete and FileMover.apply_deletions |
1800 |
mover.apply_deletions() |
1801 |
self.failIfExists('q') |
|
2733.2.12
by Aaron Bentley
Updates from review |
1802 |
self.failIfExists('r') |
2733.2.5
by Aaron Bentley
Implement FileMover.pre_delete and FileMover.apply_deletions |
1803 |
self.failIfExists('a') |
2733.2.12
by Aaron Bentley
Updates from review |
1804 |
self.failIfExists('b') |
2733.2.5
by Aaron Bentley
Implement FileMover.pre_delete and FileMover.apply_deletions |
1805 |
|
2733.2.1
by Aaron Bentley
Implement FileMover, to support TreeTransform rollback |
1806 |
def test_file_mover_rollback(self): |
1807 |
self.build_tree(['a/', 'a/b', 'c/', 'c/d/', 'c/e/']) |
|
1808 |
mover = _FileMover() |
|
1809 |
mover.rename('c/d', 'c/f') |
|
1810 |
mover.rename('c/e', 'c/d') |
|
1811 |
try: |
|
1812 |
mover.rename('a', 'c') |
|
3063.1.3
by Aaron Bentley
Update for Linux |
1813 |
except errors.FileExists, e: |
2733.2.1
by Aaron Bentley
Implement FileMover, to support TreeTransform rollback |
1814 |
mover.rollback() |
1815 |
self.failUnlessExists('a') |
|
1816 |
self.failUnlessExists('c/d') |
|
2733.2.3
by Aaron Bentley
Test tranform rollback |
1817 |
|
1818 |
||
1819 |
class Bogus(Exception): |
|
1820 |
pass
|
|
1821 |
||
1822 |
||
1823 |
class TestTransformRollback(tests.TestCaseWithTransport): |
|
1824 |
||
1825 |
class ExceptionFileMover(_FileMover): |
|
1826 |
||
2733.2.4
by Aaron Bentley
Test transform rollback when renaming into place |
1827 |
def __init__(self, bad_source=None, bad_target=None): |
1828 |
_FileMover.__init__(self) |
|
1829 |
self.bad_source = bad_source |
|
1830 |
self.bad_target = bad_target |
|
1831 |
||
2733.2.3
by Aaron Bentley
Test tranform rollback |
1832 |
def rename(self, source, target): |
2733.2.4
by Aaron Bentley
Test transform rollback when renaming into place |
1833 |
if (self.bad_source is not None and |
1834 |
source.endswith(self.bad_source)): |
|
1835 |
raise Bogus |
|
1836 |
elif (self.bad_target is not None and |
|
1837 |
target.endswith(self.bad_target)): |
|
2733.2.3
by Aaron Bentley
Test tranform rollback |
1838 |
raise Bogus |
1839 |
else: |
|
1840 |
_FileMover.rename(self, source, target) |
|
1841 |
||
1842 |
def test_rollback_rename(self): |
|
1843 |
tree = self.make_branch_and_tree('.') |
|
1844 |
self.build_tree(['a/', 'a/b']) |
|
1845 |
tt = TreeTransform(tree) |
|
1846 |
self.addCleanup(tt.finalize) |
|
1847 |
a_id = tt.trans_id_tree_path('a') |
|
1848 |
tt.adjust_path('c', tt.root, a_id) |
|
1849 |
tt.adjust_path('d', a_id, tt.trans_id_tree_path('a/b')) |
|
2733.2.4
by Aaron Bentley
Test transform rollback when renaming into place |
1850 |
self.assertRaises(Bogus, tt.apply, |
1851 |
_mover=self.ExceptionFileMover(bad_source='a')) |
|
1852 |
self.failUnlessExists('a') |
|
1853 |
self.failUnlessExists('a/b') |
|
1854 |
tt.apply() |
|
1855 |
self.failUnlessExists('c') |
|
1856 |
self.failUnlessExists('c/d') |
|
1857 |
||
1858 |
def test_rollback_rename_into_place(self): |
|
1859 |
tree = self.make_branch_and_tree('.') |
|
1860 |
self.build_tree(['a/', 'a/b']) |
|
1861 |
tt = TreeTransform(tree) |
|
1862 |
self.addCleanup(tt.finalize) |
|
1863 |
a_id = tt.trans_id_tree_path('a') |
|
1864 |
tt.adjust_path('c', tt.root, a_id) |
|
1865 |
tt.adjust_path('d', a_id, tt.trans_id_tree_path('a/b')) |
|
1866 |
self.assertRaises(Bogus, tt.apply, |
|
1867 |
_mover=self.ExceptionFileMover(bad_target='c/d')) |
|
1868 |
self.failUnlessExists('a') |
|
1869 |
self.failUnlessExists('a/b') |
|
1870 |
tt.apply() |
|
1871 |
self.failUnlessExists('c') |
|
1872 |
self.failUnlessExists('c/d') |
|
2733.2.6
by Aaron Bentley
Make TreeTransform commits rollbackable |
1873 |
|
1874 |
def test_rollback_deletion(self): |
|
1875 |
tree = self.make_branch_and_tree('.') |
|
1876 |
self.build_tree(['a/', 'a/b']) |
|
1877 |
tt = TreeTransform(tree) |
|
1878 |
self.addCleanup(tt.finalize) |
|
1879 |
a_id = tt.trans_id_tree_path('a') |
|
1880 |
tt.delete_contents(a_id) |
|
1881 |
tt.adjust_path('d', tt.root, tt.trans_id_tree_path('a/b')) |
|
1882 |
self.assertRaises(Bogus, tt.apply, |
|
1883 |
_mover=self.ExceptionFileMover(bad_target='d')) |
|
1884 |
self.failUnlessExists('a') |
|
1885 |
self.failUnlessExists('a/b') |
|
3008.1.1
by Aaron Bentley
Start work allowing previews of transforms |
1886 |
|
1551.19.6
by Aaron Bentley
Revert doesn't crash restoring a file from a deleted directory |
1887 |
def test_resolve_no_parent(self): |
1888 |
wt = self.make_branch_and_tree('.') |
|
1889 |
tt = TreeTransform(wt) |
|
1890 |
self.addCleanup(tt.finalize) |
|
1891 |
parent = tt.trans_id_file_id('parent-id') |
|
1892 |
tt.new_file('file', parent, 'Contents') |
|
1893 |
resolve_conflicts(tt) |
|
3008.1.13
by Michael Hudson
merge bzr.dev |
1894 |
|
3008.1.1
by Aaron Bentley
Start work allowing previews of transforms |
1895 |
|
1896 |
class TestTransformPreview(tests.TestCaseWithTransport): |
|
1897 |
||
1898 |
def create_tree(self): |
|
1899 |
tree = self.make_branch_and_tree('.') |
|
1900 |
self.build_tree_contents([('a', 'content 1')]) |
|
3008.2.1
by Aaron Bentley
Ensure conflict resolution works |
1901 |
tree.add('a', 'a-id') |
3008.1.1
by Aaron Bentley
Start work allowing previews of transforms |
1902 |
tree.commit('rev1', rev_id='rev1') |
1903 |
return tree.branch.repository.revision_tree('rev1') |
|
1904 |
||
3008.1.18
by Aaron Bentley
Get supported PreviewTree functionality under test |
1905 |
def get_empty_preview(self): |
1906 |
repository = self.make_repository('repo') |
|
1907 |
tree = repository.revision_tree(_mod_revision.NULL_REVISION) |
|
3199.1.4
by Vincent Ladeuil
Fix 16 leaked tmp dirs. Probably indicates a lock handling problem with TransformPreview |
1908 |
preview = TransformPreview(tree) |
3199.1.5
by Vincent Ladeuil
Fix two more leaking tmp dirs, by reworking TransformPreview lock handling. |
1909 |
self.addCleanup(preview.finalize) |
3199.1.4
by Vincent Ladeuil
Fix 16 leaked tmp dirs. Probably indicates a lock handling problem with TransformPreview |
1910 |
return preview |
1911 |
||
3008.1.1
by Aaron Bentley
Start work allowing previews of transforms |
1912 |
def test_transform_preview(self): |
1913 |
revision_tree = self.create_tree() |
|
1914 |
preview = TransformPreview(revision_tree) |
|
3199.1.5
by Vincent Ladeuil
Fix two more leaking tmp dirs, by reworking TransformPreview lock handling. |
1915 |
self.addCleanup(preview.finalize) |
3008.1.1
by Aaron Bentley
Start work allowing previews of transforms |
1916 |
|
1917 |
def test_transform_preview_tree(self): |
|
1918 |
revision_tree = self.create_tree() |
|
1919 |
preview = TransformPreview(revision_tree) |
|
3199.1.5
by Vincent Ladeuil
Fix two more leaking tmp dirs, by reworking TransformPreview lock handling. |
1920 |
self.addCleanup(preview.finalize) |
3008.1.1
by Aaron Bentley
Start work allowing previews of transforms |
1921 |
preview.get_preview_tree() |
1922 |
||
3008.1.5
by Michael Hudson
a more precise test |
1923 |
def test_transform_new_file(self): |
1924 |
revision_tree = self.create_tree() |
|
1925 |
preview = TransformPreview(revision_tree) |
|
3199.1.5
by Vincent Ladeuil
Fix two more leaking tmp dirs, by reworking TransformPreview lock handling. |
1926 |
self.addCleanup(preview.finalize) |
3008.1.5
by Michael Hudson
a more precise test |
1927 |
preview.new_file('file2', preview.root, 'content B\n', 'file2-id') |
1928 |
preview_tree = preview.get_preview_tree() |
|
1929 |
self.assertEqual(preview_tree.kind('file2-id'), 'file') |
|
1930 |
self.assertEqual( |
|
1931 |
preview_tree.get_file('file2-id').read(), 'content B\n') |
|
1932 |
||
3008.1.1
by Aaron Bentley
Start work allowing previews of transforms |
1933 |
def test_diff_preview_tree(self): |
1934 |
revision_tree = self.create_tree() |
|
1935 |
preview = TransformPreview(revision_tree) |
|
3199.1.5
by Vincent Ladeuil
Fix two more leaking tmp dirs, by reworking TransformPreview lock handling. |
1936 |
self.addCleanup(preview.finalize) |
3008.1.4
by Michael Hudson
Merge test enhancements |
1937 |
preview.new_file('file2', preview.root, 'content B\n', 'file2-id') |
3008.1.1
by Aaron Bentley
Start work allowing previews of transforms |
1938 |
preview_tree = preview.get_preview_tree() |
1939 |
out = StringIO() |
|
1940 |
show_diff_trees(revision_tree, preview_tree, out) |
|
3008.1.4
by Michael Hudson
Merge test enhancements |
1941 |
lines = out.getvalue().splitlines() |
1942 |
self.assertEqual(lines[0], "=== added file 'file2'") |
|
1943 |
# 3 lines of diff administrivia
|
|
1944 |
self.assertEqual(lines[4], "+content B") |
|
3008.2.1
by Aaron Bentley
Ensure conflict resolution works |
1945 |
|
1946 |
def test_transform_conflicts(self): |
|
1947 |
revision_tree = self.create_tree() |
|
1948 |
preview = TransformPreview(revision_tree) |
|
3199.1.5
by Vincent Ladeuil
Fix two more leaking tmp dirs, by reworking TransformPreview lock handling. |
1949 |
self.addCleanup(preview.finalize) |
3008.2.1
by Aaron Bentley
Ensure conflict resolution works |
1950 |
preview.new_file('a', preview.root, 'content 2') |
1951 |
resolve_conflicts(preview) |
|
1952 |
trans_id = preview.trans_id_file_id('a-id') |
|
1953 |
self.assertEqual('a.moved', preview.final_name(trans_id)) |
|
3008.1.17
by Aaron Bentley
Test unused parameters of preview_tree._iter_changes |
1954 |
|
3008.1.31
by Aaron Bentley
Split PreviewTree._iter_changes parameter tests into smaller tests |
1955 |
def get_tree_and_preview_tree(self): |
3008.1.17
by Aaron Bentley
Test unused parameters of preview_tree._iter_changes |
1956 |
revision_tree = self.create_tree() |
1957 |
preview = TransformPreview(revision_tree) |
|
3199.1.5
by Vincent Ladeuil
Fix two more leaking tmp dirs, by reworking TransformPreview lock handling. |
1958 |
self.addCleanup(preview.finalize) |
3008.1.17
by Aaron Bentley
Test unused parameters of preview_tree._iter_changes |
1959 |
a_trans_id = preview.trans_id_file_id('a-id') |
1960 |
preview.delete_contents(a_trans_id) |
|
1961 |
preview.create_file('b content', a_trans_id) |
|
1962 |
preview_tree = preview.get_preview_tree() |
|
3008.1.31
by Aaron Bentley
Split PreviewTree._iter_changes parameter tests into smaller tests |
1963 |
return revision_tree, preview_tree |
1964 |
||
1965 |
def test_iter_changes(self): |
|
1966 |
revision_tree, preview_tree = self.get_tree_and_preview_tree() |
|
1967 |
root = revision_tree.inventory.root.file_id |
|
3008.1.17
by Aaron Bentley
Test unused parameters of preview_tree._iter_changes |
1968 |
self.assertEqual([('a-id', ('a', 'a'), True, (True, True), |
1969 |
(root, root), ('a', 'a'), ('file', 'file'), |
|
1970 |
(False, False))], |
|
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
1971 |
list(preview_tree.iter_changes(revision_tree))) |
3008.1.31
by Aaron Bentley
Split PreviewTree._iter_changes parameter tests into smaller tests |
1972 |
|
1973 |
def test_wrong_tree_value_error(self): |
|
1974 |
revision_tree, preview_tree = self.get_tree_and_preview_tree() |
|
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
1975 |
e = self.assertRaises(ValueError, preview_tree.iter_changes, |
3008.1.17
by Aaron Bentley
Test unused parameters of preview_tree._iter_changes |
1976 |
preview_tree) |
1977 |
self.assertEqual('from_tree must be transform source tree.', str(e)) |
|
3008.1.31
by Aaron Bentley
Split PreviewTree._iter_changes parameter tests into smaller tests |
1978 |
|
1979 |
def test_include_unchanged_value_error(self): |
|
1980 |
revision_tree, preview_tree = self.get_tree_and_preview_tree() |
|
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
1981 |
e = self.assertRaises(ValueError, preview_tree.iter_changes, |
3008.1.17
by Aaron Bentley
Test unused parameters of preview_tree._iter_changes |
1982 |
revision_tree, include_unchanged=True) |
1983 |
self.assertEqual('include_unchanged is not supported', str(e)) |
|
3008.1.31
by Aaron Bentley
Split PreviewTree._iter_changes parameter tests into smaller tests |
1984 |
|
1985 |
def test_specific_files(self): |
|
1986 |
revision_tree, preview_tree = self.get_tree_and_preview_tree() |
|
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
1987 |
e = self.assertRaises(ValueError, preview_tree.iter_changes, |
3008.1.17
by Aaron Bentley
Test unused parameters of preview_tree._iter_changes |
1988 |
revision_tree, specific_files=['pete']) |
1989 |
self.assertEqual('specific_files is not supported', str(e)) |
|
3008.1.31
by Aaron Bentley
Split PreviewTree._iter_changes parameter tests into smaller tests |
1990 |
|
1991 |
def test_want_unversioned_value_error(self): |
|
1992 |
revision_tree, preview_tree = self.get_tree_and_preview_tree() |
|
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
1993 |
e = self.assertRaises(ValueError, preview_tree.iter_changes, |
3008.1.17
by Aaron Bentley
Test unused parameters of preview_tree._iter_changes |
1994 |
revision_tree, want_unversioned=True) |
1995 |
self.assertEqual('want_unversioned is not supported', str(e)) |
|
1996 |
||
3008.1.31
by Aaron Bentley
Split PreviewTree._iter_changes parameter tests into smaller tests |
1997 |
def test_ignore_extra_trees_no_specific_files(self): |
3008.1.17
by Aaron Bentley
Test unused parameters of preview_tree._iter_changes |
1998 |
# extra_trees is harmless without specific_files, so we'll silently
|
1999 |
# accept it, even though we won't use it.
|
|
3008.1.31
by Aaron Bentley
Split PreviewTree._iter_changes parameter tests into smaller tests |
2000 |
revision_tree, preview_tree = self.get_tree_and_preview_tree() |
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
2001 |
preview_tree.iter_changes(revision_tree, extra_trees=[preview_tree]) |
3008.1.31
by Aaron Bentley
Split PreviewTree._iter_changes parameter tests into smaller tests |
2002 |
|
2003 |
def test_ignore_require_versioned_no_specific_files(self): |
|
3008.1.17
by Aaron Bentley
Test unused parameters of preview_tree._iter_changes |
2004 |
# require_versioned is meaningless without specific_files.
|
3008.1.31
by Aaron Bentley
Split PreviewTree._iter_changes parameter tests into smaller tests |
2005 |
revision_tree, preview_tree = self.get_tree_and_preview_tree() |
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
2006 |
preview_tree.iter_changes(revision_tree, require_versioned=False) |
3008.1.31
by Aaron Bentley
Split PreviewTree._iter_changes parameter tests into smaller tests |
2007 |
|
2008 |
def test_ignore_pb(self): |
|
3008.1.17
by Aaron Bentley
Test unused parameters of preview_tree._iter_changes |
2009 |
# pb could be supported, but TT.iter_changes doesn't support it.
|
3008.1.31
by Aaron Bentley
Split PreviewTree._iter_changes parameter tests into smaller tests |
2010 |
revision_tree, preview_tree = self.get_tree_and_preview_tree() |
3254.1.1
by Aaron Bentley
Make Tree.iter_changes a public method |
2011 |
preview_tree.iter_changes(revision_tree, pb=progress.DummyProgress()) |
3008.1.18
by Aaron Bentley
Get supported PreviewTree functionality under test |
2012 |
|
2013 |
def test_kind(self): |
|
2014 |
revision_tree = self.create_tree() |
|
2015 |
preview = TransformPreview(revision_tree) |
|
3199.1.5
by Vincent Ladeuil
Fix two more leaking tmp dirs, by reworking TransformPreview lock handling. |
2016 |
self.addCleanup(preview.finalize) |
3008.1.18
by Aaron Bentley
Get supported PreviewTree functionality under test |
2017 |
preview.new_file('file', preview.root, 'contents', 'file-id') |
2018 |
preview.new_directory('directory', preview.root, 'dir-id') |
|
2019 |
preview_tree = preview.get_preview_tree() |
|
2020 |
self.assertEqual('file', preview_tree.kind('file-id')) |
|
2021 |
self.assertEqual('directory', preview_tree.kind('dir-id')) |
|
2022 |
||
2023 |
def test_get_file_mtime(self): |
|
2024 |
preview = self.get_empty_preview() |
|
2025 |
file_trans_id = preview.new_file('file', preview.root, 'contents', |
|
2026 |
'file-id') |
|
2027 |
limbo_path = preview._limbo_name(file_trans_id) |
|
2028 |
preview_tree = preview.get_preview_tree() |
|
2029 |
self.assertEqual(os.stat(limbo_path).st_mtime, |
|
2030 |
preview_tree.get_file_mtime('file-id')) |
|
2031 |
||
2032 |
def test_get_file(self): |
|
2033 |
preview = self.get_empty_preview() |
|
2034 |
preview.new_file('file', preview.root, 'contents', 'file-id') |
|
2035 |
preview_tree = preview.get_preview_tree() |
|
2036 |
tree_file = preview_tree.get_file('file-id') |
|
2037 |
try: |
|
2038 |
self.assertEqual('contents', tree_file.read()) |
|
2039 |
finally: |
|
2040 |
tree_file.close() |
|
3228.1.2
by James Henstridge
Simplify test, and move it down to be next to the other _PreviewTree tests. |
2041 |
|
2042 |
def test_get_symlink_target(self): |
|
2043 |
self.requireFeature(SymlinkFeature) |
|
2044 |
preview = self.get_empty_preview() |
|
2045 |
preview.new_symlink('symlink', preview.root, 'target', 'symlink-id') |
|
2046 |
preview_tree = preview.get_preview_tree() |
|
2047 |
self.assertEqual('target', |
|
2048 |
preview_tree.get_symlink_target('symlink-id')) |
|
3363.2.18
by Aaron Bentley
Implement correct all_file_ids for PreviewTree |
2049 |
|
2050 |
def test_all_file_ids(self): |
|
2051 |
tree = self.make_branch_and_tree('tree') |
|
2052 |
self.build_tree(['tree/a', 'tree/b', 'tree/c']) |
|
2053 |
tree.add(['a', 'b', 'c'], ['a-id', 'b-id', 'c-id']) |
|
2054 |
preview = TransformPreview(tree) |
|
2055 |
self.addCleanup(preview.finalize) |
|
2056 |
preview.unversion_file(preview.trans_id_file_id('b-id')) |
|
2057 |
c_trans_id = preview.trans_id_file_id('c-id') |
|
2058 |
preview.unversion_file(c_trans_id) |
|
2059 |
preview.version_file('c-id', c_trans_id) |
|
2060 |
preview_tree = preview.get_preview_tree() |
|
2061 |
self.assertEqual(set(['a-id', 'c-id', tree.get_root_id()]), |
|
2062 |
preview_tree.all_file_ids()) |
|
3363.2.19
by Aaron Bentley
Make PreviewTree.path2id correct |
2063 |
|
2064 |
def test_path2id_deleted_unchanged(self): |
|
2065 |
tree = self.make_branch_and_tree('tree') |
|
2066 |
self.build_tree(['tree/unchanged', 'tree/deleted']) |
|
2067 |
tree.add(['unchanged', 'deleted'], ['unchanged-id', 'deleted-id']) |
|
2068 |
preview = TransformPreview(tree) |
|
2069 |
self.addCleanup(preview.finalize) |
|
2070 |
preview.unversion_file(preview.trans_id_file_id('deleted-id')) |
|
2071 |
preview_tree = preview.get_preview_tree() |
|
2072 |
self.assertEqual('unchanged-id', preview_tree.path2id('unchanged')) |
|
2073 |
self.assertIs(None, preview_tree.path2id('deleted')) |
|
2074 |
||
2075 |
def test_path2id_created(self): |
|
2076 |
tree = self.make_branch_and_tree('tree') |
|
2077 |
self.build_tree(['tree/unchanged']) |
|
2078 |
tree.add(['unchanged'], ['unchanged-id']) |
|
2079 |
preview = TransformPreview(tree) |
|
2080 |
self.addCleanup(preview.finalize) |
|
2081 |
preview.new_file('new', preview.trans_id_file_id('unchanged-id'), |
|
2082 |
'contents', 'new-id') |
|
2083 |
preview_tree = preview.get_preview_tree() |
|
2084 |
self.assertEqual('new-id', preview_tree.path2id('unchanged/new')) |
|
2085 |
||
2086 |
def test_path2id_moved(self): |
|
2087 |
tree = self.make_branch_and_tree('tree') |
|
2088 |
self.build_tree(['tree/old_parent/', 'tree/old_parent/child']) |
|
2089 |
tree.add(['old_parent', 'old_parent/child'], |
|
2090 |
['old_parent-id', 'child-id']) |
|
2091 |
preview = TransformPreview(tree) |
|
2092 |
self.addCleanup(preview.finalize) |
|
2093 |
new_parent = preview.new_directory('new_parent', preview.root, |
|
2094 |
'new_parent-id') |
|
2095 |
preview.adjust_path('child', new_parent, |
|
2096 |
preview.trans_id_file_id('child-id')) |
|
2097 |
preview_tree = preview.get_preview_tree() |
|
2098 |
self.assertIs(None, preview_tree.path2id('old_parent/child')) |
|
2099 |
self.assertEqual('child-id', preview_tree.path2id('new_parent/child')) |
|
2100 |
||
2101 |
def test_path2id_renamed_parent(self): |
|
2102 |
tree = self.make_branch_and_tree('tree') |
|
2103 |
self.build_tree(['tree/old_name/', 'tree/old_name/child']) |
|
2104 |
tree.add(['old_name', 'old_name/child'], |
|
2105 |
['parent-id', 'child-id']) |
|
2106 |
preview = TransformPreview(tree) |
|
2107 |
self.addCleanup(preview.finalize) |
|
2108 |
preview.adjust_path('new_name', preview.root, |
|
2109 |
preview.trans_id_file_id('parent-id')) |
|
2110 |
preview_tree = preview.get_preview_tree() |
|
2111 |
self.assertIs(None, preview_tree.path2id('old_name/child')) |
|
2112 |
self.assertEqual('child-id', preview_tree.path2id('new_name/child')) |
|
3363.2.21
by Aaron Bentley
Implement iter_entries_by_dir |
2113 |
|
2114 |
def assertMatchingIterEntries(self, tt, specific_file_ids=None): |
|
2115 |
preview_tree = tt.get_preview_tree() |
|
2116 |
preview_result = list(preview_tree.iter_entries_by_dir( |
|
2117 |
specific_file_ids)) |
|
2118 |
tree = tt._tree |
|
2119 |
tt.apply() |
|
2120 |
actual_result = list(tree.iter_entries_by_dir(specific_file_ids)) |
|
2121 |
self.assertEqual(actual_result, preview_result) |
|
2122 |
||
2123 |
def test_iter_entries_by_dir_new(self): |
|
2124 |
tree = self.make_branch_and_tree('tree') |
|
2125 |
tt = TreeTransform(tree) |
|
2126 |
tt.new_file('new', tt.root, 'contents', 'new-id') |
|
2127 |
self.assertMatchingIterEntries(tt) |
|
2128 |
||
2129 |
def test_iter_entries_by_dir_deleted(self): |
|
2130 |
tree = self.make_branch_and_tree('tree') |
|
2131 |
self.build_tree(['tree/deleted']) |
|
2132 |
tree.add('deleted', 'deleted-id') |
|
2133 |
tt = TreeTransform(tree) |
|
2134 |
tt.delete_contents(tt.trans_id_file_id('deleted-id')) |
|
2135 |
self.assertMatchingIterEntries(tt) |
|
2136 |
||
2137 |
def test_iter_entries_by_dir_unversioned(self): |
|
2138 |
tree = self.make_branch_and_tree('tree') |
|
2139 |
self.build_tree(['tree/removed']) |
|
2140 |
tree.add('removed', 'removed-id') |
|
2141 |
tt = TreeTransform(tree) |
|
2142 |
tt.unversion_file(tt.trans_id_file_id('removed-id')) |
|
2143 |
self.assertMatchingIterEntries(tt) |
|
2144 |
||
2145 |
def test_iter_entries_by_dir_moved(self): |
|
2146 |
tree = self.make_branch_and_tree('tree') |
|
2147 |
self.build_tree(['tree/moved', 'tree/new_parent/']) |
|
2148 |
tree.add(['moved', 'new_parent'], ['moved-id', 'new_parent-id']) |
|
2149 |
tt = TreeTransform(tree) |
|
2150 |
tt.adjust_path('moved', tt.trans_id_file_id('new_parent-id'), |
|
2151 |
tt.trans_id_file_id('moved-id')) |
|
2152 |
self.assertMatchingIterEntries(tt) |
|
2153 |
||
2154 |
def test_iter_entries_by_dir_specific_file_ids(self): |
|
2155 |
tree = self.make_branch_and_tree('tree') |
|
2156 |
tree.set_root_id('tree-root-id') |
|
2157 |
self.build_tree(['tree/parent/', 'tree/parent/child']) |
|
2158 |
tree.add(['parent', 'parent/child'], ['parent-id', 'child-id']) |
|
2159 |
tt = TreeTransform(tree) |
|
2160 |
self.assertMatchingIterEntries(tt, ['tree-root-id', 'child-id']) |
|
3363.2.26
by Aaron Bentley
Get symlinks working |
2161 |
|
2162 |
def test_symlink_content_summary(self): |
|
2163 |
self.requireFeature(SymlinkFeature) |
|
2164 |
preview = self.get_empty_preview() |
|
2165 |
preview.new_symlink('path', preview.root, 'target', 'path-id') |
|
2166 |
summary = preview.get_preview_tree().path_content_summary('path') |
|
2167 |
self.assertEqual(('symlink', None, None, 'target'), summary) |
|
3363.2.27
by Aaron Bentley
Make path_content_summary a core API |
2168 |
|
2169 |
def test_missing_content_summary(self): |
|
2170 |
preview = self.get_empty_preview() |
|
2171 |
summary = preview.get_preview_tree().path_content_summary('path') |
|
2172 |
self.assertEqual(('missing', None, None, None), summary) |
|
2173 |
||
2174 |
def test_deleted_content_summary(self): |
|
2175 |
tree = self.make_branch_and_tree('tree') |
|
2176 |
self.build_tree(['tree/path/']) |
|
2177 |
tree.add('path') |
|
2178 |
preview = TransformPreview(tree) |
|
2179 |
self.addCleanup(preview.finalize) |
|
2180 |
preview.delete_contents(preview.trans_id_tree_path('path')) |
|
2181 |
summary = preview.get_preview_tree().path_content_summary('path') |
|
2182 |
self.assertEqual(('missing', None, None, None), summary) |
|
2183 |
||
3363.2.30
by Aaron Bentley
Improve execute bit testing |
2184 |
def test_file_content_summary_executable(self): |
2185 |
if not osutils.supports_executable(): |
|
2186 |
raise TestNotApplicable() |
|
2187 |
preview = self.get_empty_preview() |
|
2188 |
path_id = preview.new_file('path', preview.root, 'contents', 'path-id') |
|
2189 |
preview.set_executability(True, path_id) |
|
2190 |
summary = preview.get_preview_tree().path_content_summary('path') |
|
2191 |
self.assertEqual(4, len(summary)) |
|
2192 |
self.assertEqual('file', summary[0]) |
|
2193 |
# size must be known
|
|
2194 |
self.assertEqual(len('contents'), summary[1]) |
|
2195 |
# executable
|
|
2196 |
self.assertEqual(True, summary[2]) |
|
3363.2.31
by Aaron Bentley
Tweak tests |
2197 |
# will not have hash (not cheap to determine)
|
2198 |
self.assertIs(None, summary[3]) |
|
3363.2.30
by Aaron Bentley
Improve execute bit testing |
2199 |
|
2200 |
def test_change_executability(self): |
|
2201 |
if not osutils.supports_executable(): |
|
2202 |
raise TestNotApplicable() |
|
2203 |
tree = self.make_branch_and_tree('tree') |
|
2204 |
self.build_tree(['tree/path']) |
|
2205 |
tree.add('path') |
|
2206 |
preview = TransformPreview(tree) |
|
2207 |
self.addCleanup(preview.finalize) |
|
2208 |
path_id = preview.trans_id_tree_path('path') |
|
2209 |
preview.set_executability(True, path_id) |
|
2210 |
summary = preview.get_preview_tree().path_content_summary('path') |
|
2211 |
self.assertEqual(True, summary[2]) |
|
2212 |
||
3363.2.27
by Aaron Bentley
Make path_content_summary a core API |
2213 |
def test_file_content_summary_non_exec(self): |
2214 |
preview = self.get_empty_preview() |
|
2215 |
preview.new_file('path', preview.root, 'contents', 'path-id') |
|
2216 |
summary = preview.get_preview_tree().path_content_summary('path') |
|
2217 |
self.assertEqual(4, len(summary)) |
|
2218 |
self.assertEqual('file', summary[0]) |
|
2219 |
# size must be known
|
|
3363.2.30
by Aaron Bentley
Improve execute bit testing |
2220 |
self.assertEqual(len('contents'), summary[1]) |
3363.2.27
by Aaron Bentley
Make path_content_summary a core API |
2221 |
# not executable
|
2222 |
if osutils.supports_executable(): |
|
2223 |
self.assertEqual(False, summary[2]) |
|
2224 |
else: |
|
2225 |
self.assertEqual(None, summary[2]) |
|
3363.2.31
by Aaron Bentley
Tweak tests |
2226 |
# will not have hash (not cheap to determine)
|
2227 |
self.assertIs(None, summary[3]) |
|
3363.2.27
by Aaron Bentley
Make path_content_summary a core API |
2228 |
|
2229 |
def test_dir_content_summary(self): |
|
2230 |
preview = self.get_empty_preview() |
|
2231 |
preview.new_directory('path', preview.root, 'path-id') |
|
2232 |
summary = preview.get_preview_tree().path_content_summary('path') |
|
2233 |
self.assertEqual(('directory', None, None, None), summary) |
|
2234 |
||
2235 |
def test_tree_content_summary(self): |
|
2236 |
preview = self.get_empty_preview() |
|
2237 |
path = preview.new_directory('path', preview.root, 'path-id') |
|
2238 |
preview.set_tree_reference('rev-1', path) |
|
2239 |
summary = preview.get_preview_tree().path_content_summary('path') |
|
2240 |
self.assertEqual(4, len(summary)) |
|
2241 |
self.assertEqual('tree-reference', summary[0]) |
|
3363.2.33
by Aaron Bentley
Implement PreviewTree.annotate_iter |
2242 |
|
2243 |
def test_annotate(self): |
|
2244 |
tree = self.make_branch_and_tree('tree') |
|
2245 |
self.build_tree_contents([('tree/file', 'a\n')]) |
|
2246 |
tree.add('file', 'file-id') |
|
2247 |
tree.commit('a', rev_id='one') |
|
2248 |
self.build_tree_contents([('tree/file', 'a\nb\n')]) |
|
2249 |
preview = TransformPreview(tree) |
|
2250 |
self.addCleanup(preview.finalize) |
|
2251 |
file_trans_id = preview.trans_id_file_id('file-id') |
|
2252 |
preview.delete_contents(file_trans_id) |
|
2253 |
preview.create_file('a\nb\nc\n', file_trans_id) |
|
2254 |
preview_tree = preview.get_preview_tree() |
|
2255 |
expected = [ |
|
2256 |
('one', 'a\n'), |
|
2257 |
('me:', 'b\n'), |
|
2258 |
('me:', 'c\n'), |
|
2259 |
]
|
|
2260 |
annotation = preview_tree.annotate_iter('file-id', 'me:') |
|
2261 |
self.assertEqual(expected, annotation) |
|
2262 |
||
2263 |
def test_annotate_missing(self): |
|
2264 |
preview = self.get_empty_preview() |
|
2265 |
preview.new_file('file', preview.root, 'a\nb\nc\n', 'file-id') |
|
2266 |
preview_tree = preview.get_preview_tree() |
|
2267 |
expected = [ |
|
2268 |
('me:', 'a\n'), |
|
2269 |
('me:', 'b\n'), |
|
2270 |
('me:', 'c\n'), |
|
2271 |
]
|
|
2272 |
annotation = preview_tree.annotate_iter('file-id', 'me:') |
|
2273 |
self.assertEqual(expected, annotation) |
|
2274 |
||
3363.7.3
by Aaron Bentley
Add test that annotate correctly handles renames |
2275 |
def test_annotate_rename(self): |
2276 |
tree = self.make_branch_and_tree('tree') |
|
2277 |
self.build_tree_contents([('tree/file', 'a\n')]) |
|
2278 |
tree.add('file', 'file-id') |
|
2279 |
tree.commit('a', rev_id='one') |
|
2280 |
preview = TransformPreview(tree) |
|
2281 |
self.addCleanup(preview.finalize) |
|
2282 |
file_trans_id = preview.trans_id_file_id('file-id') |
|
2283 |
preview.adjust_path('newname', preview.root, file_trans_id) |
|
2284 |
preview_tree = preview.get_preview_tree() |
|
2285 |
expected = [ |
|
2286 |
('one', 'a\n'), |
|
2287 |
]
|
|
2288 |
annotation = preview_tree.annotate_iter('file-id', 'me:') |
|
2289 |
self.assertEqual(expected, annotation) |
|
2290 |
||
3363.2.33
by Aaron Bentley
Implement PreviewTree.annotate_iter |
2291 |
def test_annotate_deleted(self): |
2292 |
tree = self.make_branch_and_tree('tree') |
|
2293 |
self.build_tree_contents([('tree/file', 'a\n')]) |
|
2294 |
tree.add('file', 'file-id') |
|
2295 |
tree.commit('a', rev_id='one') |
|
2296 |
self.build_tree_contents([('tree/file', 'a\nb\n')]) |
|
2297 |
preview = TransformPreview(tree) |
|
2298 |
self.addCleanup(preview.finalize) |
|
2299 |
file_trans_id = preview.trans_id_file_id('file-id') |
|
2300 |
preview.delete_contents(file_trans_id) |
|
2301 |
preview_tree = preview.get_preview_tree() |
|
2302 |
annotation = preview_tree.annotate_iter('file-id', 'me:') |
|
2303 |
self.assertIs(None, annotation) |
|
2304 |
||
3363.2.36
by Aaron Bentley
Fix PreviewTree.stored_kind |
2305 |
def test_stored_kind(self): |
2306 |
preview = self.get_empty_preview() |
|
2307 |
preview.new_file('file', preview.root, 'a\nb\nc\n', 'file-id') |
|
2308 |
preview_tree = preview.get_preview_tree() |
|
2309 |
self.assertEqual('file', preview_tree.stored_kind('file-id')) |
|
3363.2.37
by Aaron Bentley
Fix is_executable |
2310 |
|
2311 |
def test_is_executable(self): |
|
2312 |
preview = self.get_empty_preview() |
|
2313 |
preview.new_file('file', preview.root, 'a\nb\nc\n', 'file-id') |
|
2314 |
preview.set_executability(True, preview.trans_id_file_id('file-id')) |
|
2315 |
preview_tree = preview.get_preview_tree() |
|
2316 |
self.assertEqual(True, preview_tree.is_executable('file-id')) |
|
3363.9.1
by Aaron Bentley
Implement plan_merge, refactoring various bits |
2317 |
|
3571.1.1
by Aaron Bentley
Allow set/get of parent_ids in PreviewTree |
2318 |
def test_get_set_parent_ids(self): |
2319 |
revision_tree, preview_tree = self.get_tree_and_preview_tree() |
|
2320 |
self.assertEqual([], preview_tree.get_parent_ids()) |
|
2321 |
preview_tree.set_parent_ids(['rev-1']) |
|
2322 |
self.assertEqual(['rev-1'], preview_tree.get_parent_ids()) |
|
2323 |
||
3363.9.1
by Aaron Bentley
Implement plan_merge, refactoring various bits |
2324 |
def test_plan_file_merge(self): |
2325 |
work_a = self.make_branch_and_tree('wta') |
|
2326 |
self.build_tree_contents([('wta/file', 'a\nb\nc\nd\n')]) |
|
2327 |
work_a.add('file', 'file-id') |
|
3363.9.7
by Aaron Bentley
Fix up to use set_parent_ids |
2328 |
base_id = work_a.commit('base version') |
3363.9.1
by Aaron Bentley
Implement plan_merge, refactoring various bits |
2329 |
tree_b = work_a.bzrdir.sprout('wtb').open_workingtree() |
2330 |
preview = TransformPreview(work_a) |
|
2331 |
self.addCleanup(preview.finalize) |
|
2332 |
trans_id = preview.trans_id_file_id('file-id') |
|
2333 |
preview.delete_contents(trans_id) |
|
2334 |
preview.create_file('b\nc\nd\ne\n', trans_id) |
|
2335 |
self.build_tree_contents([('wtb/file', 'a\nc\nd\nf\n')]) |
|
2336 |
tree_a = preview.get_preview_tree() |
|
3363.9.7
by Aaron Bentley
Fix up to use set_parent_ids |
2337 |
tree_a.set_parent_ids([base_id]) |
3363.9.1
by Aaron Bentley
Implement plan_merge, refactoring various bits |
2338 |
self.assertEqual([ |
3363.9.5
by Aaron Bentley
Move killed-a from top to bottom |
2339 |
('killed-a', 'a\n'), |
3363.9.1
by Aaron Bentley
Implement plan_merge, refactoring various bits |
2340 |
('killed-b', 'b\n'), |
2341 |
('unchanged', 'c\n'), |
|
2342 |
('unchanged', 'd\n'), |
|
2343 |
('new-a', 'e\n'), |
|
2344 |
('new-b', 'f\n'), |
|
2345 |
], list(tree_a.plan_file_merge('file-id', tree_b))) |
|
3363.9.8
by Aaron Bentley
Ensure plan_file_merge works with a RevisionTree as the basis |
2346 |
|
2347 |
def test_plan_file_merge_revision_tree(self): |
|
2348 |
work_a = self.make_branch_and_tree('wta') |
|
2349 |
self.build_tree_contents([('wta/file', 'a\nb\nc\nd\n')]) |
|
2350 |
work_a.add('file', 'file-id') |
|
2351 |
base_id = work_a.commit('base version') |
|
2352 |
tree_b = work_a.bzrdir.sprout('wtb').open_workingtree() |
|
2353 |
preview = TransformPreview(work_a.basis_tree()) |
|
2354 |
self.addCleanup(preview.finalize) |
|
2355 |
trans_id = preview.trans_id_file_id('file-id') |
|
2356 |
preview.delete_contents(trans_id) |
|
2357 |
preview.create_file('b\nc\nd\ne\n', trans_id) |
|
2358 |
self.build_tree_contents([('wtb/file', 'a\nc\nd\nf\n')]) |
|
2359 |
tree_a = preview.get_preview_tree() |
|
2360 |
tree_a.set_parent_ids([base_id]) |
|
2361 |
self.assertEqual([ |
|
2362 |
('killed-a', 'a\n'), |
|
2363 |
('killed-b', 'b\n'), |
|
2364 |
('unchanged', 'c\n'), |
|
2365 |
('unchanged', 'd\n'), |
|
2366 |
('new-a', 'e\n'), |
|
2367 |
('new-b', 'f\n'), |
|
2368 |
], list(tree_a.plan_file_merge('file-id', tree_b))) |