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