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