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