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 |
||
|
0.12.13
by Aaron Bentley
Implement shelving content |
116 |
def test_shelve_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) |
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
127 |
self.assertEqual([('modify text', 'foo-id')], |
128 |
list(creator.iter_shelvable())) |
|
|
0.14.14
by Aaron Bentley
Change shelf_text to shelve_lines |
129 |
creator.shelve_lines('foo-id', ['a\n', 'c\n']) |
|
0.12.13
by Aaron Bentley
Implement shelving content |
130 |
creator.transform() |
131 |
self.assertFileEqual('a\nc\n', 'foo') |
|
|
0.12.14
by Aaron Bentley
Add shelving of created files |
132 |
self.assertShelvedFileEqual('b\na\n', creator, 'foo-id') |
133 |
||
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
134 |
|
135 |
def prepare_shelve_creation(self): |
|
|
0.12.14
by Aaron Bentley
Add shelving of created files |
136 |
tree = self.make_branch_and_tree('.') |
137 |
tree.lock_write() |
|
138 |
self.addCleanup(tree.unlock) |
|
139 |
tree.commit('Empty tree') |
|
|
0.12.16
by Aaron Bentley
Handle shelving directory creation |
140 |
self.build_tree_contents([('foo', 'a\n'), ('bar/',)]) |
141 |
tree.add(['foo', 'bar'], ['foo-id', 'bar-id']) |
|
|
0.14.7
by Aaron Bentley
Misc test cleanup |
142 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
0.12.14
by Aaron Bentley
Add shelving of created files |
143 |
self.addCleanup(creator.finalize) |
|
0.14.13
by Aaron Bentley
Provide path and kind when deletes/adds are detected. |
144 |
self.assertEqual([('add file', 'bar-id', 'directory', 'bar'), |
145 |
('add file', 'foo-id', 'file', 'foo')], |
|
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
146 |
sorted(list(creator.iter_shelvable()))) |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
147 |
return creator, tree |
148 |
||
149 |
def check_shelve_creation(self, creator, tree): |
|
|
0.12.15
by Aaron Bentley
Handle file-id when shelving creation |
150 |
self.assertRaises(StopIteration, |
151 |
tree.iter_entries_by_dir(['foo-id']).next) |
|
152 |
s_trans_id = creator.shelf_transform.trans_id_file_id('foo-id') |
|
153 |
self.assertEqual('foo-id', |
|
154 |
creator.shelf_transform.final_file_id(s_trans_id)) |
|
|
0.12.14
by Aaron Bentley
Add shelving of created files |
155 |
self.failIfExists('foo') |
|
0.12.16
by Aaron Bentley
Handle shelving directory creation |
156 |
self.failIfExists('bar') |
|
0.12.14
by Aaron Bentley
Add shelving of created files |
157 |
self.assertShelvedFileEqual('a\n', creator, 'foo-id') |
|
0.12.16
by Aaron Bentley
Handle shelving directory creation |
158 |
s_bar_trans_id = creator.shelf_transform.trans_id_file_id('bar-id') |
159 |
self.assertEqual('directory', |
|
160 |
creator.shelf_transform.final_kind(s_bar_trans_id)) |
|
|
0.12.17
by Aaron Bentley
Handle creating symlinks |
161 |
|
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
162 |
def test_shelve_creation(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
163 |
self.thisFailsStrictLockCheck() |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
164 |
creator, tree = self.prepare_shelve_creation() |
165 |
creator.shelve_creation('foo-id') |
|
166 |
creator.shelve_creation('bar-id') |
|
167 |
creator.transform() |
|
168 |
self.check_shelve_creation(creator, tree) |
|
169 |
||
170 |
def test_shelve_change_handles_creation(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
171 |
self.thisFailsStrictLockCheck() |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
172 |
creator, tree = self.prepare_shelve_creation() |
173 |
creator.shelve_change(('add file', 'foo-id', 'file', 'foo')) |
|
174 |
creator.shelve_change(('add file', 'bar-id', 'directory', 'bar')) |
|
175 |
creator.transform() |
|
176 |
self.check_shelve_creation(creator, tree) |
|
177 |
||
178 |
def _test_shelve_symlink_creation(self, link_name, link_target, |
|
179 |
shelve_change=False): |
|
|
4241.14.16
by Vincent Ladeuil
Fix _PreviewTree.get_symlink_target for unicode symlinks. |
180 |
self.requireFeature(tests.SymlinkFeature) |
181 |
tree = self.make_branch_and_tree('.') |
|
182 |
tree.lock_write() |
|
183 |
self.addCleanup(tree.unlock) |
|
184 |
tree.commit('Empty tree') |
|
185 |
os.symlink(link_target, link_name) |
|
186 |
tree.add(link_name, 'foo-id') |
|
187 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
188 |
self.addCleanup(creator.finalize) |
|
189 |
self.assertEqual([('add file', 'foo-id', 'symlink', link_name)], |
|
190 |
list(creator.iter_shelvable())) |
|
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
191 |
if shelve_change: |
192 |
creator.shelve_change(('add file', 'foo-id', 'symlink', link_name)) |
|
193 |
else: |
|
194 |
creator.shelve_creation('foo-id') |
|
|
4241.14.16
by Vincent Ladeuil
Fix _PreviewTree.get_symlink_target for unicode symlinks. |
195 |
creator.transform() |
196 |
s_trans_id = creator.shelf_transform.trans_id_file_id('foo-id') |
|
197 |
self.failIfExists(link_name) |
|
198 |
limbo_name = creator.shelf_transform._limbo_name(s_trans_id) |
|
199 |
self.assertEqual(link_target, osutils.readlink(limbo_name)) |
|
200 |
ptree = creator.shelf_transform.get_preview_tree() |
|
201 |
self.assertEqual(link_target, ptree.get_symlink_target('foo-id')) |
|
202 |
||
|
0.12.17
by Aaron Bentley
Handle creating symlinks |
203 |
def test_shelve_symlink_creation(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
204 |
self.thisFailsStrictLockCheck() |
|
4241.14.16
by Vincent Ladeuil
Fix _PreviewTree.get_symlink_target for unicode symlinks. |
205 |
self._test_shelve_symlink_creation('foo', 'bar') |
206 |
||
207 |
def test_shelve_unicode_symlink_creation(self): |
|
208 |
self.requireFeature(tests.UnicodeFilenameFeature) |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
209 |
self.thisFailsStrictLockCheck() |
|
4241.14.16
by Vincent Ladeuil
Fix _PreviewTree.get_symlink_target for unicode symlinks. |
210 |
self._test_shelve_symlink_creation(u'fo\N{Euro Sign}o', |
211 |
u'b\N{Euro Sign}ar') |
|
|
0.12.19
by Aaron Bentley
Add support for writing shelves |
212 |
|
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
213 |
def test_shelve_change_handles_symlink_creation(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
214 |
self.thisFailsStrictLockCheck() |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
215 |
self._test_shelve_symlink_creation('foo', 'bar', shelve_change=True) |
216 |
||
|
4241.14.12
by Vincent Ladeuil
Far too many modifications for a single commit, need to restart. |
217 |
def _test_shelve_symlink_target_change(self, link_name, |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
218 |
old_target, new_target, |
219 |
shelve_change=False): |
|
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
220 |
self.requireFeature(tests.SymlinkFeature) |
221 |
tree = self.make_branch_and_tree('.') |
|
222 |
tree.lock_write() |
|
223 |
self.addCleanup(tree.unlock) |
|
|
4241.14.12
by Vincent Ladeuil
Far too many modifications for a single commit, need to restart. |
224 |
os.symlink(old_target, link_name) |
225 |
tree.add(link_name, 'foo-id') |
|
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
226 |
tree.commit("commit symlink") |
|
4241.14.12
by Vincent Ladeuil
Far too many modifications for a single commit, need to restart. |
227 |
os.unlink(link_name) |
228 |
os.symlink(new_target, link_name) |
|
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
229 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
230 |
self.addCleanup(creator.finalize) |
|
|
4241.14.12
by Vincent Ladeuil
Far too many modifications for a single commit, need to restart. |
231 |
self.assertEqual([('modify target', 'foo-id', link_name, |
232 |
old_target, new_target)], |
|
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
233 |
list(creator.iter_shelvable())) |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
234 |
if shelve_change: |
235 |
creator.shelve_change(('modify target', 'foo-id', link_name, |
|
236 |
old_target, new_target)) |
|
237 |
else: |
|
238 |
creator.shelve_modify_target('foo-id') |
|
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
239 |
creator.transform() |
|
4241.14.21
by Vincent Ladeuil
More cleanup. |
240 |
self.assertEqual(old_target, osutils.readlink(link_name)) |
|
4119.5.1
by James Westby
Shelve can now shelve changes to a symlink's target. |
241 |
s_trans_id = creator.shelf_transform.trans_id_file_id('foo-id') |
242 |
limbo_name = creator.shelf_transform._limbo_name(s_trans_id) |
|
|
4241.14.21
by Vincent Ladeuil
More cleanup. |
243 |
self.assertEqual(new_target, osutils.readlink(limbo_name)) |
|
4241.14.16
by Vincent Ladeuil
Fix _PreviewTree.get_symlink_target for unicode symlinks. |
244 |
ptree = creator.shelf_transform.get_preview_tree() |
245 |
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. |
246 |
|
247 |
def test_shelve_symlink_target_change(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
248 |
self.thisFailsStrictLockCheck() |
|
4241.14.12
by Vincent Ladeuil
Far too many modifications for a single commit, need to restart. |
249 |
self._test_shelve_symlink_target_change('foo', 'bar', 'baz') |
250 |
||
251 |
def test_shelve_unicode_symlink_target_change(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
252 |
self.thisFailsStrictLockCheck() |
|
4241.14.12
by Vincent Ladeuil
Far too many modifications for a single commit, need to restart. |
253 |
self.requireFeature(tests.UnicodeFilenameFeature) |
254 |
self._test_shelve_symlink_target_change( |
|
255 |
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. |
256 |
|
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
257 |
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. |
258 |
self.thisFailsStrictLockCheck() |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
259 |
self._test_shelve_symlink_target_change('foo', 'bar', 'baz', |
260 |
shelve_change=True) |
|
261 |
||
|
0.14.12
by Aaron Bentley
Handle new dangling ids |
262 |
def test_shelve_creation_no_contents(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
263 |
self.thisFailsStrictLockCheck() |
|
0.14.12
by Aaron Bentley
Handle new dangling ids |
264 |
tree = self.make_branch_and_tree('.') |
265 |
tree.lock_write() |
|
266 |
self.addCleanup(tree.unlock) |
|
267 |
tree.commit('Empty tree') |
|
268 |
self.build_tree(['foo']) |
|
269 |
tree.add('foo', 'foo-id') |
|
270 |
os.unlink('foo') |
|
271 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
272 |
self.addCleanup(creator.finalize) |
|
|
0.14.13
by Aaron Bentley
Provide path and kind when deletes/adds are detected. |
273 |
self.assertEqual([('add file', 'foo-id', None, 'foo')], |
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
274 |
sorted(list(creator.iter_shelvable()))) |
|
0.14.12
by Aaron Bentley
Handle new dangling ids |
275 |
creator.shelve_creation('foo-id') |
276 |
creator.transform() |
|
277 |
self.assertRaises(StopIteration, |
|
278 |
tree.iter_entries_by_dir(['foo-id']).next) |
|
279 |
self.assertShelvedFileEqual('', creator, 'foo-id') |
|
280 |
s_trans_id = creator.shelf_transform.trans_id_file_id('foo-id') |
|
281 |
self.assertEqual('foo-id', |
|
282 |
creator.shelf_transform.final_file_id(s_trans_id)) |
|
283 |
self.failIfExists('foo') |
|
284 |
||
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
285 |
def prepare_shelve_deletion(self): |
|
0.14.4
by Aaron Bentley
Implement shelving deletion |
286 |
tree = self.make_branch_and_tree('tree') |
|
0.14.11
by Aaron Bentley
Fix re-versioning |
287 |
tree.lock_write() |
288 |
self.addCleanup(tree.unlock) |
|
|
0.14.4
by Aaron Bentley
Implement shelving deletion |
289 |
self.build_tree_contents([('tree/foo/',), ('tree/foo/bar', 'baz')]) |
290 |
tree.add(['foo', 'foo/bar'], ['foo-id', 'bar-id']) |
|
291 |
tree.commit('Added file and directory') |
|
|
0.14.9
by Aaron Bentley
Shelve deleted files properly |
292 |
tree.unversion(['foo-id', 'bar-id']) |
|
0.14.4
by Aaron Bentley
Implement shelving deletion |
293 |
os.unlink('tree/foo/bar') |
294 |
os.rmdir('tree/foo') |
|
|
0.14.7
by Aaron Bentley
Misc test cleanup |
295 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
0.14.4
by Aaron Bentley
Implement shelving deletion |
296 |
self.addCleanup(creator.finalize) |
|
0.14.13
by Aaron Bentley
Provide path and kind when deletes/adds are detected. |
297 |
self.assertEqual([('delete file', 'bar-id', 'file', 'foo/bar'), |
298 |
('delete file', 'foo-id', 'directory', 'foo')], |
|
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
299 |
sorted(list(creator.iter_shelvable()))) |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
300 |
return creator, tree |
301 |
||
302 |
def check_shelve_deletion(self, tree): |
|
|
0.14.11
by Aaron Bentley
Fix re-versioning |
303 |
self.assertTrue('foo-id' in tree) |
304 |
self.assertTrue('bar-id' in tree) |
|
|
0.14.4
by Aaron Bentley
Implement shelving deletion |
305 |
self.assertFileEqual('baz', 'tree/foo/bar') |
306 |
||
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
307 |
def test_shelve_deletion(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
308 |
self.thisFailsStrictLockCheck() |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
309 |
creator, tree = self.prepare_shelve_deletion() |
310 |
creator.shelve_deletion('foo-id') |
|
311 |
creator.shelve_deletion('bar-id') |
|
312 |
creator.transform() |
|
313 |
self.check_shelve_deletion(tree) |
|
314 |
||
315 |
def test_shelve_change_handles_deletion(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
316 |
self.thisFailsStrictLockCheck() |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
317 |
creator, tree = self.prepare_shelve_deletion() |
318 |
creator.shelve_change(('delete file', 'foo-id', 'directory', 'foo')) |
|
319 |
creator.shelve_change(('delete file', 'bar-id', 'file', 'foo/bar')) |
|
320 |
creator.transform() |
|
321 |
self.check_shelve_deletion(tree) |
|
322 |
||
|
0.14.10
by Aaron Bentley
Fix behavior with deletions, unversioning, ... |
323 |
def test_shelve_delete_contents(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
324 |
self.thisFailsStrictLockCheck() |
|
0.14.10
by Aaron Bentley
Fix behavior with deletions, unversioning, ... |
325 |
tree = self.make_branch_and_tree('tree') |
326 |
self.build_tree(['tree/foo',]) |
|
327 |
tree.add('foo', 'foo-id') |
|
328 |
tree.commit('Added file and directory') |
|
329 |
os.unlink('tree/foo') |
|
330 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
331 |
self.addCleanup(creator.finalize) |
|
|
0.14.13
by Aaron Bentley
Provide path and kind when deletes/adds are detected. |
332 |
self.assertEqual([('delete file', 'foo-id', 'file', 'foo')], |
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
333 |
sorted(list(creator.iter_shelvable()))) |
|
0.14.10
by Aaron Bentley
Fix behavior with deletions, unversioning, ... |
334 |
creator.shelve_deletion('foo-id') |
335 |
creator.transform() |
|
336 |
self.failUnlessExists('tree/foo') |
|
337 |
||
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
338 |
def prepare_shelve_change_kind(self): |
|
0.14.23
by Aaron Bentley
Allow shelving kind change |
339 |
tree = self.make_branch_and_tree('tree') |
340 |
self.build_tree_contents([('tree/foo', 'bar')]) |
|
341 |
tree.add('foo', 'foo-id') |
|
342 |
tree.commit('Added file and directory') |
|
343 |
os.unlink('tree/foo') |
|
344 |
os.mkdir('tree/foo') |
|
345 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
346 |
self.addCleanup(creator.finalize) |
|
347 |
self.assertEqual([('change kind', 'foo-id', 'file', 'directory', |
|
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
348 |
'foo')], sorted(list(creator.iter_shelvable()))) |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
349 |
return creator |
350 |
||
351 |
def check_shelve_change_kind(self, creator): |
|
352 |
self.assertFileEqual('bar', 'tree/foo') |
|
353 |
s_trans_id = creator.shelf_transform.trans_id_file_id('foo-id') |
|
354 |
self.assertEqual('directory', |
|
355 |
creator.shelf_transform._new_contents[s_trans_id]) |
|
356 |
||
357 |
def test_shelve_change_kind(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
358 |
self.thisFailsStrictLockCheck() |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
359 |
creator = self.prepare_shelve_change_kind() |
|
0.14.23
by Aaron Bentley
Allow shelving kind change |
360 |
creator.shelve_content_change('foo-id') |
361 |
creator.transform() |
|
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
362 |
self.check_shelve_change_kind(creator) |
363 |
||
364 |
def test_shelve_change_handles_change_kind(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
365 |
self.thisFailsStrictLockCheck() |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
366 |
creator = self.prepare_shelve_change_kind() |
367 |
creator.shelve_change(('change kind', 'foo-id', 'file', 'directory', |
|
368 |
'foo')) |
|
369 |
creator.transform() |
|
370 |
self.check_shelve_change_kind(creator) |
|
371 |
||
372 |
def test_shelve_change_unknown_change(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
373 |
self.thisFailsStrictLockCheck() |
|
4526.7.3
by Aaron Bentley
Test shelve_change. |
374 |
tree = self.make_branch_and_tree('tree') |
375 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
376 |
self.addCleanup(creator.finalize) |
|
377 |
e = self.assertRaises(ValueError, creator.shelve_change, ('unknown',)) |
|
378 |
self.assertEqual('Unknown change kind: "unknown"', str(e)) |
|
|
0.14.23
by Aaron Bentley
Allow shelving kind change |
379 |
|
|
0.14.10
by Aaron Bentley
Fix behavior with deletions, unversioning, ... |
380 |
def test_shelve_unversion(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
381 |
self.thisFailsStrictLockCheck() |
|
0.14.10
by Aaron Bentley
Fix behavior with deletions, unversioning, ... |
382 |
tree = self.make_branch_and_tree('tree') |
383 |
self.build_tree(['tree/foo',]) |
|
384 |
tree.add('foo', 'foo-id') |
|
385 |
tree.commit('Added file and directory') |
|
386 |
tree.unversion(['foo-id']) |
|
387 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
388 |
self.addCleanup(creator.finalize) |
|
|
0.14.13
by Aaron Bentley
Provide path and kind when deletes/adds are detected. |
389 |
self.assertEqual([('delete file', 'foo-id', 'file', 'foo')], |
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
390 |
sorted(list(creator.iter_shelvable()))) |
|
0.14.10
by Aaron Bentley
Fix behavior with deletions, unversioning, ... |
391 |
creator.shelve_deletion('foo-id') |
392 |
creator.transform() |
|
393 |
self.failUnlessExists('tree/foo') |
|
394 |
||
|
0.14.33
by Aaron Bentley
Add explicit test of shelf on-disk format |
395 |
def test_shelve_serialization(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
396 |
self.thisFailsStrictLockCheck() |
|
0.14.33
by Aaron Bentley
Add explicit test of shelf on-disk format |
397 |
tree = self.make_branch_and_tree('.') |
398 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
399 |
self.addCleanup(creator.finalize) |
|
|
0.12.76
by Aaron Bentley
Convert failing tests |
400 |
shelf_file = open('shelf', 'wb') |
401 |
self.addCleanup(shelf_file.close) |
|
402 |
try: |
|
403 |
creator.write_shelf(shelf_file) |
|
404 |
finally: |
|
405 |
shelf_file.close() |
|
406 |
self.assertFileEqual(EMPTY_SHELF, 'shelf') |
|
|
0.14.33
by Aaron Bentley
Add explicit test of shelf on-disk format |
407 |
|
|
0.12.19
by Aaron Bentley
Add support for writing shelves |
408 |
def test_write_shelf(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
409 |
self.thisFailsStrictLockCheck() |
|
0.12.19
by Aaron Bentley
Add support for writing shelves |
410 |
tree = self.make_branch_and_tree('tree') |
411 |
self.build_tree(['tree/foo']) |
|
412 |
tree.add('foo', 'foo-id') |
|
|
0.14.7
by Aaron Bentley
Misc test cleanup |
413 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
414 |
self.addCleanup(creator.finalize) |
|
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
415 |
list(creator.iter_shelvable()) |
|
0.14.2
by Aaron Bentley
Somewhat clean up shelving |
416 |
creator.shelve_creation('foo-id') |
|
0.12.29
by Aaron Bentley
Update failing tests |
417 |
shelf_file = open('shelf', 'wb') |
418 |
try: |
|
|
0.12.61
by Aaron Bentley
Stop assigning result of write_shelf |
419 |
creator.write_shelf(shelf_file) |
|
0.12.29
by Aaron Bentley
Update failing tests |
420 |
finally: |
421 |
shelf_file.close() |
|
|
0.12.19
by Aaron Bentley
Add support for writing shelves |
422 |
parser = pack.ContainerPushParser() |
|
0.12.29
by Aaron Bentley
Update failing tests |
423 |
shelf_file = open('shelf', 'rb') |
|
0.12.19
by Aaron Bentley
Add support for writing shelves |
424 |
try: |
425 |
parser.accept_bytes(shelf_file.read()) |
|
426 |
finally: |
|
427 |
shelf_file.close() |
|
428 |
tt = transform.TransformPreview(tree) |
|
|
0.14.7
by Aaron Bentley
Misc test cleanup |
429 |
self.addCleanup(tt.finalize) |
|
0.12.29
by Aaron Bentley
Update failing tests |
430 |
records = iter(parser.read_pending_records()) |
431 |
#skip revision-id
|
|
432 |
records.next() |
|
|
0.15.26
by Aaron Bentley
Merge with prepare-shelf |
433 |
tt.deserialize(records) |
|
0.12.21
by Aaron Bentley
Add failing test of unshelver |
434 |
|
|
3873.2.4
by Benoît Pierre
Add a test: test_shelve_unversioned; check if tree is in a clean state |
435 |
def test_shelve_unversioned(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
436 |
self.thisFailsStrictLockCheck() |
|
3873.2.4
by Benoît Pierre
Add a test: test_shelve_unversioned; check if tree is in a clean state |
437 |
tree = self.make_branch_and_tree('tree') |
438 |
self.assertRaises(errors.PathsNotVersionedError, |
|
439 |
shelf.ShelfCreator, tree, tree.basis_tree(), ['foo']) |
|
440 |
# We should be able to lock/unlock the tree if ShelfCreator cleaned
|
|
441 |
# after itself.
|
|
442 |
wt = workingtree.WorkingTree.open('tree') |
|
443 |
wt.lock_tree_write() |
|
444 |
wt.unlock() |
|
445 |
# And a second tentative should raise the same error (no
|
|
446 |
# limbo/pending_deletion leftovers).
|
|
447 |
self.assertRaises(errors.PathsNotVersionedError, |
|
448 |
shelf.ShelfCreator, tree, tree.basis_tree(), ['foo']) |
|
449 |
||
|
0.12.21
by Aaron Bentley
Add failing test of unshelver |
450 |
|
451 |
class TestUnshelver(tests.TestCaseWithTransport): |
|
452 |
||
|
0.15.31
by Aaron Bentley
Remove 'unshelve' method, test make_merger |
453 |
def test_make_merger(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
454 |
self.thisFailsStrictLockCheck() |
|
0.12.21
by Aaron Bentley
Add failing test of unshelver |
455 |
tree = self.make_branch_and_tree('tree') |
|
0.12.30
by Aaron Bentley
Fix test by using non NULL base tree |
456 |
tree.commit('first commit') |
|
0.12.21
by Aaron Bentley
Add failing test of unshelver |
457 |
self.build_tree_contents([('tree/foo', 'bar')]) |
|
0.12.24
by Aaron Bentley
Get unshelve using merge codepath, not applying transform directly |
458 |
tree.lock_write() |
459 |
self.addCleanup(tree.unlock) |
|
|
0.12.21
by Aaron Bentley
Add failing test of unshelver |
460 |
tree.add('foo', 'foo-id') |
|
0.15.5
by Aaron Bentley
Rename to shelf |
461 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
462 |
self.addCleanup(creator.finalize) |
|
|
0.12.73
by Aaron Bentley
Merge unshelve into shelf-manager |
463 |
list(creator.iter_shelvable()) |
|
0.12.23
by Aaron Bentley
Fix up unshelve some more |
464 |
creator.shelve_creation('foo-id') |
|
0.12.29
by Aaron Bentley
Update failing tests |
465 |
shelf_file = open('shelf-file', 'w+b') |
466 |
try: |
|
|
0.12.61
by Aaron Bentley
Stop assigning result of write_shelf |
467 |
creator.write_shelf(shelf_file) |
|
0.12.29
by Aaron Bentley
Update failing tests |
468 |
creator.transform() |
469 |
shelf_file.seek(0) |
|
|
0.12.34
by Aaron Bentley
merge with unshelve |
470 |
unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file) |
|
0.12.66
by Aaron Bentley
Merge with unshelve |
471 |
unshelver.make_merger().do_merge() |
|
0.12.29
by Aaron Bentley
Update failing tests |
472 |
self.assertFileEqual('bar', 'tree/foo') |
473 |
finally: |
|
474 |
shelf_file.close() |
|
|
0.12.26
by Aaron Bentley
Use correct base for shelving |
475 |
|
|
0.15.23
by Aaron Bentley
Use correct tree for desrializing transform |
476 |
def test_unshelve_changed(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
477 |
self.thisFailsStrictLockCheck() |
|
0.15.23
by Aaron Bentley
Use correct tree for desrializing transform |
478 |
tree = self.make_branch_and_tree('tree') |
479 |
tree.lock_write() |
|
480 |
self.addCleanup(tree.unlock) |
|
481 |
self.build_tree_contents([('tree/foo', 'a\nb\nc\n')]) |
|
482 |
tree.add('foo', 'foo-id') |
|
483 |
tree.commit('first commit') |
|
484 |
self.build_tree_contents([('tree/foo', 'a\nb\nd\n')]) |
|
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.15.23
by Aaron Bentley
Use correct tree for desrializing transform |
488 |
creator.shelve_lines('foo-id', ['a\n', 'b\n', 'c\n']) |
|
0.12.57
by Aaron Bentley
Update for new Shelf API |
489 |
shelf_file = open('shelf', 'w+b') |
490 |
self.addCleanup(shelf_file.close) |
|
491 |
creator.write_shelf(shelf_file) |
|
|
0.15.23
by Aaron Bentley
Use correct tree for desrializing transform |
492 |
creator.transform() |
493 |
self.build_tree_contents([('tree/foo', 'z\na\nb\nc\n')]) |
|
|
0.12.57
by Aaron Bentley
Update for new Shelf API |
494 |
shelf_file.seek(0) |
495 |
unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file) |
|
|
0.15.31
by Aaron Bentley
Remove 'unshelve' method, test make_merger |
496 |
unshelver.make_merger().do_merge() |
|
0.15.23
by Aaron Bentley
Use correct tree for desrializing transform |
497 |
self.assertFileEqual('z\na\nb\nd\n', 'tree/foo') |
498 |
||
|
3981.1.1
by Robert Collins
Fix bug 319790 - unshelve of deleted paths failing. |
499 |
def test_unshelve_deleted(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
500 |
self.thisFailsStrictLockCheck() |
|
3981.1.1
by Robert Collins
Fix bug 319790 - unshelve of deleted paths failing. |
501 |
tree = self.make_branch_and_tree('tree') |
502 |
tree.lock_write() |
|
503 |
self.addCleanup(tree.unlock) |
|
504 |
self.build_tree_contents([('tree/foo/',), ('tree/foo/bar', 'baz')]) |
|
505 |
tree.add(['foo', 'foo/bar'], ['foo-id', 'bar-id']) |
|
506 |
tree.commit('Added file and directory') |
|
507 |
tree.unversion(['foo-id', 'bar-id']) |
|
508 |
os.unlink('tree/foo/bar') |
|
509 |
os.rmdir('tree/foo') |
|
510 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
511 |
list(creator.iter_shelvable()) |
|
512 |
creator.shelve_deletion('foo-id') |
|
513 |
creator.shelve_deletion('bar-id') |
|
514 |
shelf_file = open('shelf', 'w+b') |
|
515 |
self.addCleanup(shelf_file.close) |
|
516 |
creator.write_shelf(shelf_file) |
|
517 |
creator.transform() |
|
518 |
creator.finalize() |
|
519 |
# validate the test setup
|
|
520 |
self.assertTrue('foo-id' in tree) |
|
521 |
self.assertTrue('bar-id' in tree) |
|
522 |
self.assertFileEqual('baz', 'tree/foo/bar') |
|
523 |
shelf_file.seek(0) |
|
524 |
unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file) |
|
525 |
unshelver.make_merger().do_merge() |
|
526 |
self.assertFalse('foo-id' in tree) |
|
527 |
self.assertFalse('bar-id' in tree) |
|
528 |
||
|
0.12.26
by Aaron Bentley
Use correct base for shelving |
529 |
def test_unshelve_base(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
530 |
self.thisFailsStrictLockCheck() |
|
0.12.26
by Aaron Bentley
Use correct base for shelving |
531 |
tree = self.make_branch_and_tree('tree') |
532 |
tree.lock_write() |
|
533 |
self.addCleanup(tree.unlock) |
|
534 |
tree.commit('rev1', rev_id='rev1') |
|
|
0.15.5
by Aaron Bentley
Rename to shelf |
535 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
0.12.59
by Aaron Bentley
Fix locking bugs in tests |
536 |
self.addCleanup(creator.finalize) |
|
0.12.42
by Aaron Bentley
Get shelf from tree |
537 |
manager = tree.get_shelf_manager() |
|
0.12.29
by Aaron Bentley
Update failing tests |
538 |
shelf_id, shelf_file = manager.new_shelf() |
539 |
try: |
|
|
0.12.61
by Aaron Bentley
Stop assigning result of write_shelf |
540 |
creator.write_shelf(shelf_file) |
|
0.12.29
by Aaron Bentley
Update failing tests |
541 |
finally: |
542 |
shelf_file.close() |
|
|
0.12.26
by Aaron Bentley
Use correct base for shelving |
543 |
tree.commit('rev2', rev_id='rev2') |
|
0.12.29
by Aaron Bentley
Update failing tests |
544 |
shelf_file = manager.read_shelf(1) |
|
0.12.59
by Aaron Bentley
Fix locking bugs in tests |
545 |
self.addCleanup(shelf_file.close) |
546 |
unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file) |
|
547 |
self.addCleanup(unshelver.finalize) |
|
|
0.12.26
by Aaron Bentley
Use correct base for shelving |
548 |
self.assertEqual('rev1', unshelver.base_tree.get_revision_id()) |
|
0.12.27
by Aaron Bentley
Implement shelf manager |
549 |
|
|
0.15.41
by Aaron Bentley
Replace assert with proper error handling |
550 |
def test_unshelve_serialization(self): |
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
551 |
self.thisFailsStrictLockCheck() |
|
0.15.41
by Aaron Bentley
Replace assert with proper error handling |
552 |
tree = self.make_branch_and_tree('.') |
553 |
self.build_tree_contents([('shelf', EMPTY_SHELF)]) |
|
|
0.12.76
by Aaron Bentley
Convert failing tests |
554 |
shelf_file = open('shelf', 'rb') |
555 |
self.addCleanup(shelf_file.close) |
|
556 |
unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file) |
|
|
0.15.41
by Aaron Bentley
Replace assert with proper error handling |
557 |
|
558 |
def test_corrupt_shelf(self): |
|
|
4523.4.17
by John Arbash Meinel
Now we got to the per-workingtree tests, etc. |
559 |
self.thisFailsStrictLockCheck() |
|
0.15.41
by Aaron Bentley
Replace assert with proper error handling |
560 |
tree = self.make_branch_and_tree('.') |
561 |
self.build_tree_contents([('shelf', EMPTY_SHELF.replace('metadata', |
|
562 |
'foo'))]) |
|
|
0.12.76
by Aaron Bentley
Convert failing tests |
563 |
shelf_file = open('shelf', 'rb') |
564 |
self.addCleanup(shelf_file.close) |
|
|
0.15.41
by Aaron Bentley
Replace assert with proper error handling |
565 |
e = self.assertRaises(errors.ShelfCorrupt, |
566 |
shelf.Unshelver.from_tree_and_shelf, tree, |
|
|
0.12.76
by Aaron Bentley
Convert failing tests |
567 |
shelf_file) |
|
0.15.41
by Aaron Bentley
Replace assert with proper error handling |
568 |
self.assertEqual('Shelf corrupt.', str(e)) |
|
0.12.75
by Aaron Bentley
Merge unshelve into shelf-manager |
569 |
|
|
0.12.27
by Aaron Bentley
Implement shelf manager |
570 |
|
571 |
class TestShelfManager(tests.TestCaseWithTransport): |
|
572 |
||
|
0.12.42
by Aaron Bentley
Get shelf from tree |
573 |
def test_get_shelf_manager(self): |
|
0.12.27
by Aaron Bentley
Implement shelf manager |
574 |
tree = self.make_branch_and_tree('.') |
|
0.12.42
by Aaron Bentley
Get shelf from tree |
575 |
manager = tree.get_shelf_manager() |
|
0.12.41
by Aaron Bentley
Change shelf to use WT control dir for shelves |
576 |
self.assertEqual(tree._transport.base + 'shelf/', |
|
0.12.27
by Aaron Bentley
Implement shelf manager |
577 |
manager.transport.base) |
578 |
||
579 |
def get_manager(self): |
|
|
0.12.42
by Aaron Bentley
Get shelf from tree |
580 |
return self.make_branch_and_tree('.').get_shelf_manager() |
|
0.12.27
by Aaron Bentley
Implement shelf manager |
581 |
|
|
0.12.77
by Aaron Bentley
Use names of the form shelf-5 for shelves |
582 |
def test_get_shelf_filename(self): |
583 |
tree = self.make_branch_and_tree('.') |
|
584 |
manager = tree.get_shelf_manager() |
|
585 |
self.assertEqual('shelf-1', manager.get_shelf_filename(1)) |
|
586 |
||
587 |
def test_get_shelf_ids(self): |
|
588 |
tree = self.make_branch_and_tree('.') |
|
589 |
manager = tree.get_shelf_manager() |
|
590 |
self.assertEqual([1, 3], manager.get_shelf_ids( |
|
591 |
['shelf-1', 'shelf-02', 'shelf-3'])) |
|
592 |
||
|
0.12.27
by Aaron Bentley
Implement shelf manager |
593 |
def test_new_shelf(self): |
594 |
manager = self.get_manager() |
|
595 |
shelf_id, shelf_file = manager.new_shelf() |
|
596 |
shelf_file.close() |
|
597 |
self.assertEqual(1, shelf_id) |
|
598 |
shelf_id, shelf_file = manager.new_shelf() |
|
599 |
shelf_file.close() |
|
600 |
self.assertEqual(2, shelf_id) |
|
601 |
manager.delete_shelf(1) |
|
602 |
shelf_id, shelf_file = manager.new_shelf() |
|
603 |
shelf_file.close() |
|
604 |
self.assertEqual(3, shelf_id) |
|
605 |
||
606 |
def test_active_shelves(self): |
|
607 |
manager = self.get_manager() |
|
608 |
self.assertEqual([], manager.active_shelves()) |
|
609 |
shelf_id, shelf_file = manager.new_shelf() |
|
610 |
shelf_file.close() |
|
611 |
self.assertEqual([1], manager.active_shelves()) |
|
612 |
||
613 |
def test_delete_shelf(self): |
|
614 |
manager = self.get_manager() |
|
615 |
shelf_id, shelf_file = manager.new_shelf() |
|
616 |
shelf_file.close() |
|
617 |
self.assertEqual([1], manager.active_shelves()) |
|
618 |
manager.delete_shelf(1) |
|
619 |
self.assertEqual([], manager.active_shelves()) |
|
620 |
||
621 |
def test_last_shelf(self): |
|
622 |
manager = self.get_manager() |
|
623 |
self.assertIs(None, manager.last_shelf()) |
|
624 |
shelf_id, shelf_file = manager.new_shelf() |
|
625 |
shelf_file.close() |
|
626 |
self.assertEqual(1, manager.last_shelf()) |
|
627 |
||
628 |
def test_read_shelf(self): |
|
629 |
manager = self.get_manager() |
|
630 |
shelf_id, shelf_file = manager.new_shelf() |
|
631 |
try: |
|
632 |
shelf_file.write('foo') |
|
633 |
finally: |
|
634 |
shelf_file.close() |
|
635 |
shelf_id, shelf_file = manager.new_shelf() |
|
636 |
try: |
|
637 |
shelf_file.write('bar') |
|
638 |
finally: |
|
639 |
shelf_file.close() |
|
640 |
shelf_file = manager.read_shelf(1) |
|
641 |
try: |
|
642 |
self.assertEqual('foo', shelf_file.read()) |
|
643 |
finally: |
|
644 |
shelf_file.close() |
|
645 |
shelf_file = manager.read_shelf(2) |
|
646 |
try: |
|
647 |
self.assertEqual('bar', shelf_file.read()) |
|
648 |
finally: |
|
649 |
shelf_file.close() |
|
|
0.12.43
by Aaron Bentley
Make ShelfManager consume ShelfCreator and produce Unshelver |
650 |
|
|
0.12.50
by Aaron Bentley
Improve error handling for non-existant shelf-ids |
651 |
def test_read_non_existant(self): |
652 |
manager = self.get_manager() |
|
|
0.12.68
by Aaron Bentley
Update docs, move items to proper files. |
653 |
e = self.assertRaises(errors.NoSuchShelfId, manager.read_shelf, 1) |
|
0.12.50
by Aaron Bentley
Improve error handling for non-existant shelf-ids |
654 |
self.assertEqual('No changes are shelved with id "1".', str(e)) |
655 |
||
|
0.12.43
by Aaron Bentley
Make ShelfManager consume ShelfCreator and produce Unshelver |
656 |
def test_shelve_changes(self): |
657 |
tree = self.make_branch_and_tree('tree') |
|
|
0.12.44
by Aaron Bentley
Give manager responsibility for applying transform |
658 |
tree.commit('no-change commit') |
659 |
tree.lock_write() |
|
660 |
self.addCleanup(tree.unlock) |
|
661 |
self.build_tree_contents([('tree/foo', 'bar')]) |
|
662 |
self.assertFileEqual('bar', 'tree/foo') |
|
|
0.12.43
by Aaron Bentley
Make ShelfManager consume ShelfCreator and produce Unshelver |
663 |
tree.add('foo', 'foo-id') |
664 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
665 |
self.addCleanup(creator.finalize) |
|
|
0.12.74
by Aaron Bentley
Update to use iter_shelvable |
666 |
list(creator.iter_shelvable()) |
|
0.12.43
by Aaron Bentley
Make ShelfManager consume ShelfCreator and produce Unshelver |
667 |
creator.shelve_creation('foo-id') |
668 |
shelf_manager = tree.get_shelf_manager() |
|
669 |
shelf_id = shelf_manager.shelve_changes(creator) |
|
|
0.12.44
by Aaron Bentley
Give manager responsibility for applying transform |
670 |
self.failIfExists('tree/foo') |
|
0.12.43
by Aaron Bentley
Make ShelfManager consume ShelfCreator and produce Unshelver |
671 |
unshelver = shelf_manager.get_unshelver(shelf_id) |
|
0.12.67
by Aaron Bentley
Update for new Unshelver API |
672 |
unshelver.make_merger().do_merge() |
|
0.12.44
by Aaron Bentley
Give manager responsibility for applying transform |
673 |
self.assertFileEqual('bar', 'tree/foo') |
|
0.16.112
by Aaron Bentley
Add tests |
674 |
|
675 |
def test_get_metadata(self): |
|
676 |
tree = self.make_branch_and_tree('.') |
|
677 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
678 |
shelf_manager = tree.get_shelf_manager() |
|
679 |
shelf_id = shelf_manager.shelve_changes(creator, 'foo') |
|
680 |
metadata = shelf_manager.get_metadata(shelf_id) |
|
681 |
self.assertEqual('foo', metadata['message']) |
|
682 |
self.assertEqual('null:', metadata['revision_id']) |