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
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
0.12.12
by Aaron Bentley
Implement shelf creator |
16 |
|
0.12.17
by Aaron Bentley
Handle creating symlinks |
17 |
import os |
18 |
||
0.12.68
by Aaron Bentley
Update docs, move items to proper files. |
19 |
from bzrlib import errors, pack, shelf, tests, transform |
0.12.12
by Aaron Bentley
Implement shelf creator |
20 |
|
21 |
||
0.14.34
by Aaron Bentley
Factor out the empty shelf |
22 |
EMPTY_SHELF = ("Bazaar pack format 1 (introduced in 0.18)\n" |
0.15.39
by Aaron Bentley
Update empty shelf serialization |
23 |
"B23\n" |
24 |
"metadata\n\n" |
|
25 |
"d11:revision_id5:null:e"
|
|
0.14.34
by Aaron Bentley
Factor out the empty shelf |
26 |
"B159\n" |
27 |
"attribs\n\n" |
|
28 |
"d10:_id_numberi0e18:_new_executabilityde7:_new_idde"
|
|
29 |
"9:_new_namede11:_new_parentde16:_non_present_idsde"
|
|
30 |
"17:_removed_contentsle11:_removed_idle14:_tree_path_idsdeeE") |
|
31 |
||
32 |
||
0.12.12
by Aaron Bentley
Implement shelf creator |
33 |
class TestPrepareShelf(tests.TestCaseWithTransport): |
34 |
||
35 |
def test_shelve_rename(self): |
|
36 |
tree = self.make_branch_and_tree('.') |
|
37 |
self.build_tree(['foo']) |
|
38 |
tree.add(['foo'], ['foo-id']) |
|
39 |
tree.commit('foo') |
|
40 |
tree.rename_one('foo', 'bar') |
|
0.14.7
by Aaron Bentley
Misc test cleanup |
41 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
0.12.12
by Aaron Bentley
Implement shelf creator |
42 |
self.addCleanup(creator.finalize) |
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
43 |
self.assertEqual([('rename', 'foo-id', 'foo', 'bar')], |
44 |
list(creator.iter_shelvable())) |
|
0.12.12
by Aaron Bentley
Implement shelf creator |
45 |
creator.shelve_rename('foo-id') |
46 |
work_trans_id = creator.work_transform.trans_id_file_id('foo-id') |
|
47 |
self.assertEqual('foo', creator.work_transform.final_name( |
|
48 |
work_trans_id)) |
|
49 |
shelf_trans_id = creator.shelf_transform.trans_id_file_id('foo-id') |
|
50 |
self.assertEqual('bar', creator.shelf_transform.final_name( |
|
51 |
shelf_trans_id)) |
|
52 |
||
53 |
def test_shelve_move(self): |
|
54 |
tree = self.make_branch_and_tree('.') |
|
55 |
self.build_tree(['foo/', 'bar/', 'foo/baz']) |
|
56 |
tree.add(['foo', 'bar', 'foo/baz'], ['foo-id', 'bar-id', 'baz-id']) |
|
57 |
tree.commit('foo') |
|
58 |
tree.rename_one('foo/baz', 'bar/baz') |
|
0.14.7
by Aaron Bentley
Misc test cleanup |
59 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
0.12.12
by Aaron Bentley
Implement shelf creator |
60 |
self.addCleanup(creator.finalize) |
61 |
self.assertEqual([('rename', 'baz-id', 'foo/baz', 'bar/baz')], |
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
62 |
list(creator.iter_shelvable())) |
0.12.12
by Aaron Bentley
Implement shelf creator |
63 |
creator.shelve_rename('baz-id') |
64 |
work_trans_id = creator.work_transform.trans_id_file_id('baz-id') |
|
65 |
work_foo = creator.work_transform.trans_id_file_id('foo-id') |
|
66 |
self.assertEqual(work_foo, creator.work_transform.final_parent( |
|
67 |
work_trans_id)) |
|
68 |
shelf_trans_id = creator.shelf_transform.trans_id_file_id('baz-id') |
|
69 |
shelf_bar = creator.shelf_transform.trans_id_file_id('bar-id') |
|
70 |
self.assertEqual(shelf_bar, creator.shelf_transform.final_parent( |
|
71 |
shelf_trans_id)) |
|
0.12.13
by Aaron Bentley
Implement shelving content |
72 |
creator.transform() |
73 |
self.assertEqual('foo/baz', tree.id2path('baz-id')) |
|
74 |
||
0.12.14
by Aaron Bentley
Add shelving of created files |
75 |
def assertShelvedFileEqual(self, expected_content, creator, file_id): |
76 |
s_trans_id = creator.shelf_transform.trans_id_file_id(file_id) |
|
77 |
shelf_file = creator.shelf_transform._limbo_name(s_trans_id) |
|
78 |
self.assertFileEqual(expected_content, shelf_file) |
|
79 |
||
0.12.13
by Aaron Bentley
Implement shelving content |
80 |
def test_shelve_content_change(self): |
81 |
tree = self.make_branch_and_tree('.') |
|
82 |
tree.lock_write() |
|
83 |
self.addCleanup(tree.unlock) |
|
84 |
self.build_tree_contents([('foo', 'a\n')]) |
|
85 |
tree.add('foo', 'foo-id') |
|
86 |
tree.commit('Committed foo') |
|
87 |
self.build_tree_contents([('foo', 'b\na\nc\n')]) |
|
0.14.7
by Aaron Bentley
Misc test cleanup |
88 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
0.12.13
by Aaron Bentley
Implement shelving content |
89 |
self.addCleanup(creator.finalize) |
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
90 |
self.assertEqual([('modify text', 'foo-id')], |
91 |
list(creator.iter_shelvable())) |
|
0.14.14
by Aaron Bentley
Change shelf_text to shelve_lines |
92 |
creator.shelve_lines('foo-id', ['a\n', 'c\n']) |
0.12.13
by Aaron Bentley
Implement shelving content |
93 |
creator.transform() |
94 |
self.assertFileEqual('a\nc\n', 'foo') |
|
0.12.14
by Aaron Bentley
Add shelving of created files |
95 |
self.assertShelvedFileEqual('b\na\n', creator, 'foo-id') |
96 |
||
97 |
def test_shelve_creation(self): |
|
98 |
tree = self.make_branch_and_tree('.') |
|
99 |
tree.lock_write() |
|
100 |
self.addCleanup(tree.unlock) |
|
101 |
tree.commit('Empty tree') |
|
0.12.16
by Aaron Bentley
Handle shelving directory creation |
102 |
self.build_tree_contents([('foo', 'a\n'), ('bar/',)]) |
103 |
tree.add(['foo', 'bar'], ['foo-id', 'bar-id']) |
|
0.14.7
by Aaron Bentley
Misc test cleanup |
104 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
0.12.14
by Aaron Bentley
Add shelving of created files |
105 |
self.addCleanup(creator.finalize) |
0.14.13
by Aaron Bentley
Provide path and kind when deletes/adds are detected. |
106 |
self.assertEqual([('add file', 'bar-id', 'directory', 'bar'), |
107 |
('add file', 'foo-id', 'file', 'foo')], |
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
108 |
sorted(list(creator.iter_shelvable()))) |
0.14.2
by Aaron Bentley
Somewhat clean up shelving |
109 |
creator.shelve_creation('foo-id') |
110 |
creator.shelve_creation('bar-id') |
|
0.12.14
by Aaron Bentley
Add shelving of created files |
111 |
creator.transform() |
0.12.15
by Aaron Bentley
Handle file-id when shelving creation |
112 |
self.assertRaises(StopIteration, |
113 |
tree.iter_entries_by_dir(['foo-id']).next) |
|
114 |
s_trans_id = creator.shelf_transform.trans_id_file_id('foo-id') |
|
115 |
self.assertEqual('foo-id', |
|
116 |
creator.shelf_transform.final_file_id(s_trans_id)) |
|
0.12.14
by Aaron Bentley
Add shelving of created files |
117 |
self.failIfExists('foo') |
0.12.16
by Aaron Bentley
Handle shelving directory creation |
118 |
self.failIfExists('bar') |
0.12.14
by Aaron Bentley
Add shelving of created files |
119 |
self.assertShelvedFileEqual('a\n', creator, 'foo-id') |
0.12.16
by Aaron Bentley
Handle shelving directory creation |
120 |
s_bar_trans_id = creator.shelf_transform.trans_id_file_id('bar-id') |
121 |
self.assertEqual('directory', |
|
122 |
creator.shelf_transform.final_kind(s_bar_trans_id)) |
|
0.12.17
by Aaron Bentley
Handle creating symlinks |
123 |
|
124 |
def test_shelve_symlink_creation(self): |
|
125 |
self.requireFeature(tests.SymlinkFeature) |
|
126 |
tree = self.make_branch_and_tree('.') |
|
127 |
tree.lock_write() |
|
128 |
self.addCleanup(tree.unlock) |
|
129 |
tree.commit('Empty tree') |
|
130 |
os.symlink('bar', 'foo') |
|
131 |
tree.add('foo', 'foo-id') |
|
0.14.7
by Aaron Bentley
Misc test cleanup |
132 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
0.12.17
by Aaron Bentley
Handle creating symlinks |
133 |
self.addCleanup(creator.finalize) |
0.14.13
by Aaron Bentley
Provide path and kind when deletes/adds are detected. |
134 |
self.assertEqual([('add file', 'foo-id', 'symlink', 'foo')], |
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
135 |
list(creator.iter_shelvable())) |
0.14.2
by Aaron Bentley
Somewhat clean up shelving |
136 |
creator.shelve_creation('foo-id') |
0.12.17
by Aaron Bentley
Handle creating symlinks |
137 |
creator.transform() |
138 |
s_trans_id = creator.shelf_transform.trans_id_file_id('foo-id') |
|
139 |
self.failIfExists('foo') |
|
140 |
limbo_name = creator.shelf_transform._limbo_name(s_trans_id) |
|
141 |
self.assertEqual('bar', os.readlink(limbo_name)) |
|
0.12.19
by Aaron Bentley
Add support for writing shelves |
142 |
|
0.14.12
by Aaron Bentley
Handle new dangling ids |
143 |
def test_shelve_creation_no_contents(self): |
144 |
tree = self.make_branch_and_tree('.') |
|
145 |
tree.lock_write() |
|
146 |
self.addCleanup(tree.unlock) |
|
147 |
tree.commit('Empty tree') |
|
148 |
self.build_tree(['foo']) |
|
149 |
tree.add('foo', 'foo-id') |
|
150 |
os.unlink('foo') |
|
151 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
152 |
self.addCleanup(creator.finalize) |
|
0.14.13
by Aaron Bentley
Provide path and kind when deletes/adds are detected. |
153 |
self.assertEqual([('add file', 'foo-id', None, 'foo')], |
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
154 |
sorted(list(creator.iter_shelvable()))) |
0.14.12
by Aaron Bentley
Handle new dangling ids |
155 |
creator.shelve_creation('foo-id') |
156 |
creator.transform() |
|
157 |
self.assertRaises(StopIteration, |
|
158 |
tree.iter_entries_by_dir(['foo-id']).next) |
|
159 |
self.assertShelvedFileEqual('', creator, 'foo-id') |
|
160 |
s_trans_id = creator.shelf_transform.trans_id_file_id('foo-id') |
|
161 |
self.assertEqual('foo-id', |
|
162 |
creator.shelf_transform.final_file_id(s_trans_id)) |
|
163 |
self.failIfExists('foo') |
|
164 |
||
0.14.4
by Aaron Bentley
Implement shelving deletion |
165 |
def test_shelve_deletion(self): |
166 |
tree = self.make_branch_and_tree('tree') |
|
0.14.11
by Aaron Bentley
Fix re-versioning |
167 |
tree.lock_write() |
168 |
self.addCleanup(tree.unlock) |
|
0.14.4
by Aaron Bentley
Implement shelving deletion |
169 |
self.build_tree_contents([('tree/foo/',), ('tree/foo/bar', 'baz')]) |
170 |
tree.add(['foo', 'foo/bar'], ['foo-id', 'bar-id']) |
|
171 |
tree.commit('Added file and directory') |
|
0.14.9
by Aaron Bentley
Shelve deleted files properly |
172 |
tree.unversion(['foo-id', 'bar-id']) |
0.14.4
by Aaron Bentley
Implement shelving deletion |
173 |
os.unlink('tree/foo/bar') |
174 |
os.rmdir('tree/foo') |
|
0.14.7
by Aaron Bentley
Misc test cleanup |
175 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
0.14.4
by Aaron Bentley
Implement shelving deletion |
176 |
self.addCleanup(creator.finalize) |
0.14.13
by Aaron Bentley
Provide path and kind when deletes/adds are detected. |
177 |
self.assertEqual([('delete file', 'bar-id', 'file', 'foo/bar'), |
178 |
('delete file', 'foo-id', 'directory', 'foo')], |
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
179 |
sorted(list(creator.iter_shelvable()))) |
0.14.4
by Aaron Bentley
Implement shelving deletion |
180 |
creator.shelve_deletion('foo-id') |
181 |
creator.shelve_deletion('bar-id') |
|
0.14.6
by Aaron Bentley
Fix deletion test |
182 |
creator.transform() |
0.14.11
by Aaron Bentley
Fix re-versioning |
183 |
self.assertTrue('foo-id' in tree) |
184 |
self.assertTrue('bar-id' in tree) |
|
0.14.4
by Aaron Bentley
Implement shelving deletion |
185 |
self.assertFileEqual('baz', 'tree/foo/bar') |
186 |
||
0.14.10
by Aaron Bentley
Fix behavior with deletions, unversioning, ... |
187 |
def test_shelve_delete_contents(self): |
188 |
tree = self.make_branch_and_tree('tree') |
|
189 |
self.build_tree(['tree/foo',]) |
|
190 |
tree.add('foo', 'foo-id') |
|
191 |
tree.commit('Added file and directory') |
|
192 |
os.unlink('tree/foo') |
|
193 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
194 |
self.addCleanup(creator.finalize) |
|
0.14.13
by Aaron Bentley
Provide path and kind when deletes/adds are detected. |
195 |
self.assertEqual([('delete file', 'foo-id', 'file', 'foo')], |
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
196 |
sorted(list(creator.iter_shelvable()))) |
0.14.10
by Aaron Bentley
Fix behavior with deletions, unversioning, ... |
197 |
creator.shelve_deletion('foo-id') |
198 |
creator.transform() |
|
199 |
self.failUnlessExists('tree/foo') |
|
200 |
||
0.14.23
by Aaron Bentley
Allow shelving kind change |
201 |
def test_shelve_change_kind(self): |
202 |
tree = self.make_branch_and_tree('tree') |
|
203 |
self.build_tree_contents([('tree/foo', 'bar')]) |
|
204 |
tree.add('foo', 'foo-id') |
|
205 |
tree.commit('Added file and directory') |
|
206 |
os.unlink('tree/foo') |
|
207 |
os.mkdir('tree/foo') |
|
208 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
209 |
self.addCleanup(creator.finalize) |
|
210 |
self.assertEqual([('change kind', 'foo-id', 'file', 'directory', |
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
211 |
'foo')], sorted(list(creator.iter_shelvable()))) |
0.14.23
by Aaron Bentley
Allow shelving kind change |
212 |
creator.shelve_content_change('foo-id') |
213 |
creator.transform() |
|
214 |
self.assertFileEqual('bar', 'tree/foo') |
|
215 |
s_trans_id = creator.shelf_transform.trans_id_file_id('foo-id') |
|
216 |
self.assertEqual('directory', |
|
217 |
creator.shelf_transform._new_contents[s_trans_id]) |
|
218 |
||
0.14.10
by Aaron Bentley
Fix behavior with deletions, unversioning, ... |
219 |
def test_shelve_unversion(self): |
220 |
tree = self.make_branch_and_tree('tree') |
|
221 |
self.build_tree(['tree/foo',]) |
|
222 |
tree.add('foo', 'foo-id') |
|
223 |
tree.commit('Added file and directory') |
|
224 |
tree.unversion(['foo-id']) |
|
225 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
226 |
self.addCleanup(creator.finalize) |
|
0.14.13
by Aaron Bentley
Provide path and kind when deletes/adds are detected. |
227 |
self.assertEqual([('delete file', 'foo-id', 'file', 'foo')], |
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
228 |
sorted(list(creator.iter_shelvable()))) |
0.14.10
by Aaron Bentley
Fix behavior with deletions, unversioning, ... |
229 |
creator.shelve_deletion('foo-id') |
230 |
creator.transform() |
|
231 |
self.failUnlessExists('tree/foo') |
|
232 |
||
0.14.33
by Aaron Bentley
Add explicit test of shelf on-disk format |
233 |
def test_shelve_serialization(self): |
234 |
tree = self.make_branch_and_tree('.') |
|
235 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
236 |
self.addCleanup(creator.finalize) |
|
0.12.76
by Aaron Bentley
Convert failing tests |
237 |
shelf_file = open('shelf', 'wb') |
238 |
self.addCleanup(shelf_file.close) |
|
239 |
try: |
|
240 |
creator.write_shelf(shelf_file) |
|
241 |
finally: |
|
242 |
shelf_file.close() |
|
243 |
self.assertFileEqual(EMPTY_SHELF, 'shelf') |
|
0.14.33
by Aaron Bentley
Add explicit test of shelf on-disk format |
244 |
|
0.12.19
by Aaron Bentley
Add support for writing shelves |
245 |
def test_write_shelf(self): |
246 |
tree = self.make_branch_and_tree('tree') |
|
247 |
self.build_tree(['tree/foo']) |
|
248 |
tree.add('foo', 'foo-id') |
|
0.14.7
by Aaron Bentley
Misc test cleanup |
249 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
250 |
self.addCleanup(creator.finalize) |
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
251 |
list(creator.iter_shelvable()) |
0.14.2
by Aaron Bentley
Somewhat clean up shelving |
252 |
creator.shelve_creation('foo-id') |
0.12.29
by Aaron Bentley
Update failing tests |
253 |
shelf_file = open('shelf', 'wb') |
254 |
try: |
|
0.12.61
by Aaron Bentley
Stop assigning result of write_shelf |
255 |
creator.write_shelf(shelf_file) |
0.12.29
by Aaron Bentley
Update failing tests |
256 |
finally: |
257 |
shelf_file.close() |
|
0.12.19
by Aaron Bentley
Add support for writing shelves |
258 |
parser = pack.ContainerPushParser() |
0.12.29
by Aaron Bentley
Update failing tests |
259 |
shelf_file = open('shelf', 'rb') |
0.12.19
by Aaron Bentley
Add support for writing shelves |
260 |
try: |
261 |
parser.accept_bytes(shelf_file.read()) |
|
262 |
finally: |
|
263 |
shelf_file.close() |
|
264 |
tt = transform.TransformPreview(tree) |
|
0.14.7
by Aaron Bentley
Misc test cleanup |
265 |
self.addCleanup(tt.finalize) |
0.12.29
by Aaron Bentley
Update failing tests |
266 |
records = iter(parser.read_pending_records()) |
267 |
#skip revision-id
|
|
268 |
records.next() |
|
0.15.26
by Aaron Bentley
Merge with prepare-shelf |
269 |
tt.deserialize(records) |
0.12.21
by Aaron Bentley
Add failing test of unshelver |
270 |
|
271 |
||
272 |
class TestUnshelver(tests.TestCaseWithTransport): |
|
273 |
||
0.15.31
by Aaron Bentley
Remove 'unshelve' method, test make_merger |
274 |
def test_make_merger(self): |
0.12.21
by Aaron Bentley
Add failing test of unshelver |
275 |
tree = self.make_branch_and_tree('tree') |
0.12.30
by Aaron Bentley
Fix test by using non NULL base tree |
276 |
tree.commit('first commit') |
0.12.21
by Aaron Bentley
Add failing test of unshelver |
277 |
self.build_tree_contents([('tree/foo', 'bar')]) |
0.12.24
by Aaron Bentley
Get unshelve using merge codepath, not applying transform directly |
278 |
tree.lock_write() |
279 |
self.addCleanup(tree.unlock) |
|
0.12.21
by Aaron Bentley
Add failing test of unshelver |
280 |
tree.add('foo', 'foo-id') |
0.15.5
by Aaron Bentley
Rename to shelf |
281 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
282 |
self.addCleanup(creator.finalize) |
|
0.12.73
by Aaron Bentley
Merge unshelve into shelf-manager |
283 |
list(creator.iter_shelvable()) |
0.12.23
by Aaron Bentley
Fix up unshelve some more |
284 |
creator.shelve_creation('foo-id') |
0.12.29
by Aaron Bentley
Update failing tests |
285 |
shelf_file = open('shelf-file', 'w+b') |
286 |
try: |
|
0.12.61
by Aaron Bentley
Stop assigning result of write_shelf |
287 |
creator.write_shelf(shelf_file) |
0.12.29
by Aaron Bentley
Update failing tests |
288 |
creator.transform() |
289 |
shelf_file.seek(0) |
|
0.12.34
by Aaron Bentley
merge with unshelve |
290 |
unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file) |
0.12.66
by Aaron Bentley
Merge with unshelve |
291 |
unshelver.make_merger().do_merge() |
0.12.29
by Aaron Bentley
Update failing tests |
292 |
self.assertFileEqual('bar', 'tree/foo') |
293 |
finally: |
|
294 |
shelf_file.close() |
|
0.12.26
by Aaron Bentley
Use correct base for shelving |
295 |
|
0.15.23
by Aaron Bentley
Use correct tree for desrializing transform |
296 |
def test_unshelve_changed(self): |
297 |
tree = self.make_branch_and_tree('tree') |
|
298 |
tree.lock_write() |
|
299 |
self.addCleanup(tree.unlock) |
|
300 |
self.build_tree_contents([('tree/foo', 'a\nb\nc\n')]) |
|
301 |
tree.add('foo', 'foo-id') |
|
302 |
tree.commit('first commit') |
|
303 |
self.build_tree_contents([('tree/foo', 'a\nb\nd\n')]) |
|
304 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
305 |
self.addCleanup(creator.finalize) |
|
0.12.73
by Aaron Bentley
Merge unshelve into shelf-manager |
306 |
list(creator.iter_shelvable()) |
0.15.23
by Aaron Bentley
Use correct tree for desrializing transform |
307 |
creator.shelve_lines('foo-id', ['a\n', 'b\n', 'c\n']) |
0.12.57
by Aaron Bentley
Update for new Shelf API |
308 |
shelf_file = open('shelf', 'w+b') |
309 |
self.addCleanup(shelf_file.close) |
|
310 |
creator.write_shelf(shelf_file) |
|
0.15.23
by Aaron Bentley
Use correct tree for desrializing transform |
311 |
creator.transform() |
312 |
self.build_tree_contents([('tree/foo', 'z\na\nb\nc\n')]) |
|
0.12.57
by Aaron Bentley
Update for new Shelf API |
313 |
shelf_file.seek(0) |
314 |
unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file) |
|
0.15.31
by Aaron Bentley
Remove 'unshelve' method, test make_merger |
315 |
unshelver.make_merger().do_merge() |
0.15.23
by Aaron Bentley
Use correct tree for desrializing transform |
316 |
self.assertFileEqual('z\na\nb\nd\n', 'tree/foo') |
317 |
||
0.12.26
by Aaron Bentley
Use correct base for shelving |
318 |
def test_unshelve_base(self): |
319 |
tree = self.make_branch_and_tree('tree') |
|
320 |
tree.lock_write() |
|
321 |
self.addCleanup(tree.unlock) |
|
322 |
tree.commit('rev1', rev_id='rev1') |
|
0.15.5
by Aaron Bentley
Rename to shelf |
323 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
0.12.59
by Aaron Bentley
Fix locking bugs in tests |
324 |
self.addCleanup(creator.finalize) |
0.12.42
by Aaron Bentley
Get shelf from tree |
325 |
manager = tree.get_shelf_manager() |
0.12.29
by Aaron Bentley
Update failing tests |
326 |
shelf_id, shelf_file = manager.new_shelf() |
327 |
try: |
|
0.12.61
by Aaron Bentley
Stop assigning result of write_shelf |
328 |
creator.write_shelf(shelf_file) |
0.12.29
by Aaron Bentley
Update failing tests |
329 |
finally: |
330 |
shelf_file.close() |
|
0.12.26
by Aaron Bentley
Use correct base for shelving |
331 |
tree.commit('rev2', rev_id='rev2') |
0.12.29
by Aaron Bentley
Update failing tests |
332 |
shelf_file = manager.read_shelf(1) |
0.12.59
by Aaron Bentley
Fix locking bugs in tests |
333 |
self.addCleanup(shelf_file.close) |
334 |
unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file) |
|
335 |
self.addCleanup(unshelver.finalize) |
|
0.12.26
by Aaron Bentley
Use correct base for shelving |
336 |
self.assertEqual('rev1', unshelver.base_tree.get_revision_id()) |
0.12.27
by Aaron Bentley
Implement shelf manager |
337 |
|
0.15.41
by Aaron Bentley
Replace assert with proper error handling |
338 |
def test_unshelve_serialization(self): |
339 |
tree = self.make_branch_and_tree('.') |
|
340 |
self.build_tree_contents([('shelf', EMPTY_SHELF)]) |
|
0.12.76
by Aaron Bentley
Convert failing tests |
341 |
shelf_file = open('shelf', 'rb') |
342 |
self.addCleanup(shelf_file.close) |
|
343 |
unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file) |
|
0.15.41
by Aaron Bentley
Replace assert with proper error handling |
344 |
|
345 |
def test_corrupt_shelf(self): |
|
346 |
tree = self.make_branch_and_tree('.') |
|
347 |
self.build_tree_contents([('shelf', EMPTY_SHELF.replace('metadata', |
|
348 |
'foo'))]) |
|
0.12.76
by Aaron Bentley
Convert failing tests |
349 |
shelf_file = open('shelf', 'rb') |
350 |
self.addCleanup(shelf_file.close) |
|
0.15.41
by Aaron Bentley
Replace assert with proper error handling |
351 |
e = self.assertRaises(errors.ShelfCorrupt, |
352 |
shelf.Unshelver.from_tree_and_shelf, tree, |
|
0.12.76
by Aaron Bentley
Convert failing tests |
353 |
shelf_file) |
0.15.41
by Aaron Bentley
Replace assert with proper error handling |
354 |
self.assertEqual('Shelf corrupt.', str(e)) |
0.12.75
by Aaron Bentley
Merge unshelve into shelf-manager |
355 |
|
0.12.27
by Aaron Bentley
Implement shelf manager |
356 |
|
357 |
class TestShelfManager(tests.TestCaseWithTransport): |
|
358 |
||
0.12.42
by Aaron Bentley
Get shelf from tree |
359 |
def test_get_shelf_manager(self): |
0.12.27
by Aaron Bentley
Implement shelf manager |
360 |
tree = self.make_branch_and_tree('.') |
0.12.42
by Aaron Bentley
Get shelf from tree |
361 |
manager = tree.get_shelf_manager() |
0.12.41
by Aaron Bentley
Change shelf to use WT control dir for shelves |
362 |
self.assertEqual(tree._transport.base + 'shelf/', |
0.12.27
by Aaron Bentley
Implement shelf manager |
363 |
manager.transport.base) |
364 |
||
365 |
def get_manager(self): |
|
0.12.42
by Aaron Bentley
Get shelf from tree |
366 |
return self.make_branch_and_tree('.').get_shelf_manager() |
0.12.27
by Aaron Bentley
Implement shelf manager |
367 |
|
0.12.77
by Aaron Bentley
Use names of the form shelf-5 for shelves |
368 |
def test_get_shelf_filename(self): |
369 |
tree = self.make_branch_and_tree('.') |
|
370 |
manager = tree.get_shelf_manager() |
|
371 |
self.assertEqual('shelf-1', manager.get_shelf_filename(1)) |
|
372 |
||
373 |
def test_get_shelf_ids(self): |
|
374 |
tree = self.make_branch_and_tree('.') |
|
375 |
manager = tree.get_shelf_manager() |
|
376 |
self.assertEqual([1, 3], manager.get_shelf_ids( |
|
377 |
['shelf-1', 'shelf-02', 'shelf-3'])) |
|
378 |
||
0.12.27
by Aaron Bentley
Implement shelf manager |
379 |
def test_new_shelf(self): |
380 |
manager = self.get_manager() |
|
381 |
shelf_id, shelf_file = manager.new_shelf() |
|
382 |
shelf_file.close() |
|
383 |
self.assertEqual(1, shelf_id) |
|
384 |
shelf_id, shelf_file = manager.new_shelf() |
|
385 |
shelf_file.close() |
|
386 |
self.assertEqual(2, shelf_id) |
|
387 |
manager.delete_shelf(1) |
|
388 |
shelf_id, shelf_file = manager.new_shelf() |
|
389 |
shelf_file.close() |
|
390 |
self.assertEqual(3, shelf_id) |
|
391 |
||
392 |
def test_active_shelves(self): |
|
393 |
manager = self.get_manager() |
|
394 |
self.assertEqual([], manager.active_shelves()) |
|
395 |
shelf_id, shelf_file = manager.new_shelf() |
|
396 |
shelf_file.close() |
|
397 |
self.assertEqual([1], manager.active_shelves()) |
|
398 |
||
399 |
def test_delete_shelf(self): |
|
400 |
manager = self.get_manager() |
|
401 |
shelf_id, shelf_file = manager.new_shelf() |
|
402 |
shelf_file.close() |
|
403 |
self.assertEqual([1], manager.active_shelves()) |
|
404 |
manager.delete_shelf(1) |
|
405 |
self.assertEqual([], manager.active_shelves()) |
|
406 |
||
407 |
def test_last_shelf(self): |
|
408 |
manager = self.get_manager() |
|
409 |
self.assertIs(None, manager.last_shelf()) |
|
410 |
shelf_id, shelf_file = manager.new_shelf() |
|
411 |
shelf_file.close() |
|
412 |
self.assertEqual(1, manager.last_shelf()) |
|
413 |
||
414 |
def test_read_shelf(self): |
|
415 |
manager = self.get_manager() |
|
416 |
shelf_id, shelf_file = manager.new_shelf() |
|
417 |
try: |
|
418 |
shelf_file.write('foo') |
|
419 |
finally: |
|
420 |
shelf_file.close() |
|
421 |
shelf_id, shelf_file = manager.new_shelf() |
|
422 |
try: |
|
423 |
shelf_file.write('bar') |
|
424 |
finally: |
|
425 |
shelf_file.close() |
|
426 |
shelf_file = manager.read_shelf(1) |
|
427 |
try: |
|
428 |
self.assertEqual('foo', shelf_file.read()) |
|
429 |
finally: |
|
430 |
shelf_file.close() |
|
431 |
shelf_file = manager.read_shelf(2) |
|
432 |
try: |
|
433 |
self.assertEqual('bar', shelf_file.read()) |
|
434 |
finally: |
|
435 |
shelf_file.close() |
|
0.12.43
by Aaron Bentley
Make ShelfManager consume ShelfCreator and produce Unshelver |
436 |
|
0.12.50
by Aaron Bentley
Improve error handling for non-existant shelf-ids |
437 |
def test_read_non_existant(self): |
438 |
manager = self.get_manager() |
|
0.12.68
by Aaron Bentley
Update docs, move items to proper files. |
439 |
e = self.assertRaises(errors.NoSuchShelfId, manager.read_shelf, 1) |
0.12.50
by Aaron Bentley
Improve error handling for non-existant shelf-ids |
440 |
self.assertEqual('No changes are shelved with id "1".', str(e)) |
441 |
||
0.12.43
by Aaron Bentley
Make ShelfManager consume ShelfCreator and produce Unshelver |
442 |
def test_shelve_changes(self): |
443 |
tree = self.make_branch_and_tree('tree') |
|
0.12.44
by Aaron Bentley
Give manager responsibility for applying transform |
444 |
tree.commit('no-change commit') |
445 |
tree.lock_write() |
|
446 |
self.addCleanup(tree.unlock) |
|
447 |
self.build_tree_contents([('tree/foo', 'bar')]) |
|
448 |
self.assertFileEqual('bar', 'tree/foo') |
|
0.12.43
by Aaron Bentley
Make ShelfManager consume ShelfCreator and produce Unshelver |
449 |
tree.add('foo', 'foo-id') |
450 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
451 |
self.addCleanup(creator.finalize) |
|
0.12.74
by Aaron Bentley
Update to use iter_shelvable |
452 |
list(creator.iter_shelvable()) |
0.12.43
by Aaron Bentley
Make ShelfManager consume ShelfCreator and produce Unshelver |
453 |
creator.shelve_creation('foo-id') |
454 |
shelf_manager = tree.get_shelf_manager() |
|
455 |
shelf_id = shelf_manager.shelve_changes(creator) |
|
0.12.44
by Aaron Bentley
Give manager responsibility for applying transform |
456 |
self.failIfExists('tree/foo') |
0.12.43
by Aaron Bentley
Make ShelfManager consume ShelfCreator and produce Unshelver |
457 |
unshelver = shelf_manager.get_unshelver(shelf_id) |
0.12.67
by Aaron Bentley
Update for new Unshelver API |
458 |
unshelver.make_merger().do_merge() |
0.12.44
by Aaron Bentley
Give manager responsibility for applying transform |
459 |
self.assertFileEqual('bar', 'tree/foo') |
0.16.112
by Aaron Bentley
Add tests |
460 |
|
461 |
def test_get_metadata(self): |
|
462 |
tree = self.make_branch_and_tree('.') |
|
463 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
464 |
shelf_manager = tree.get_shelf_manager() |
|
465 |
shelf_id = shelf_manager.shelve_changes(creator, 'foo') |
|
466 |
metadata = shelf_manager.get_metadata(shelf_id) |
|
467 |
self.assertEqual('foo', metadata['message']) |
|
468 |
self.assertEqual('null:', metadata['revision_id']) |