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 |
#
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
|
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 |
||
22 |
class TestPrepareShelf(tests.TestCaseWithTransport): |
|
23 |
||
24 |
def test_shelve_rename(self): |
|
25 |
tree = self.make_branch_and_tree('.') |
|
26 |
self.build_tree(['foo']) |
|
27 |
tree.add(['foo'], ['foo-id']) |
|
28 |
tree.commit('foo') |
|
29 |
tree.rename_one('foo', 'bar') |
|
|
0.14.7
by Aaron Bentley
Misc test cleanup |
30 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
0.12.12
by Aaron Bentley
Implement shelf creator |
31 |
self.addCleanup(creator.finalize) |
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
32 |
self.assertEqual([('rename', 'foo-id', 'foo', 'bar')], |
33 |
list(creator.iter_shelvable())) |
|
|
0.12.12
by Aaron Bentley
Implement shelf creator |
34 |
creator.shelve_rename('foo-id') |
35 |
work_trans_id = creator.work_transform.trans_id_file_id('foo-id') |
|
36 |
self.assertEqual('foo', creator.work_transform.final_name( |
|
37 |
work_trans_id)) |
|
38 |
shelf_trans_id = creator.shelf_transform.trans_id_file_id('foo-id') |
|
39 |
self.assertEqual('bar', creator.shelf_transform.final_name( |
|
40 |
shelf_trans_id)) |
|
41 |
||
42 |
def test_shelve_move(self): |
|
43 |
tree = self.make_branch_and_tree('.') |
|
44 |
self.build_tree(['foo/', 'bar/', 'foo/baz']) |
|
45 |
tree.add(['foo', 'bar', 'foo/baz'], ['foo-id', 'bar-id', 'baz-id']) |
|
46 |
tree.commit('foo') |
|
47 |
tree.rename_one('foo/baz', 'bar/baz') |
|
|
0.14.7
by Aaron Bentley
Misc test cleanup |
48 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
0.12.12
by Aaron Bentley
Implement shelf creator |
49 |
self.addCleanup(creator.finalize) |
50 |
self.assertEqual([('rename', 'baz-id', 'foo/baz', 'bar/baz')], |
|
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
51 |
list(creator.iter_shelvable())) |
|
0.12.12
by Aaron Bentley
Implement shelf creator |
52 |
creator.shelve_rename('baz-id') |
53 |
work_trans_id = creator.work_transform.trans_id_file_id('baz-id') |
|
54 |
work_foo = creator.work_transform.trans_id_file_id('foo-id') |
|
55 |
self.assertEqual(work_foo, creator.work_transform.final_parent( |
|
56 |
work_trans_id)) |
|
57 |
shelf_trans_id = creator.shelf_transform.trans_id_file_id('baz-id') |
|
58 |
shelf_bar = creator.shelf_transform.trans_id_file_id('bar-id') |
|
59 |
self.assertEqual(shelf_bar, creator.shelf_transform.final_parent( |
|
60 |
shelf_trans_id)) |
|
|
0.12.13
by Aaron Bentley
Implement shelving content |
61 |
creator.transform() |
62 |
self.assertEqual('foo/baz', tree.id2path('baz-id')) |
|
63 |
||
|
0.12.14
by Aaron Bentley
Add shelving of created files |
64 |
def assertShelvedFileEqual(self, expected_content, creator, file_id): |
65 |
s_trans_id = creator.shelf_transform.trans_id_file_id(file_id) |
|
66 |
shelf_file = creator.shelf_transform._limbo_name(s_trans_id) |
|
67 |
self.assertFileEqual(expected_content, shelf_file) |
|
68 |
||
|
0.12.13
by Aaron Bentley
Implement shelving content |
69 |
def test_shelve_content_change(self): |
70 |
tree = self.make_branch_and_tree('.') |
|
71 |
tree.lock_write() |
|
72 |
self.addCleanup(tree.unlock) |
|
73 |
self.build_tree_contents([('foo', 'a\n')]) |
|
74 |
tree.add('foo', 'foo-id') |
|
75 |
tree.commit('Committed foo') |
|
76 |
self.build_tree_contents([('foo', 'b\na\nc\n')]) |
|
|
0.14.7
by Aaron Bentley
Misc test cleanup |
77 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
0.12.13
by Aaron Bentley
Implement shelving content |
78 |
self.addCleanup(creator.finalize) |
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
79 |
self.assertEqual([('modify text', 'foo-id')], |
80 |
list(creator.iter_shelvable())) |
|
|
0.14.14
by Aaron Bentley
Change shelf_text to shelve_lines |
81 |
creator.shelve_lines('foo-id', ['a\n', 'c\n']) |
|
0.12.13
by Aaron Bentley
Implement shelving content |
82 |
creator.transform() |
83 |
self.assertFileEqual('a\nc\n', 'foo') |
|
|
0.12.14
by Aaron Bentley
Add shelving of created files |
84 |
self.assertShelvedFileEqual('b\na\n', creator, 'foo-id') |
85 |
||
86 |
def test_shelve_creation(self): |
|
87 |
tree = self.make_branch_and_tree('.') |
|
88 |
tree.lock_write() |
|
89 |
self.addCleanup(tree.unlock) |
|
90 |
tree.commit('Empty tree') |
|
|
0.12.16
by Aaron Bentley
Handle shelving directory creation |
91 |
self.build_tree_contents([('foo', 'a\n'), ('bar/',)]) |
92 |
tree.add(['foo', 'bar'], ['foo-id', 'bar-id']) |
|
|
0.14.7
by Aaron Bentley
Misc test cleanup |
93 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
0.12.14
by Aaron Bentley
Add shelving of created files |
94 |
self.addCleanup(creator.finalize) |
|
0.14.13
by Aaron Bentley
Provide path and kind when deletes/adds are detected. |
95 |
self.assertEqual([('add file', 'bar-id', 'directory', 'bar'), |
96 |
('add file', 'foo-id', 'file', 'foo')], |
|
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
97 |
sorted(list(creator.iter_shelvable()))) |
|
0.14.2
by Aaron Bentley
Somewhat clean up shelving |
98 |
creator.shelve_creation('foo-id') |
99 |
creator.shelve_creation('bar-id') |
|
|
0.12.14
by Aaron Bentley
Add shelving of created files |
100 |
creator.transform() |
|
0.12.15
by Aaron Bentley
Handle file-id when shelving creation |
101 |
self.assertRaises(StopIteration, |
102 |
tree.iter_entries_by_dir(['foo-id']).next) |
|
103 |
s_trans_id = creator.shelf_transform.trans_id_file_id('foo-id') |
|
104 |
self.assertEqual('foo-id', |
|
105 |
creator.shelf_transform.final_file_id(s_trans_id)) |
|
|
0.12.14
by Aaron Bentley
Add shelving of created files |
106 |
self.failIfExists('foo') |
|
0.12.16
by Aaron Bentley
Handle shelving directory creation |
107 |
self.failIfExists('bar') |
|
0.12.14
by Aaron Bentley
Add shelving of created files |
108 |
self.assertShelvedFileEqual('a\n', creator, 'foo-id') |
|
0.12.16
by Aaron Bentley
Handle shelving directory creation |
109 |
s_bar_trans_id = creator.shelf_transform.trans_id_file_id('bar-id') |
110 |
self.assertEqual('directory', |
|
111 |
creator.shelf_transform.final_kind(s_bar_trans_id)) |
|
|
0.12.17
by Aaron Bentley
Handle creating symlinks |
112 |
|
113 |
def test_shelve_symlink_creation(self): |
|
114 |
self.requireFeature(tests.SymlinkFeature) |
|
115 |
tree = self.make_branch_and_tree('.') |
|
116 |
tree.lock_write() |
|
117 |
self.addCleanup(tree.unlock) |
|
118 |
tree.commit('Empty tree') |
|
119 |
os.symlink('bar', 'foo') |
|
120 |
tree.add('foo', 'foo-id') |
|
|
0.14.7
by Aaron Bentley
Misc test cleanup |
121 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
0.12.17
by Aaron Bentley
Handle creating symlinks |
122 |
self.addCleanup(creator.finalize) |
|
0.14.13
by Aaron Bentley
Provide path and kind when deletes/adds are detected. |
123 |
self.assertEqual([('add file', 'foo-id', 'symlink', 'foo')], |
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
124 |
list(creator.iter_shelvable())) |
|
0.14.2
by Aaron Bentley
Somewhat clean up shelving |
125 |
creator.shelve_creation('foo-id') |
|
0.12.17
by Aaron Bentley
Handle creating symlinks |
126 |
creator.transform() |
127 |
s_trans_id = creator.shelf_transform.trans_id_file_id('foo-id') |
|
128 |
self.failIfExists('foo') |
|
129 |
limbo_name = creator.shelf_transform._limbo_name(s_trans_id) |
|
130 |
self.assertEqual('bar', os.readlink(limbo_name)) |
|
|
0.12.19
by Aaron Bentley
Add support for writing shelves |
131 |
|
|
0.14.12
by Aaron Bentley
Handle new dangling ids |
132 |
def test_shelve_creation_no_contents(self): |
133 |
tree = self.make_branch_and_tree('.') |
|
134 |
tree.lock_write() |
|
135 |
self.addCleanup(tree.unlock) |
|
136 |
tree.commit('Empty tree') |
|
137 |
self.build_tree(['foo']) |
|
138 |
tree.add('foo', 'foo-id') |
|
139 |
os.unlink('foo') |
|
140 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
141 |
self.addCleanup(creator.finalize) |
|
|
0.14.13
by Aaron Bentley
Provide path and kind when deletes/adds are detected. |
142 |
self.assertEqual([('add file', 'foo-id', None, 'foo')], |
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
143 |
sorted(list(creator.iter_shelvable()))) |
|
0.14.12
by Aaron Bentley
Handle new dangling ids |
144 |
creator.shelve_creation('foo-id') |
145 |
creator.transform() |
|
146 |
self.assertRaises(StopIteration, |
|
147 |
tree.iter_entries_by_dir(['foo-id']).next) |
|
148 |
self.assertShelvedFileEqual('', creator, 'foo-id') |
|
149 |
s_trans_id = creator.shelf_transform.trans_id_file_id('foo-id') |
|
150 |
self.assertEqual('foo-id', |
|
151 |
creator.shelf_transform.final_file_id(s_trans_id)) |
|
152 |
self.failIfExists('foo') |
|
153 |
||
|
0.14.4
by Aaron Bentley
Implement shelving deletion |
154 |
def test_shelve_deletion(self): |
155 |
tree = self.make_branch_and_tree('tree') |
|
|
0.14.11
by Aaron Bentley
Fix re-versioning |
156 |
tree.lock_write() |
157 |
self.addCleanup(tree.unlock) |
|
|
0.14.4
by Aaron Bentley
Implement shelving deletion |
158 |
self.build_tree_contents([('tree/foo/',), ('tree/foo/bar', 'baz')]) |
159 |
tree.add(['foo', 'foo/bar'], ['foo-id', 'bar-id']) |
|
160 |
tree.commit('Added file and directory') |
|
|
0.14.9
by Aaron Bentley
Shelve deleted files properly |
161 |
tree.unversion(['foo-id', 'bar-id']) |
|
0.14.4
by Aaron Bentley
Implement shelving deletion |
162 |
os.unlink('tree/foo/bar') |
163 |
os.rmdir('tree/foo') |
|
|
0.14.7
by Aaron Bentley
Misc test cleanup |
164 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
0.14.4
by Aaron Bentley
Implement shelving deletion |
165 |
self.addCleanup(creator.finalize) |
|
0.14.13
by Aaron Bentley
Provide path and kind when deletes/adds are detected. |
166 |
self.assertEqual([('delete file', 'bar-id', 'file', 'foo/bar'), |
167 |
('delete file', 'foo-id', 'directory', 'foo')], |
|
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
168 |
sorted(list(creator.iter_shelvable()))) |
|
0.14.4
by Aaron Bentley
Implement shelving deletion |
169 |
creator.shelve_deletion('foo-id') |
170 |
creator.shelve_deletion('bar-id') |
|
|
0.14.6
by Aaron Bentley
Fix deletion test |
171 |
creator.transform() |
|
0.14.11
by Aaron Bentley
Fix re-versioning |
172 |
self.assertTrue('foo-id' in tree) |
173 |
self.assertTrue('bar-id' in tree) |
|
|
0.14.4
by Aaron Bentley
Implement shelving deletion |
174 |
self.assertFileEqual('baz', 'tree/foo/bar') |
175 |
||
|
0.14.10
by Aaron Bentley
Fix behavior with deletions, unversioning, ... |
176 |
def test_shelve_delete_contents(self): |
177 |
tree = self.make_branch_and_tree('tree') |
|
178 |
self.build_tree(['tree/foo',]) |
|
179 |
tree.add('foo', 'foo-id') |
|
180 |
tree.commit('Added file and directory') |
|
181 |
os.unlink('tree/foo') |
|
182 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
183 |
self.addCleanup(creator.finalize) |
|
|
0.14.13
by Aaron Bentley
Provide path and kind when deletes/adds are detected. |
184 |
self.assertEqual([('delete file', 'foo-id', 'file', 'foo')], |
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
185 |
sorted(list(creator.iter_shelvable()))) |
|
0.14.10
by Aaron Bentley
Fix behavior with deletions, unversioning, ... |
186 |
creator.shelve_deletion('foo-id') |
187 |
creator.transform() |
|
188 |
self.failUnlessExists('tree/foo') |
|
189 |
||
|
0.14.23
by Aaron Bentley
Allow shelving kind change |
190 |
def test_shelve_change_kind(self): |
191 |
tree = self.make_branch_and_tree('tree') |
|
192 |
self.build_tree_contents([('tree/foo', 'bar')]) |
|
193 |
tree.add('foo', 'foo-id') |
|
194 |
tree.commit('Added file and directory') |
|
195 |
os.unlink('tree/foo') |
|
196 |
os.mkdir('tree/foo') |
|
197 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
198 |
self.addCleanup(creator.finalize) |
|
199 |
self.assertEqual([('change kind', 'foo-id', 'file', 'directory', |
|
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
200 |
'foo')], sorted(list(creator.iter_shelvable()))) |
|
0.14.23
by Aaron Bentley
Allow shelving kind change |
201 |
creator.shelve_content_change('foo-id') |
202 |
creator.transform() |
|
203 |
self.assertFileEqual('bar', 'tree/foo') |
|
204 |
s_trans_id = creator.shelf_transform.trans_id_file_id('foo-id') |
|
205 |
self.assertEqual('directory', |
|
206 |
creator.shelf_transform._new_contents[s_trans_id]) |
|
207 |
||
|
0.14.10
by Aaron Bentley
Fix behavior with deletions, unversioning, ... |
208 |
def test_shelve_unversion(self): |
209 |
tree = self.make_branch_and_tree('tree') |
|
210 |
self.build_tree(['tree/foo',]) |
|
211 |
tree.add('foo', 'foo-id') |
|
212 |
tree.commit('Added file and directory') |
|
213 |
tree.unversion(['foo-id']) |
|
214 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
215 |
self.addCleanup(creator.finalize) |
|
|
0.14.13
by Aaron Bentley
Provide path and kind when deletes/adds are detected. |
216 |
self.assertEqual([('delete file', 'foo-id', 'file', 'foo')], |
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
217 |
sorted(list(creator.iter_shelvable()))) |
|
0.14.10
by Aaron Bentley
Fix behavior with deletions, unversioning, ... |
218 |
creator.shelve_deletion('foo-id') |
219 |
creator.transform() |
|
220 |
self.failUnlessExists('tree/foo') |
|
221 |
||
|
0.12.19
by Aaron Bentley
Add support for writing shelves |
222 |
def test_write_shelf(self): |
223 |
tree = self.make_branch_and_tree('tree') |
|
224 |
self.build_tree(['tree/foo']) |
|
225 |
tree.add('foo', 'foo-id') |
|
|
0.14.7
by Aaron Bentley
Misc test cleanup |
226 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
227 |
self.addCleanup(creator.finalize) |
|
|
0.14.32
by Aaron Bentley
Replace ShelfCreator.__iter__ with ShelfCreator.iter_shelvable |
228 |
list(creator.iter_shelvable()) |
|
0.14.2
by Aaron Bentley
Somewhat clean up shelving |
229 |
creator.shelve_creation('foo-id') |
|
0.12.29
by Aaron Bentley
Update failing tests |
230 |
shelf_file = open('shelf', 'wb') |
231 |
try: |
|
|
0.12.61
by Aaron Bentley
Stop assigning result of write_shelf |
232 |
creator.write_shelf(shelf_file) |
|
0.12.29
by Aaron Bentley
Update failing tests |
233 |
finally: |
234 |
shelf_file.close() |
|
|
0.12.19
by Aaron Bentley
Add support for writing shelves |
235 |
parser = pack.ContainerPushParser() |
|
0.12.29
by Aaron Bentley
Update failing tests |
236 |
shelf_file = open('shelf', 'rb') |
|
0.12.19
by Aaron Bentley
Add support for writing shelves |
237 |
try: |
238 |
parser.accept_bytes(shelf_file.read()) |
|
239 |
finally: |
|
240 |
shelf_file.close() |
|
241 |
tt = transform.TransformPreview(tree) |
|
|
0.14.7
by Aaron Bentley
Misc test cleanup |
242 |
self.addCleanup(tt.finalize) |
|
0.12.29
by Aaron Bentley
Update failing tests |
243 |
records = iter(parser.read_pending_records()) |
244 |
#skip revision-id
|
|
245 |
records.next() |
|
|
0.15.26
by Aaron Bentley
Merge with prepare-shelf |
246 |
tt.deserialize(records) |
|
0.12.21
by Aaron Bentley
Add failing test of unshelver |
247 |
|
248 |
||
249 |
class TestUnshelver(tests.TestCaseWithTransport): |
|
250 |
||
|
0.15.31
by Aaron Bentley
Remove 'unshelve' method, test make_merger |
251 |
def test_make_merger(self): |
|
0.12.21
by Aaron Bentley
Add failing test of unshelver |
252 |
tree = self.make_branch_and_tree('tree') |
|
0.12.30
by Aaron Bentley
Fix test by using non NULL base tree |
253 |
tree.commit('first commit') |
|
0.12.21
by Aaron Bentley
Add failing test of unshelver |
254 |
self.build_tree_contents([('tree/foo', 'bar')]) |
|
0.12.24
by Aaron Bentley
Get unshelve using merge codepath, not applying transform directly |
255 |
tree.lock_write() |
256 |
self.addCleanup(tree.unlock) |
|
|
0.12.21
by Aaron Bentley
Add failing test of unshelver |
257 |
tree.add('foo', 'foo-id') |
|
0.15.5
by Aaron Bentley
Rename to shelf |
258 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
259 |
self.addCleanup(creator.finalize) |
|
|
0.12.73
by Aaron Bentley
Merge unshelve into shelf-manager |
260 |
list(creator.iter_shelvable()) |
|
0.12.23
by Aaron Bentley
Fix up unshelve some more |
261 |
creator.shelve_creation('foo-id') |
|
0.12.29
by Aaron Bentley
Update failing tests |
262 |
shelf_file = open('shelf-file', 'w+b') |
263 |
try: |
|
|
0.12.61
by Aaron Bentley
Stop assigning result of write_shelf |
264 |
creator.write_shelf(shelf_file) |
|
0.12.29
by Aaron Bentley
Update failing tests |
265 |
creator.transform() |
266 |
shelf_file.seek(0) |
|
|
0.12.34
by Aaron Bentley
merge with unshelve |
267 |
unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file) |
|
0.12.66
by Aaron Bentley
Merge with unshelve |
268 |
unshelver.make_merger().do_merge() |
|
0.12.29
by Aaron Bentley
Update failing tests |
269 |
self.assertFileEqual('bar', 'tree/foo') |
270 |
finally: |
|
271 |
shelf_file.close() |
|
|
0.12.26
by Aaron Bentley
Use correct base for shelving |
272 |
|
|
0.15.23
by Aaron Bentley
Use correct tree for desrializing transform |
273 |
def test_unshelve_changed(self): |
274 |
tree = self.make_branch_and_tree('tree') |
|
275 |
tree.lock_write() |
|
276 |
self.addCleanup(tree.unlock) |
|
277 |
self.build_tree_contents([('tree/foo', 'a\nb\nc\n')]) |
|
278 |
tree.add('foo', 'foo-id') |
|
279 |
tree.commit('first commit') |
|
280 |
self.build_tree_contents([('tree/foo', 'a\nb\nd\n')]) |
|
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.15.23
by Aaron Bentley
Use correct tree for desrializing transform |
284 |
creator.shelve_lines('foo-id', ['a\n', 'b\n', 'c\n']) |
|
0.12.57
by Aaron Bentley
Update for new Shelf API |
285 |
shelf_file = open('shelf', 'w+b') |
286 |
self.addCleanup(shelf_file.close) |
|
287 |
creator.write_shelf(shelf_file) |
|
|
0.15.23
by Aaron Bentley
Use correct tree for desrializing transform |
288 |
creator.transform() |
289 |
self.build_tree_contents([('tree/foo', 'z\na\nb\nc\n')]) |
|
|
0.12.57
by Aaron Bentley
Update for new Shelf API |
290 |
shelf_file.seek(0) |
291 |
unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file) |
|
|
0.15.31
by Aaron Bentley
Remove 'unshelve' method, test make_merger |
292 |
unshelver.make_merger().do_merge() |
|
0.15.23
by Aaron Bentley
Use correct tree for desrializing transform |
293 |
self.assertFileEqual('z\na\nb\nd\n', 'tree/foo') |
294 |
||
|
0.12.26
by Aaron Bentley
Use correct base for shelving |
295 |
def test_unshelve_base(self): |
296 |
tree = self.make_branch_and_tree('tree') |
|
297 |
tree.lock_write() |
|
298 |
self.addCleanup(tree.unlock) |
|
299 |
tree.commit('rev1', rev_id='rev1') |
|
|
0.15.5
by Aaron Bentley
Rename to shelf |
300 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
0.12.59
by Aaron Bentley
Fix locking bugs in tests |
301 |
self.addCleanup(creator.finalize) |
|
0.12.42
by Aaron Bentley
Get shelf from tree |
302 |
manager = tree.get_shelf_manager() |
|
0.12.29
by Aaron Bentley
Update failing tests |
303 |
shelf_id, shelf_file = manager.new_shelf() |
304 |
try: |
|
|
0.12.61
by Aaron Bentley
Stop assigning result of write_shelf |
305 |
creator.write_shelf(shelf_file) |
|
0.12.29
by Aaron Bentley
Update failing tests |
306 |
finally: |
307 |
shelf_file.close() |
|
|
0.12.26
by Aaron Bentley
Use correct base for shelving |
308 |
tree.commit('rev2', rev_id='rev2') |
|
0.12.29
by Aaron Bentley
Update failing tests |
309 |
shelf_file = manager.read_shelf(1) |
|
0.12.59
by Aaron Bentley
Fix locking bugs in tests |
310 |
self.addCleanup(shelf_file.close) |
311 |
unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file) |
|
312 |
self.addCleanup(unshelver.finalize) |
|
|
0.12.26
by Aaron Bentley
Use correct base for shelving |
313 |
self.assertEqual('rev1', unshelver.base_tree.get_revision_id()) |
|
0.12.27
by Aaron Bentley
Implement shelf manager |
314 |
|
315 |
||
316 |
class TestShelfManager(tests.TestCaseWithTransport): |
|
317 |
||
|
0.12.42
by Aaron Bentley
Get shelf from tree |
318 |
def test_get_shelf_manager(self): |
|
0.12.27
by Aaron Bentley
Implement shelf manager |
319 |
tree = self.make_branch_and_tree('.') |
|
0.12.42
by Aaron Bentley
Get shelf from tree |
320 |
manager = tree.get_shelf_manager() |
|
0.12.41
by Aaron Bentley
Change shelf to use WT control dir for shelves |
321 |
self.assertEqual(tree._transport.base + 'shelf/', |
|
0.12.27
by Aaron Bentley
Implement shelf manager |
322 |
manager.transport.base) |
323 |
||
324 |
def get_manager(self): |
|
|
0.12.42
by Aaron Bentley
Get shelf from tree |
325 |
return self.make_branch_and_tree('.').get_shelf_manager() |
|
0.12.27
by Aaron Bentley
Implement shelf manager |
326 |
|
327 |
def test_new_shelf(self): |
|
328 |
manager = self.get_manager() |
|
329 |
shelf_id, shelf_file = manager.new_shelf() |
|
330 |
shelf_file.close() |
|
331 |
self.assertEqual(1, shelf_id) |
|
332 |
shelf_id, shelf_file = manager.new_shelf() |
|
333 |
shelf_file.close() |
|
334 |
self.assertEqual(2, shelf_id) |
|
335 |
manager.delete_shelf(1) |
|
336 |
shelf_id, shelf_file = manager.new_shelf() |
|
337 |
shelf_file.close() |
|
338 |
self.assertEqual(3, shelf_id) |
|
339 |
||
340 |
def test_active_shelves(self): |
|
341 |
manager = self.get_manager() |
|
342 |
self.assertEqual([], manager.active_shelves()) |
|
343 |
shelf_id, shelf_file = manager.new_shelf() |
|
344 |
shelf_file.close() |
|
345 |
self.assertEqual([1], manager.active_shelves()) |
|
346 |
||
347 |
def test_delete_shelf(self): |
|
348 |
manager = self.get_manager() |
|
349 |
shelf_id, shelf_file = manager.new_shelf() |
|
350 |
shelf_file.close() |
|
351 |
self.assertEqual([1], manager.active_shelves()) |
|
352 |
manager.delete_shelf(1) |
|
353 |
self.assertEqual([], manager.active_shelves()) |
|
354 |
||
355 |
def test_last_shelf(self): |
|
356 |
manager = self.get_manager() |
|
357 |
self.assertIs(None, manager.last_shelf()) |
|
358 |
shelf_id, shelf_file = manager.new_shelf() |
|
359 |
shelf_file.close() |
|
360 |
self.assertEqual(1, manager.last_shelf()) |
|
361 |
||
362 |
def test_read_shelf(self): |
|
363 |
manager = self.get_manager() |
|
364 |
shelf_id, shelf_file = manager.new_shelf() |
|
365 |
try: |
|
366 |
shelf_file.write('foo') |
|
367 |
finally: |
|
368 |
shelf_file.close() |
|
369 |
shelf_id, shelf_file = manager.new_shelf() |
|
370 |
try: |
|
371 |
shelf_file.write('bar') |
|
372 |
finally: |
|
373 |
shelf_file.close() |
|
374 |
shelf_file = manager.read_shelf(1) |
|
375 |
try: |
|
376 |
self.assertEqual('foo', shelf_file.read()) |
|
377 |
finally: |
|
378 |
shelf_file.close() |
|
379 |
shelf_file = manager.read_shelf(2) |
|
380 |
try: |
|
381 |
self.assertEqual('bar', shelf_file.read()) |
|
382 |
finally: |
|
383 |
shelf_file.close() |
|
|
0.12.43
by Aaron Bentley
Make ShelfManager consume ShelfCreator and produce Unshelver |
384 |
|
|
0.12.50
by Aaron Bentley
Improve error handling for non-existant shelf-ids |
385 |
def test_read_non_existant(self): |
386 |
manager = self.get_manager() |
|
|
0.12.68
by Aaron Bentley
Update docs, move items to proper files. |
387 |
e = self.assertRaises(errors.NoSuchShelfId, manager.read_shelf, 1) |
|
0.12.50
by Aaron Bentley
Improve error handling for non-existant shelf-ids |
388 |
self.assertEqual('No changes are shelved with id "1".', str(e)) |
389 |
||
|
0.12.43
by Aaron Bentley
Make ShelfManager consume ShelfCreator and produce Unshelver |
390 |
def test_shelve_changes(self): |
391 |
tree = self.make_branch_and_tree('tree') |
|
|
0.12.44
by Aaron Bentley
Give manager responsibility for applying transform |
392 |
tree.commit('no-change commit') |
393 |
tree.lock_write() |
|
394 |
self.addCleanup(tree.unlock) |
|
395 |
self.build_tree_contents([('tree/foo', 'bar')]) |
|
396 |
self.assertFileEqual('bar', 'tree/foo') |
|
|
0.12.43
by Aaron Bentley
Make ShelfManager consume ShelfCreator and produce Unshelver |
397 |
tree.add('foo', 'foo-id') |
398 |
creator = shelf.ShelfCreator(tree, tree.basis_tree()) |
|
399 |
self.addCleanup(creator.finalize) |
|
|
0.12.74
by Aaron Bentley
Update to use iter_shelvable |
400 |
list(creator.iter_shelvable()) |
|
0.12.43
by Aaron Bentley
Make ShelfManager consume ShelfCreator and produce Unshelver |
401 |
creator.shelve_creation('foo-id') |
402 |
shelf_manager = tree.get_shelf_manager() |
|
403 |
shelf_id = shelf_manager.shelve_changes(creator) |
|
|
0.12.44
by Aaron Bentley
Give manager responsibility for applying transform |
404 |
self.failIfExists('tree/foo') |
|
0.12.43
by Aaron Bentley
Make ShelfManager consume ShelfCreator and produce Unshelver |
405 |
unshelver = shelf_manager.get_unshelver(shelf_id) |
|
0.12.67
by Aaron Bentley
Update for new Unshelver API |
406 |
unshelver.make_merger().do_merge() |
|
0.12.44
by Aaron Bentley
Give manager responsibility for applying transform |
407 |
self.assertFileEqual('bar', 'tree/foo') |