bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.14.26
by Aaron Bentley
Update copyright |
1 |
# Copyright (C) 2008 Canonical Ltd
|
|
0.12.12
by Aaron Bentley
Implement shelf creator |
2 |
#
|
|
0.12.80
by Aaron Bentley
Re-format GPL notifications |
3 |
# This program is free software; you can redistribute it and/or modify
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
0.12.12
by Aaron Bentley
Implement shelf creator |
16 |
|
|
0.12.17
by Aaron Bentley
Handle creating symlinks |
17 |
import os |
18 |
||
|
4241.14.12
by Vincent Ladeuil
Far too many modifications for a single commit, need to restart. |
19 |
from bzrlib import ( |
20 |
errors, |
|
21 |
osutils, |
|
22 |
pack, |
|
23 |
shelf, |
|
24 |
tests, |
|
25 |
transform, |
|
26 |
workingtree, |
|
27 |
)
|
|
|
0.12.12
by Aaron Bentley
Implement shelf creator |
28 |
|
29 |
||
|
0.14.34
by Aaron Bentley
Factor out the empty shelf |
30 |
EMPTY_SHELF = ("Bazaar pack format 1 (introduced in 0.18)\n" |
|
0.15.39
by Aaron Bentley
Update empty shelf serialization |
31 |
"B23\n" |
32 |
"metadata\n\n" |
|
33 |
"d11:revision_id5:null:e"
|
|
|
0.14.34
by Aaron Bentley
Factor out the empty shelf |
34 |
"B159\n" |
35 |
"attribs\n\n" |
|
36 |
"d10:_id_numberi0e18:_new_executabilityde7:_new_idde"
|
|
37 |
"9:_new_namede11:_new_parentde16:_non_present_idsde"
|
|
38 |
"17:_removed_contentsle11:_removed_idle14:_tree_path_idsdeeE") |
|
39 |
||
40 |
||
|
0.12.12
by Aaron Bentley
Implement shelf creator |
41 |
class TestPrepareShelf(tests.TestCaseWithTransport): |
42 |
||
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
43 |
def prepare_shelve_rename(self): |
|
0.12.12
by Aaron Bentley
Implement shelf creator |
44 |
tree = self.make_branch_and_tree('.') |
45 |
self.build_tree(['foo']) |
|
46 |
tree.add(['foo'], ['foo-id']) |
|
47 |
tree.commit('foo') |
|
48 |
tree.rename_one('foo', 'bar') |
|
|
0.14.7
by Aaron Bentley
Misc test cleanup |
49 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
0.12.12
by Aaron Bentley
Implement shelf creator |
50 |
self.addCleanup(creator.finalize) |
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
51 |
self.assertEqual([('rename', 'foo-id', 'foo', 'bar')], |
52 |
list(creator.iter_shelvable())) |
|
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
53 |
return creator |
54 |
||
55 |
def check_shelve_rename(self, creator): |
|
|
0.12.12
by Aaron Bentley
Implement shelf creator |
56 |
work_trans_id = creator.work_transform.trans_id_file_id('foo-id') |
57 |
self.assertEqual('foo', creator.work_transform.final_name( |
|
58 |
work_trans_id)) |
|
59 |
shelf_trans_id = creator.shelf_transform.trans_id_file_id('foo-id') |
|
60 |
self.assertEqual('bar', creator.shelf_transform.final_name( |
|
61 |
shelf_trans_id)) |
|
62 |
||
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
63 |
def test_shelve_rename(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
64 |
self.thisFailsStrictLockCheck() |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
65 |
creator = self.prepare_shelve_rename() |
66 |
creator.shelve_rename('foo-id') |
|
67 |
self.check_shelve_rename(creator) |
|
68 |
||
69 |
def test_shelve_change_handles_rename(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
70 |
self.thisFailsStrictLockCheck() |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
71 |
creator = self.prepare_shelve_rename() |
72 |
creator.shelve_change(('rename', 'foo-id', 'foo', 'bar')) |
|
73 |
self.check_shelve_rename(creator) |
|
74 |
||
75 |
def prepare_shelve_move(self): |
|
|
0.12.12
by Aaron Bentley
Implement shelf creator |
76 |
tree = self.make_branch_and_tree('.') |
77 |
self.build_tree(['foo/', 'bar/', 'foo/baz']) |
|
78 |
tree.add(['foo', 'bar', 'foo/baz'], ['foo-id', 'bar-id', 'baz-id']) |
|
79 |
tree.commit('foo') |
|
80 |
tree.rename_one('foo/baz', 'bar/baz') |
|
|
0.14.7
by Aaron Bentley
Misc test cleanup |
81 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
0.12.12
by Aaron Bentley
Implement shelf creator |
82 |
self.addCleanup(creator.finalize) |
83 |
self.assertEqual([('rename', 'baz-id', 'foo/baz', 'bar/baz')], |
|
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
84 |
list(creator.iter_shelvable())) |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
85 |
return creator, tree |
86 |
||
87 |
def check_shelve_move(self, creator, tree): |
|
|
0.12.12
by Aaron Bentley
Implement shelf creator |
88 |
work_trans_id = creator.work_transform.trans_id_file_id('baz-id') |
89 |
work_foo = creator.work_transform.trans_id_file_id('foo-id') |
|
90 |
self.assertEqual(work_foo, creator.work_transform.final_parent( |
|
91 |
work_trans_id)) |
|
92 |
shelf_trans_id = creator.shelf_transform.trans_id_file_id('baz-id') |
|
93 |
shelf_bar = creator.shelf_transform.trans_id_file_id('bar-id') |
|
94 |
self.assertEqual(shelf_bar, creator.shelf_transform.final_parent( |
|
95 |
shelf_trans_id)) |
|
|
0.12.13
by Aaron Bentley
Implement shelving content |
96 |
creator.transform() |
97 |
self.assertEqual('foo/baz', tree.id2path('baz-id')) |
|
98 |
||
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
99 |
def test_shelve_move(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
100 |
self.thisFailsStrictLockCheck() |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
101 |
creator, tree = self.prepare_shelve_move() |
102 |
creator.shelve_rename('baz-id') |
|
103 |
self.check_shelve_move(creator, tree) |
|
104 |
||
105 |
def test_shelve_change_handles_move(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
106 |
self.thisFailsStrictLockCheck() |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
107 |
creator, tree = self.prepare_shelve_move() |
108 |
creator.shelve_change(('rename', 'baz-id', 'foo/baz', 'bar/baz')) |
|
109 |
self.check_shelve_move(creator, tree) |
|
110 |
||
|
0.12.14
by Aaron Bentley
Add shelving of created files |
111 |
def assertShelvedFileEqual(self, expected_content, creator, file_id): |
112 |
s_trans_id = creator.shelf_transform.trans_id_file_id(file_id) |
|
113 |
shelf_file = creator.shelf_transform._limbo_name(s_trans_id) |
|
114 |
self.assertFileEqual(expected_content, shelf_file) |
|
115 |
||
|
4595.8.1
by Aaron Bentley
shelve_change handles text modification. |
116 |
def prepare_content_change(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
117 |
self.thisFailsStrictLockCheck() |
|
0.12.13
by Aaron Bentley
Implement shelving content |
118 |
tree = self.make_branch_and_tree('.') |
119 |
tree.lock_write() |
|
120 |
self.addCleanup(tree.unlock) |
|
121 |
self.build_tree_contents([('foo', 'a\n')]) |
|
122 |
tree.add('foo', 'foo-id') |
|
123 |
tree.commit('Committed foo') |
|
124 |
self.build_tree_contents([('foo', 'b\na\nc\n')]) |
|
|
0.14.7
by Aaron Bentley
Misc test cleanup |
125 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
0.12.13
by Aaron Bentley
Implement shelving content |
126 |
self.addCleanup(creator.finalize) |
|
4595.8.2
by Aaron Bentley
Implement shelve_all |
127 |
return creator |
128 |
||
129 |
def test_shelve_content_change(self): |
|
130 |
creator = self.prepare_content_change() |
|
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
131 |
self.assertEqual([('modify text', 'foo-id')], |
132 |
list(creator.iter_shelvable())) |
|
|
0.14.14
by Aaron Bentley
Change shelf_text to shelve_lines |
133 |
creator.shelve_lines('foo-id', ['a\n', 'c\n']) |
|
0.12.13
by Aaron Bentley
Implement shelving content |
134 |
creator.transform() |
135 |
self.assertFileEqual('a\nc\n', 'foo') |
|
|
0.12.14
by Aaron Bentley
Add shelving of created files |
136 |
self.assertShelvedFileEqual('b\na\n', creator, 'foo-id') |
137 |
||
|
4595.8.1
by Aaron Bentley
shelve_change handles text modification. |
138 |
def test_shelve_change_handles_modify_text(self): |
139 |
creator = self.prepare_content_change() |
|
140 |
creator.shelve_change(('modify text', 'foo-id')) |
|
141 |
creator.transform() |
|
142 |
self.assertFileEqual('a\n', 'foo') |
|
143 |
self.assertShelvedFileEqual('b\na\nc\n', creator, 'foo-id') |
|
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
144 |
|
|
4595.8.2
by Aaron Bentley
Implement shelve_all |
145 |
def test_shelve_all(self): |
146 |
creator = self.prepare_content_change() |
|
147 |
creator.shelve_all() |
|
148 |
creator.transform() |
|
149 |
self.assertFileEqual('a\n', 'foo') |
|
150 |
self.assertShelvedFileEqual('b\na\nc\n', creator, 'foo-id') |
|
151 |
||
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
152 |
def prepare_shelve_creation(self): |
|
0.12.14
by Aaron Bentley
Add shelving of created files |
153 |
tree = self.make_branch_and_tree('.') |
154 |
tree.lock_write() |
|
155 |
self.addCleanup(tree.unlock) |
|
156 |
tree.commit('Empty tree') |
|
|
0.12.16
by Aaron Bentley
Handle shelving directory creation |
157 |
self.build_tree_contents([('foo', 'a\n'), ('bar/',)]) |
158 |
tree.add(['foo', 'bar'], ['foo-id', 'bar-id']) |
|
|
0.14.7
by Aaron Bentley
Misc test cleanup |
159 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
0.12.14
by Aaron Bentley
Add shelving of created files |
160 |
self.addCleanup(creator.finalize) |
|
0.14.13
by Aaron Bentley
Provide path and kind when deletes/adds are detected. |
161 |
self.assertEqual([('add file', 'bar-id', 'directory', 'bar'), |
162 |
('add file', 'foo-id', 'file', 'foo')], |
|
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
163 |
sorted(list(creator.iter_shelvable()))) |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
164 |
return creator, tree |
165 |
||
166 |
def check_shelve_creation(self, creator, tree): |
|
|
0.12.15
by Aaron Bentley
Handle file-id when shelving creation |
167 |
self.assertRaises(StopIteration, |
168 |
tree.iter_entries_by_dir(['foo-id']).next) |
|
169 |
s_trans_id = creator.shelf_transform.trans_id_file_id('foo-id') |
|
170 |
self.assertEqual('foo-id', |
|
171 |
creator.shelf_transform.final_file_id(s_trans_id)) |
|
|
0.12.14
by Aaron Bentley
Add shelving of created files |
172 |
self.failIfExists('foo') |
|
0.12.16
by Aaron Bentley
Handle shelving directory creation |
173 |
self.failIfExists('bar') |
|
0.12.14
by Aaron Bentley
Add shelving of created files |
174 |
self.assertShelvedFileEqual('a\n', creator, 'foo-id') |
|
0.12.16
by Aaron Bentley
Handle shelving directory creation |
175 |
s_bar_trans_id = creator.shelf_transform.trans_id_file_id('bar-id') |
176 |
self.assertEqual('directory', |
|
177 |
creator.shelf_transform.final_kind(s_bar_trans_id)) |
|
|
0.12.17
by Aaron Bentley
Handle creating symlinks |
178 |
|
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
179 |
def test_shelve_creation(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
180 |
self.thisFailsStrictLockCheck() |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
181 |
creator, tree = self.prepare_shelve_creation() |
182 |
creator.shelve_creation('foo-id') |
|
183 |
creator.shelve_creation('bar-id') |
|
184 |
creator.transform() |
|
185 |
self.check_shelve_creation(creator, tree) |
|
186 |
||
187 |
def test_shelve_change_handles_creation(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
188 |
self.thisFailsStrictLockCheck() |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
189 |
creator, tree = self.prepare_shelve_creation() |
190 |
creator.shelve_change(('add file', 'foo-id', 'file', 'foo')) |
|
191 |
creator.shelve_change(('add file', 'bar-id', 'directory', 'bar')) |
|
192 |
creator.transform() |
|
193 |
self.check_shelve_creation(creator, tree) |
|
194 |
||
195 |
def _test_shelve_symlink_creation(self, link_name, link_target, |
|
196 |
shelve_change=False): |
|
|
4241.14.16
by Vincent Ladeuil
Fix _PreviewTree.get_symlink_target for unicode symlinks. |
197 |
self.requireFeature(tests.SymlinkFeature) |
198 |
tree = self.make_branch_and_tree('.') |
|
199 |
tree.lock_write() |
|
200 |
self.addCleanup(tree.unlock) |
|
201 |
tree.commit('Empty tree') |
|
202 |
os.symlink(link_target, link_name) |
|
203 |
tree.add(link_name, 'foo-id') |
|
204 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
205 |
self.addCleanup(creator.finalize) |
|
206 |
self.assertEqual([('add file', 'foo-id', 'symlink', link_name)], |
|
207 |
list(creator.iter_shelvable())) |
|
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
208 |
if shelve_change: |
209 |
creator.shelve_change(('add file', 'foo-id', 'symlink', link_name)) |
|
210 |
else: |
|
211 |
creator.shelve_creation('foo-id') |
|
|
4241.14.16
by Vincent Ladeuil
Fix _PreviewTree.get_symlink_target for unicode symlinks. |
212 |
creator.transform() |
213 |
s_trans_id = creator.shelf_transform.trans_id_file_id('foo-id') |
|
214 |
self.failIfExists(link_name) |
|
215 |
limbo_name = creator.shelf_transform._limbo_name(s_trans_id) |
|
216 |
self.assertEqual(link_target, osutils.readlink(limbo_name)) |
|
217 |
ptree = creator.shelf_transform.get_preview_tree() |
|
218 |
self.assertEqual(link_target, ptree.get_symlink_target('foo-id')) |
|
219 |
||
|
0.12.17
by Aaron Bentley
Handle creating symlinks |
220 |
def test_shelve_symlink_creation(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
221 |
self.thisFailsStrictLockCheck() |
|
4241.14.16
by Vincent Ladeuil
Fix _PreviewTree.get_symlink_target for unicode symlinks. |
222 |
self._test_shelve_symlink_creation('foo', 'bar') |
223 |
||
224 |
def test_shelve_unicode_symlink_creation(self): |
|
225 |
self.requireFeature(tests.UnicodeFilenameFeature) |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
226 |
self.thisFailsStrictLockCheck() |
|
4241.14.16
by Vincent Ladeuil
Fix _PreviewTree.get_symlink_target for unicode symlinks. |
227 |
self._test_shelve_symlink_creation(u'fo\N{Euro Sign}o', |
228 |
u'b\N{Euro Sign}ar') |
|
|
0.12.19
by Aaron Bentley
Add support for writing shelves |
229 |
|
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
230 |
def test_shelve_change_handles_symlink_creation(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
231 |
self.thisFailsStrictLockCheck() |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
232 |
self._test_shelve_symlink_creation('foo', 'bar', shelve_change=True) |
233 |
||
|
4241.14.12
by Vincent Ladeuil
Far too many modifications for a single commit, need to restart. |
234 |
def _test_shelve_symlink_target_change(self, link_name, |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
235 |
old_target, new_target, |
236 |
shelve_change=False): |
|
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
237 |
self.requireFeature(tests.SymlinkFeature) |
238 |
tree = self.make_branch_and_tree('.') |
|
239 |
tree.lock_write() |
|
240 |
self.addCleanup(tree.unlock) |
|
|
4241.14.12
by Vincent Ladeuil
Far too many modifications for a single commit, need to restart. |
241 |
os.symlink(old_target, link_name) |
242 |
tree.add(link_name, 'foo-id') |
|
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
243 |
tree.commit("commit symlink") |
|
4241.14.12
by Vincent Ladeuil
Far too many modifications for a single commit, need to restart. |
244 |
os.unlink(link_name) |
245 |
os.symlink(new_target, link_name) |
|
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
246 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
247 |
self.addCleanup(creator.finalize) |
|
|
4241.14.12
by Vincent Ladeuil
Far too many modifications for a single commit, need to restart. |
248 |
self.assertEqual([('modify target', 'foo-id', link_name, |
249 |
old_target, new_target)], |
|
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
250 |
list(creator.iter_shelvable())) |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
251 |
if shelve_change: |
252 |
creator.shelve_change(('modify target', 'foo-id', link_name, |
|
253 |
old_target, new_target)) |
|
254 |
else: |
|
255 |
creator.shelve_modify_target('foo-id') |
|
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
256 |
creator.transform() |
|
4241.14.21
by Vincent Ladeuil
More cleanup. |
257 |
self.assertEqual(old_target, osutils.readlink(link_name)) |
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
258 |
s_trans_id = creator.shelf_transform.trans_id_file_id('foo-id') |
259 |
limbo_name = creator.shelf_transform._limbo_name(s_trans_id) |
|
|
4241.14.21
by Vincent Ladeuil
More cleanup. |
260 |
self.assertEqual(new_target, osutils.readlink(limbo_name)) |
|
4241.14.16
by Vincent Ladeuil
Fix _PreviewTree.get_symlink_target for unicode symlinks. |
261 |
ptree = creator.shelf_transform.get_preview_tree() |
262 |
self.assertEqual(new_target, ptree.get_symlink_target('foo-id')) |
|
|
4241.14.12
by Vincent Ladeuil
Far too many modifications for a single commit, need to restart. |
263 |
|
264 |
def test_shelve_symlink_target_change(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
265 |
self.thisFailsStrictLockCheck() |
|
4241.14.12
by Vincent Ladeuil
Far too many modifications for a single commit, need to restart. |
266 |
self._test_shelve_symlink_target_change('foo', 'bar', 'baz') |
267 |
||
268 |
def test_shelve_unicode_symlink_target_change(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
269 |
self.thisFailsStrictLockCheck() |
|
4241.14.12
by Vincent Ladeuil
Far too many modifications for a single commit, need to restart. |
270 |
self.requireFeature(tests.UnicodeFilenameFeature) |
271 |
self._test_shelve_symlink_target_change( |
|
272 |
u'fo\N{Euro Sign}o', u'b\N{Euro Sign}ar', u'b\N{Euro Sign}az') |
|
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
273 |
|
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
274 |
def test_shelve_change_handles_symlink_target_change(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
275 |
self.thisFailsStrictLockCheck() |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
276 |
self._test_shelve_symlink_target_change('foo', 'bar', 'baz', |
277 |
shelve_change=True) |
|
278 |
||
|
0.14.12
by Aaron Bentley
Handle new dangling ids |
279 |
def test_shelve_creation_no_contents(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
280 |
self.thisFailsStrictLockCheck() |
|
0.14.12
by Aaron Bentley
Handle new dangling ids |
281 |
tree = self.make_branch_and_tree('.') |
282 |
tree.lock_write() |
|
283 |
self.addCleanup(tree.unlock) |
|
284 |
tree.commit('Empty tree') |
|
285 |
self.build_tree(['foo']) |
|
286 |
tree.add('foo', 'foo-id') |
|
287 |
os.unlink('foo') |
|
288 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
289 |
self.addCleanup(creator.finalize) |
|
|
0.14.13
by Aaron Bentley
Provide path and kind when deletes/adds are detected. |
290 |
self.assertEqual([('add file', 'foo-id', None, 'foo')], |
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
291 |
sorted(list(creator.iter_shelvable()))) |
|
0.14.12
by Aaron Bentley
Handle new dangling ids |
292 |
creator.shelve_creation('foo-id') |
293 |
creator.transform() |
|
294 |
self.assertRaises(StopIteration, |
|
295 |
tree.iter_entries_by_dir(['foo-id']).next) |
|
296 |
self.assertShelvedFileEqual('', creator, 'foo-id') |
|
297 |
s_trans_id = creator.shelf_transform.trans_id_file_id('foo-id') |
|
298 |
self.assertEqual('foo-id', |
|
299 |
creator.shelf_transform.final_file_id(s_trans_id)) |
|
300 |
self.failIfExists('foo') |
|
301 |
||
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
302 |
def prepare_shelve_deletion(self): |
|
0.14.4
by Aaron Bentley
Implement shelving deletion |
303 |
tree = self.make_branch_and_tree('tree') |
|
0.14.11
by Aaron Bentley
Fix re-versioning |
304 |
tree.lock_write() |
305 |
self.addCleanup(tree.unlock) |
|
|
0.14.4
by Aaron Bentley
Implement shelving deletion |
306 |
self.build_tree_contents([('tree/foo/',), ('tree/foo/bar', 'baz')]) |
307 |
tree.add(['foo', 'foo/bar'], ['foo-id', 'bar-id']) |
|
308 |
tree.commit('Added file and directory') |
|
|
0.14.9
by Aaron Bentley
Shelve deleted files properly |
309 |
tree.unversion(['foo-id', 'bar-id']) |
|
0.14.4
by Aaron Bentley
Implement shelving deletion |
310 |
os.unlink('tree/foo/bar') |
311 |
os.rmdir('tree/foo') |
|
|
0.14.7
by Aaron Bentley
Misc test cleanup |
312 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
0.14.4
by Aaron Bentley
Implement shelving deletion |
313 |
self.addCleanup(creator.finalize) |
|
0.14.13
by Aaron Bentley
Provide path and kind when deletes/adds are detected. |
314 |
self.assertEqual([('delete file', 'bar-id', 'file', 'foo/bar'), |
315 |
('delete file', 'foo-id', 'directory', 'foo')], |
|
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
316 |
sorted(list(creator.iter_shelvable()))) |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
317 |
return creator, tree |
318 |
||
319 |
def check_shelve_deletion(self, tree): |
|
|
0.14.11
by Aaron Bentley
Fix re-versioning |
320 |
self.assertTrue('foo-id' in tree) |
321 |
self.assertTrue('bar-id' in tree) |
|
|
0.14.4
by Aaron Bentley
Implement shelving deletion |
322 |
self.assertFileEqual('baz', 'tree/foo/bar') |
323 |
||
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
324 |
def test_shelve_deletion(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
325 |
self.thisFailsStrictLockCheck() |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
326 |
creator, tree = self.prepare_shelve_deletion() |
327 |
creator.shelve_deletion('foo-id') |
|
328 |
creator.shelve_deletion('bar-id') |
|
329 |
creator.transform() |
|
330 |
self.check_shelve_deletion(tree) |
|
331 |
||
332 |
def test_shelve_change_handles_deletion(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
333 |
self.thisFailsStrictLockCheck() |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
334 |
creator, tree = self.prepare_shelve_deletion() |
335 |
creator.shelve_change(('delete file', 'foo-id', 'directory', 'foo')) |
|
336 |
creator.shelve_change(('delete file', 'bar-id', 'file', 'foo/bar')) |
|
337 |
creator.transform() |
|
338 |
self.check_shelve_deletion(tree) |
|
339 |
||
|
0.14.10
by Aaron Bentley
Fix behavior with deletions, unversioning, ... |
340 |
def test_shelve_delete_contents(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
341 |
self.thisFailsStrictLockCheck() |
|
0.14.10
by Aaron Bentley
Fix behavior with deletions, unversioning, ... |
342 |
tree = self.make_branch_and_tree('tree') |
343 |
self.build_tree(['tree/foo',]) |
|
344 |
tree.add('foo', 'foo-id') |
|
345 |
tree.commit('Added file and directory') |
|
346 |
os.unlink('tree/foo') |
|
347 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
348 |
self.addCleanup(creator.finalize) |
|
|
0.14.13
by Aaron Bentley
Provide path and kind when deletes/adds are detected. |
349 |
self.assertEqual([('delete file', 'foo-id', 'file', 'foo')], |
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
350 |
sorted(list(creator.iter_shelvable()))) |
|
0.14.10
by Aaron Bentley
Fix behavior with deletions, unversioning, ... |
351 |
creator.shelve_deletion('foo-id') |
352 |
creator.transform() |
|
353 |
self.failUnlessExists('tree/foo') |
|
354 |
||
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
355 |
def prepare_shelve_change_kind(self): |
|
0.14.23
by Aaron Bentley
Allow shelving kind change |
356 |
tree = self.make_branch_and_tree('tree') |
357 |
self.build_tree_contents([('tree/foo', 'bar')]) |
|
358 |
tree.add('foo', 'foo-id') |
|
359 |
tree.commit('Added file and directory') |
|
360 |
os.unlink('tree/foo') |
|
361 |
os.mkdir('tree/foo') |
|
362 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
363 |
self.addCleanup(creator.finalize) |
|
364 |
self.assertEqual([('change kind', 'foo-id', 'file', 'directory', |
|
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
365 |
'foo')], sorted(list(creator.iter_shelvable()))) |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
366 |
return creator |
367 |
||
368 |
def check_shelve_change_kind(self, creator): |
|
369 |
self.assertFileEqual('bar', 'tree/foo') |
|
370 |
s_trans_id = creator.shelf_transform.trans_id_file_id('foo-id') |
|
371 |
self.assertEqual('directory', |
|
372 |
creator.shelf_transform._new_contents[s_trans_id]) |
|
373 |
||
374 |
def test_shelve_change_kind(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
375 |
self.thisFailsStrictLockCheck() |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
376 |
creator = self.prepare_shelve_change_kind() |
|
0.14.23
by Aaron Bentley
Allow shelving kind change |
377 |
creator.shelve_content_change('foo-id') |
378 |
creator.transform() |
|
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
379 |
self.check_shelve_change_kind(creator) |
380 |
||
381 |
def test_shelve_change_handles_change_kind(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
382 |
self.thisFailsStrictLockCheck() |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
383 |
creator = self.prepare_shelve_change_kind() |
384 |
creator.shelve_change(('change kind', 'foo-id', 'file', 'directory', |
|
385 |
'foo')) |
|
386 |
creator.transform() |
|
387 |
self.check_shelve_change_kind(creator) |
|
388 |
||
389 |
def test_shelve_change_unknown_change(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
390 |
self.thisFailsStrictLockCheck() |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
391 |
tree = self.make_branch_and_tree('tree') |
392 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
393 |
self.addCleanup(creator.finalize) |
|
394 |
e = self.assertRaises(ValueError, creator.shelve_change, ('unknown',)) |
|
395 |
self.assertEqual('Unknown change kind: "unknown"', str(e)) |
|
|
0.14.23
by Aaron Bentley
Allow shelving kind change |
396 |
|
|
0.14.10
by Aaron Bentley
Fix behavior with deletions, unversioning, ... |
397 |
def test_shelve_unversion(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
398 |
self.thisFailsStrictLockCheck() |
|
0.14.10
by Aaron Bentley
Fix behavior with deletions, unversioning, ... |
399 |
tree = self.make_branch_and_tree('tree') |
400 |
self.build_tree(['tree/foo',]) |
|
401 |
tree.add('foo', 'foo-id') |
|
402 |
tree.commit('Added file and directory') |
|
403 |
tree.unversion(['foo-id']) |
|
404 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
405 |
self.addCleanup(creator.finalize) |
|
|
0.14.13
by Aaron Bentley
Provide path and kind when deletes/adds are detected. |
406 |
self.assertEqual([('delete file', 'foo-id', 'file', 'foo')], |
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
407 |
sorted(list(creator.iter_shelvable()))) |
|
0.14.10
by Aaron Bentley
Fix behavior with deletions, unversioning, ... |
408 |
creator.shelve_deletion('foo-id') |
409 |
creator.transform() |
|
410 |
self.failUnlessExists('tree/foo') |
|
411 |
||
|
0.14.33
by Aaron Bentley
Add explicit test of shelf on-disk format |
412 |
def test_shelve_serialization(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
413 |
self.thisFailsStrictLockCheck() |
|
0.14.33
by Aaron Bentley
Add explicit test of shelf on-disk format |
414 |
tree = self.make_branch_and_tree('.') |
415 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
416 |
self.addCleanup(creator.finalize) |
|
|
0.12.76
by Aaron Bentley
Convert failing tests |
417 |
shelf_file = open('shelf', 'wb') |
418 |
self.addCleanup(shelf_file.close) |
|
419 |
try: |
|
420 |
creator.write_shelf(shelf_file) |
|
421 |
finally: |
|
422 |
shelf_file.close() |
|
423 |
self.assertFileEqual(EMPTY_SHELF, 'shelf') |
|
|
0.14.33
by Aaron Bentley
Add explicit test of shelf on-disk format |
424 |
|
|
0.12.19
by Aaron Bentley
Add support for writing shelves |
425 |
def test_write_shelf(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
426 |
self.thisFailsStrictLockCheck() |
|
0.12.19
by Aaron Bentley
Add support for writing shelves |
427 |
tree = self.make_branch_and_tree('tree') |
428 |
self.build_tree(['tree/foo']) |
|
429 |
tree.add('foo', 'foo-id') |
|
|
0.14.7
by Aaron Bentley
Misc test cleanup |
430 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
431 |
self.addCleanup(creator.finalize) |
|
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
432 |
list(creator.iter_shelvable()) |
|
0.14.2
by Aaron Bentley
Somewhat clean up shelving |
433 |
creator.shelve_creation('foo-id') |
|
0.12.29
by Aaron Bentley
Update failing tests |
434 |
shelf_file = open('shelf', 'wb') |
435 |
try: |
|
|
0.12.61
by Aaron Bentley
Stop assigning result of write_shelf |
436 |
creator.write_shelf(shelf_file) |
|
0.12.29
by Aaron Bentley
Update failing tests |
437 |
finally: |
438 |
shelf_file.close() |
|
|
0.12.19
by Aaron Bentley
Add support for writing shelves |
439 |
parser = pack.ContainerPushParser() |
|
0.12.29
by Aaron Bentley
Update failing tests |
440 |
shelf_file = open('shelf', 'rb') |
|
0.12.19
by Aaron Bentley
Add support for writing shelves |
441 |
try: |
442 |
parser.accept_bytes(shelf_file.read()) |
|
443 |
finally: |
|
444 |
shelf_file.close() |
|
445 |
tt = transform.TransformPreview(tree) |
|
|
0.14.7
by Aaron Bentley
Misc test cleanup |
446 |
self.addCleanup(tt.finalize) |
|
0.12.29
by Aaron Bentley
Update failing tests |
447 |
records = iter(parser.read_pending_records()) |
448 |
#skip revision-id
|
|
449 |
records.next() |
|
|
0.15.26
by Aaron Bentley
Merge with prepare-shelf |
450 |
tt.deserialize(records) |
|
0.12.21
by Aaron Bentley
Add failing test of unshelver |
451 |
|
|
3873.2.4
by Benoît Pierre
Add a test: test_shelve_unversioned; check if tree is in a clean state |
452 |
def test_shelve_unversioned(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
453 |
self.thisFailsStrictLockCheck() |
|
3873.2.4
by Benoît Pierre
Add a test: test_shelve_unversioned; check if tree is in a clean state |
454 |
tree = self.make_branch_and_tree('tree') |
455 |
self.assertRaises(errors.PathsNotVersionedError, |
|
456 |
shelf.ShelfCreator, tree, tree.basis_tree(), ['foo']) |
|
457 |
# We should be able to lock/unlock the tree if ShelfCreator cleaned
|
|
458 |
# after itself.
|
|
459 |
wt = workingtree.WorkingTree.open('tree') |
|
460 |
wt.lock_tree_write() |
|
461 |
wt.unlock() |
|
462 |
# And a second tentative should raise the same error (no
|
|
463 |
# limbo/pending_deletion leftovers).
|
|
464 |
self.assertRaises(errors.PathsNotVersionedError, |
|
465 |
shelf.ShelfCreator, tree, tree.basis_tree(), ['foo']) |
|
466 |
||
|
4595.9.1
by Aaron Bentley
Fix shelve in uncommitted trees. |
467 |
def test_shelve_skips_added_root(self): |
468 |
"""Skip adds of the root when iterating through shelvable changes.""" |
|
469 |
tree = self.make_branch_and_tree('tree') |
|
470 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
471 |
self.addCleanup(creator.finalize) |
|
472 |
self.assertEqual([], list(creator.iter_shelvable())) |
|
473 |
||
|
0.12.21
by Aaron Bentley
Add failing test of unshelver |
474 |
|
475 |
class TestUnshelver(tests.TestCaseWithTransport): |
|
476 |
||
|
0.15.31
by Aaron Bentley
Remove 'unshelve' method, test make_merger |
477 |
def test_make_merger(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
478 |
self.thisFailsStrictLockCheck() |
|
0.12.21
by Aaron Bentley
Add failing test of unshelver |
479 |
tree = self.make_branch_and_tree('tree') |
|
0.12.30
by Aaron Bentley
Fix test by using non NULL base tree |
480 |
tree.commit('first commit') |
|
0.12.21
by Aaron Bentley
Add failing test of unshelver |
481 |
self.build_tree_contents([('tree/foo', 'bar')]) |
|
0.12.24
by Aaron Bentley
Get unshelve using merge codepath, not applying transform directly |
482 |
tree.lock_write() |
483 |
self.addCleanup(tree.unlock) |
|
|
0.12.21
by Aaron Bentley
Add failing test of unshelver |
484 |
tree.add('foo', 'foo-id') |
|
0.15.5
by Aaron Bentley
Rename to shelf |
485 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
486 |
self.addCleanup(creator.finalize) |
|
|
0.12.73
by Aaron Bentley
Merge unshelve into shelf-manager |
487 |
list(creator.iter_shelvable()) |
|
0.12.23
by Aaron Bentley
Fix up unshelve some more |
488 |
creator.shelve_creation('foo-id') |
|
0.12.29
by Aaron Bentley
Update failing tests |
489 |
shelf_file = open('shelf-file', 'w+b') |
490 |
try: |
|
|
0.12.61
by Aaron Bentley
Stop assigning result of write_shelf |
491 |
creator.write_shelf(shelf_file) |
|
0.12.29
by Aaron Bentley
Update failing tests |
492 |
creator.transform() |
493 |
shelf_file.seek(0) |
|
|
0.12.34
by Aaron Bentley
merge with unshelve |
494 |
unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file) |
|
0.12.66
by Aaron Bentley
Merge with unshelve |
495 |
unshelver.make_merger().do_merge() |
|
0.12.29
by Aaron Bentley
Update failing tests |
496 |
self.assertFileEqual('bar', 'tree/foo') |
497 |
finally: |
|
498 |
shelf_file.close() |
|
|
0.12.26
by Aaron Bentley
Use correct base for shelving |
499 |
|
|
0.15.23
by Aaron Bentley
Use correct tree for desrializing transform |
500 |
def test_unshelve_changed(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
501 |
self.thisFailsStrictLockCheck() |
|
0.15.23
by Aaron Bentley
Use correct tree for desrializing transform |
502 |
tree = self.make_branch_and_tree('tree') |
503 |
tree.lock_write() |
|
504 |
self.addCleanup(tree.unlock) |
|
505 |
self.build_tree_contents([('tree/foo', 'a\nb\nc\n')]) |
|
506 |
tree.add('foo', 'foo-id') |
|
507 |
tree.commit('first commit') |
|
508 |
self.build_tree_contents([('tree/foo', 'a\nb\nd\n')]) |
|
509 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
510 |
self.addCleanup(creator.finalize) |
|
|
0.12.73
by Aaron Bentley
Merge unshelve into shelf-manager |
511 |
list(creator.iter_shelvable()) |
|
0.15.23
by Aaron Bentley
Use correct tree for desrializing transform |
512 |
creator.shelve_lines('foo-id', ['a\n', 'b\n', 'c\n']) |
|
0.12.57
by Aaron Bentley
Update for new Shelf API |
513 |
shelf_file = open('shelf', 'w+b') |
514 |
self.addCleanup(shelf_file.close) |
|
515 |
creator.write_shelf(shelf_file) |
|
|
0.15.23
by Aaron Bentley
Use correct tree for desrializing transform |
516 |
creator.transform() |
517 |
self.build_tree_contents([('tree/foo', 'z\na\nb\nc\n')]) |
|
|
0.12.57
by Aaron Bentley
Update for new Shelf API |
518 |
shelf_file.seek(0) |
519 |
unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file) |
|
|
0.15.31
by Aaron Bentley
Remove 'unshelve' method, test make_merger |
520 |
unshelver.make_merger().do_merge() |
|
0.15.23
by Aaron Bentley
Use correct tree for desrializing transform |
521 |
self.assertFileEqual('z\na\nb\nd\n', 'tree/foo') |
522 |
||
|
3981.1.1
by Robert Collins
Fix bug 319790 - unshelve of deleted paths failing. |
523 |
def test_unshelve_deleted(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
524 |
self.thisFailsStrictLockCheck() |
|
3981.1.1
by Robert Collins
Fix bug 319790 - unshelve of deleted paths failing. |
525 |
tree = self.make_branch_and_tree('tree') |
526 |
tree.lock_write() |
|
527 |
self.addCleanup(tree.unlock) |
|
528 |
self.build_tree_contents([('tree/foo/',), ('tree/foo/bar', 'baz')]) |
|
529 |
tree.add(['foo', 'foo/bar'], ['foo-id', 'bar-id']) |
|
530 |
tree.commit('Added file and directory') |
|
531 |
tree.unversion(['foo-id', 'bar-id']) |
|
532 |
os.unlink('tree/foo/bar') |
|
533 |
os.rmdir('tree/foo') |
|
534 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
535 |
list(creator.iter_shelvable()) |
|
536 |
creator.shelve_deletion('foo-id') |
|
537 |
creator.shelve_deletion('bar-id') |
|
538 |
shelf_file = open('shelf', 'w+b') |
|
539 |
self.addCleanup(shelf_file.close) |
|
540 |
creator.write_shelf(shelf_file) |
|
541 |
creator.transform() |
|
542 |
creator.finalize() |
|
543 |
# validate the test setup
|
|
544 |
self.assertTrue('foo-id' in tree) |
|
545 |
self.assertTrue('bar-id' in tree) |
|
546 |
self.assertFileEqual('baz', 'tree/foo/bar') |
|
547 |
shelf_file.seek(0) |
|
548 |
unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file) |
|
549 |
unshelver.make_merger().do_merge() |
|
550 |
self.assertFalse('foo-id' in tree) |
|
551 |
self.assertFalse('bar-id' in tree) |
|
552 |
||
|
0.12.26
by Aaron Bentley
Use correct base for shelving |
553 |
def test_unshelve_base(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
554 |
self.thisFailsStrictLockCheck() |
|
0.12.26
by Aaron Bentley
Use correct base for shelving |
555 |
tree = self.make_branch_and_tree('tree') |
556 |
tree.lock_write() |
|
557 |
self.addCleanup(tree.unlock) |
|
558 |
tree.commit('rev1', rev_id='rev1') |
|
|
0.15.5
by Aaron Bentley
Rename to shelf |
559 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
0.12.59
by Aaron Bentley
Fix locking bugs in tests |
560 |
self.addCleanup(creator.finalize) |
|
0.12.42
by Aaron Bentley
Get shelf from tree |
561 |
manager = tree.get_shelf_manager() |
|
0.12.29
by Aaron Bentley
Update failing tests |
562 |
shelf_id, shelf_file = manager.new_shelf() |
563 |
try: |
|
|
0.12.61
by Aaron Bentley
Stop assigning result of write_shelf |
564 |
creator.write_shelf(shelf_file) |
|
0.12.29
by Aaron Bentley
Update failing tests |
565 |
finally: |
566 |
shelf_file.close() |
|
|
0.12.26
by Aaron Bentley
Use correct base for shelving |
567 |
tree.commit('rev2', rev_id='rev2') |
|
0.12.29
by Aaron Bentley
Update failing tests |
568 |
shelf_file = manager.read_shelf(1) |
|
0.12.59
by Aaron Bentley
Fix locking bugs in tests |
569 |
self.addCleanup(shelf_file.close) |
570 |
unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file) |
|
571 |
self.addCleanup(unshelver.finalize) |
|
|
0.12.26
by Aaron Bentley
Use correct base for shelving |
572 |
self.assertEqual('rev1', unshelver.base_tree.get_revision_id()) |
|
0.12.27
by Aaron Bentley
Implement shelf manager |
573 |
|
|
0.15.41
by Aaron Bentley
Replace assert with proper error handling |
574 |
def test_unshelve_serialization(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
575 |
self.thisFailsStrictLockCheck() |
|
0.15.41
by Aaron Bentley
Replace assert with proper error handling |
576 |
tree = self.make_branch_and_tree('.') |
577 |
self.build_tree_contents([('shelf', EMPTY_SHELF)]) |
|
|
0.12.76
by Aaron Bentley
Convert failing tests |
578 |
shelf_file = open('shelf', 'rb') |
579 |
self.addCleanup(shelf_file.close) |
|
580 |
unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file) |
|
|
0.15.41
by Aaron Bentley
Replace assert with proper error handling |
581 |
|
582 |
def test_corrupt_shelf(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
583 |
self.thisFailsStrictLockCheck() |
|
0.15.41
by Aaron Bentley
Replace assert with proper error handling |
584 |
tree = self.make_branch_and_tree('.') |
585 |
self.build_tree_contents([('shelf', EMPTY_SHELF.replace('metadata', |
|
586 |
'foo'))]) |
|
|
0.12.76
by Aaron Bentley
Convert failing tests |
587 |
shelf_file = open('shelf', 'rb') |
588 |
self.addCleanup(shelf_file.close) |
|
|
0.15.41
by Aaron Bentley
Replace assert with proper error handling |
589 |
e = self.assertRaises(errors.ShelfCorrupt, |
590 |
shelf.Unshelver.from_tree_and_shelf, tree, |
|
|
0.12.76
by Aaron Bentley
Convert failing tests |
591 |
shelf_file) |
|
0.15.41
by Aaron Bentley
Replace assert with proper error handling |
592 |
self.assertEqual('Shelf corrupt.', str(e)) |
|
0.12.75
by Aaron Bentley
Merge unshelve into shelf-manager |
593 |
|
|
0.12.27
by Aaron Bentley
Implement shelf manager |
594 |
|
595 |
class TestShelfManager(tests.TestCaseWithTransport): |
|
596 |
||
|
0.12.42
by Aaron Bentley
Get shelf from tree |
597 |
def test_get_shelf_manager(self): |
|
0.12.27
by Aaron Bentley
Implement shelf manager |
598 |
tree = self.make_branch_and_tree('.') |
|
0.12.42
by Aaron Bentley
Get shelf from tree |
599 |
manager = tree.get_shelf_manager() |
|
0.12.41
by Aaron Bentley
Change shelf to use WT control dir for shelves |
600 |
self.assertEqual(tree._transport.base + 'shelf/', |
|
0.12.27
by Aaron Bentley
Implement shelf manager |
601 |
manager.transport.base) |
602 |
||
603 |
def get_manager(self): |
|
|
0.12.42
by Aaron Bentley
Get shelf from tree |
604 |
return self.make_branch_and_tree('.').get_shelf_manager() |
|
0.12.27
by Aaron Bentley
Implement shelf manager |
605 |
|
|
0.12.77
by Aaron Bentley
Use names of the form shelf-5 for shelves |
606 |
def test_get_shelf_filename(self): |
607 |
tree = self.make_branch_and_tree('.') |
|
608 |
manager = tree.get_shelf_manager() |
|
609 |
self.assertEqual('shelf-1', manager.get_shelf_filename(1)) |
|
610 |
||
611 |
def test_get_shelf_ids(self): |
|
612 |
tree = self.make_branch_and_tree('.') |
|
613 |
manager = tree.get_shelf_manager() |
|
614 |
self.assertEqual([1, 3], manager.get_shelf_ids( |
|
615 |
['shelf-1', 'shelf-02', 'shelf-3'])) |
|
616 |
||
|
0.12.27
by Aaron Bentley
Implement shelf manager |
617 |
def test_new_shelf(self): |
618 |
manager = self.get_manager() |
|
619 |
shelf_id, shelf_file = manager.new_shelf() |
|
620 |
shelf_file.close() |
|
621 |
self.assertEqual(1, shelf_id) |
|
622 |
shelf_id, shelf_file = manager.new_shelf() |
|
623 |
shelf_file.close() |
|
624 |
self.assertEqual(2, shelf_id) |
|
625 |
manager.delete_shelf(1) |
|
626 |
shelf_id, shelf_file = manager.new_shelf() |
|
627 |
shelf_file.close() |
|
628 |
self.assertEqual(3, shelf_id) |
|
629 |
||
630 |
def test_active_shelves(self): |
|
631 |
manager = self.get_manager() |
|
632 |
self.assertEqual([], manager.active_shelves()) |
|
633 |
shelf_id, shelf_file = manager.new_shelf() |
|
634 |
shelf_file.close() |
|
635 |
self.assertEqual([1], manager.active_shelves()) |
|
636 |
||
637 |
def test_delete_shelf(self): |
|
638 |
manager = self.get_manager() |
|
639 |
shelf_id, shelf_file = manager.new_shelf() |
|
640 |
shelf_file.close() |
|
641 |
self.assertEqual([1], manager.active_shelves()) |
|
642 |
manager.delete_shelf(1) |
|
643 |
self.assertEqual([], manager.active_shelves()) |
|
644 |
||
645 |
def test_last_shelf(self): |
|
646 |
manager = self.get_manager() |
|
647 |
self.assertIs(None, manager.last_shelf()) |
|
648 |
shelf_id, shelf_file = manager.new_shelf() |
|
649 |
shelf_file.close() |
|
650 |
self.assertEqual(1, manager.last_shelf()) |
|
651 |
||
652 |
def test_read_shelf(self): |
|
653 |
manager = self.get_manager() |
|
654 |
shelf_id, shelf_file = manager.new_shelf() |
|
655 |
try: |
|
656 |
shelf_file.write('foo') |
|
657 |
finally: |
|
658 |
shelf_file.close() |
|
659 |
shelf_id, shelf_file = manager.new_shelf() |
|
660 |
try: |
|
661 |
shelf_file.write('bar') |
|
662 |
finally: |
|
663 |
shelf_file.close() |
|
664 |
shelf_file = manager.read_shelf(1) |
|
665 |
try: |
|
666 |
self.assertEqual('foo', shelf_file.read()) |
|
667 |
finally: |
|
668 |
shelf_file.close() |
|
669 |
shelf_file = manager.read_shelf(2) |
|
670 |
try: |
|
671 |
self.assertEqual('bar', shelf_file.read()) |
|
672 |
finally: |
|
673 |
shelf_file.close() |
|
|
0.12.43
by Aaron Bentley
Make ShelfManager consume ShelfCreator and produce Unshelver |
674 |
|
|
0.12.50
by Aaron Bentley
Improve error handling for non-existant shelf-ids |
675 |
def test_read_non_existant(self): |
676 |
manager = self.get_manager() |
|
|
0.12.68
by Aaron Bentley
Update docs, move items to proper files. |
677 |
e = self.assertRaises(errors.NoSuchShelfId, manager.read_shelf, 1) |
|
0.12.50
by Aaron Bentley
Improve error handling for non-existant shelf-ids |
678 |
self.assertEqual('No changes are shelved with id "1".', str(e)) |
679 |
||
|
0.12.43
by Aaron Bentley
Make ShelfManager consume ShelfCreator and produce Unshelver |
680 |
def test_shelve_changes(self): |
681 |
tree = self.make_branch_and_tree('tree') |
|
|
0.12.44
by Aaron Bentley
Give manager responsibility for applying transform |
682 |
tree.commit('no-change commit') |
683 |
tree.lock_write() |
|
684 |
self.addCleanup(tree.unlock) |
|
685 |
self.build_tree_contents([('tree/foo', 'bar')]) |
|
686 |
self.assertFileEqual('bar', 'tree/foo') |
|
|
0.12.43
by Aaron Bentley
Make ShelfManager consume ShelfCreator and produce Unshelver |
687 |
tree.add('foo', 'foo-id') |
688 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
689 |
self.addCleanup(creator.finalize) |
|
|
0.12.74
by Aaron Bentley
Update to use iter_shelvable |
690 |
list(creator.iter_shelvable()) |
|
0.12.43
by Aaron Bentley
Make ShelfManager consume ShelfCreator and produce Unshelver |
691 |
creator.shelve_creation('foo-id') |
692 |
shelf_manager = tree.get_shelf_manager() |
|
693 |
shelf_id = shelf_manager.shelve_changes(creator) |
|
|
0.12.44
by Aaron Bentley
Give manager responsibility for applying transform |
694 |
self.failIfExists('tree/foo') |
|
0.12.43
by Aaron Bentley
Make ShelfManager consume ShelfCreator and produce Unshelver |
695 |
unshelver = shelf_manager.get_unshelver(shelf_id) |
|
0.12.67
by Aaron Bentley
Update for new Unshelver API |
696 |
unshelver.make_merger().do_merge() |
|
0.12.44
by Aaron Bentley
Give manager responsibility for applying transform |
697 |
self.assertFileEqual('bar', 'tree/foo') |
|
0.16.112
by Aaron Bentley
Add tests |
698 |
|
699 |
def test_get_metadata(self): |
|
700 |
tree = self.make_branch_and_tree('.') |
|
701 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
702 |
shelf_manager = tree.get_shelf_manager() |
|
703 |
shelf_id = shelf_manager.shelve_changes(creator, 'foo') |
|
704 |
metadata = shelf_manager.get_metadata(shelf_id) |
|
705 |
self.assertEqual('foo', metadata['message']) |
|
706 |
self.assertEqual('null:', metadata['revision_id']) |