215
218
def _test_shelve_symlink_creation(self, link_name, link_target,
216
219
shelve_change=False):
217
self.requireFeature(tests.SymlinkFeature)
220
self.requireFeature(features.SymlinkFeature)
218
221
tree = self.make_branch_and_tree('.')
219
222
tree.lock_write()
220
223
self.addCleanup(tree.unlock)
241
244
self._test_shelve_symlink_creation('foo', 'bar')
243
246
def test_shelve_unicode_symlink_creation(self):
244
self.requireFeature(tests.UnicodeFilenameFeature)
247
self.requireFeature(features.UnicodeFilenameFeature)
245
248
self._test_shelve_symlink_creation(u'fo\N{Euro Sign}o',
246
249
u'b\N{Euro Sign}ar')
251
254
def _test_shelve_symlink_target_change(self, link_name,
252
255
old_target, new_target,
253
256
shelve_change=False):
254
self.requireFeature(tests.SymlinkFeature)
257
self.requireFeature(features.SymlinkFeature)
255
258
tree = self.make_branch_and_tree('.')
256
259
tree.lock_write()
257
260
self.addCleanup(tree.unlock)
282
285
self._test_shelve_symlink_target_change('foo', 'bar', 'baz')
284
287
def test_shelve_unicode_symlink_target_change(self):
285
self.requireFeature(tests.UnicodeFilenameFeature)
288
self.requireFeature(features.UnicodeFilenameFeature)
286
289
self._test_shelve_symlink_target_change(
287
290
u'fo\N{Euro Sign}o', u'b\N{Euro Sign}ar', u'b\N{Euro Sign}az')
330
333
return creator, tree
332
335
def check_shelve_deletion(self, tree):
333
self.assertTrue('foo-id' in tree)
334
self.assertTrue('bar-id' in tree)
336
self.assertTrue(tree.has_id('foo-id'))
337
self.assertTrue(tree.has_id('bar-id'))
335
338
self.assertFileEqual('baz', 'tree/foo/bar')
337
340
def test_shelve_deletion(self):
568
571
list(creator.iter_shelvable())
569
572
creator.shelve_deletion('foo-id')
570
573
creator.shelve_deletion('bar-id')
571
shelf_file = open('shelf', 'w+b')
572
self.addCleanup(shelf_file.close)
573
creator.write_shelf(shelf_file)
574
with open('shelf', 'w+b') as shelf_file:
575
creator.write_shelf(shelf_file)
576
578
# validate the test setup
577
self.assertTrue('foo-id' in tree)
578
self.assertTrue('bar-id' in tree)
579
self.assertTrue(tree.has_id('foo-id'))
580
self.assertTrue(tree.has_id('bar-id'))
579
581
self.assertFileEqual('baz', 'tree/foo/bar')
581
unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file)
582
self.addCleanup(unshelver.finalize)
583
unshelver.make_merger().do_merge()
584
self.assertFalse('foo-id' in tree)
585
self.assertFalse('bar-id' in tree)
582
with open('shelf', 'r+b') as shelf_file:
583
unshelver = shelf.Unshelver.from_tree_and_shelf(tree, shelf_file)
584
self.addCleanup(unshelver.finalize)
585
unshelver.make_merger().do_merge()
586
self.assertFalse(tree.has_id('foo-id'))
587
self.assertFalse(tree.has_id('bar-id'))
587
589
def test_unshelve_base(self):
588
590
tree = self.make_branch_and_tree('tree')