525
525
resolve_conflicts(replace)
528
def test_symlinks(self):
528
def _test_symlinks(self, link_name1,link_target1,
529
link_name2, link_target2):
531
def ozpath(p): return 'oz/' + p
529
533
self.requireFeature(SymlinkFeature)
530
transform,root = self.get_transform()
534
transform, root = self.get_transform()
531
535
oz_id = transform.new_directory('oz', root, 'oz-id')
532
wizard = transform.new_symlink('wizard', oz_id, 'wizard-target',
536
wizard = transform.new_symlink(link_name1, oz_id, link_target1,
534
wiz_id = transform.create_path('wizard2', oz_id)
535
transform.create_symlink('behind_curtain', wiz_id)
538
wiz_id = transform.create_path(link_name2, oz_id)
539
transform.create_symlink(link_target2, wiz_id)
536
540
transform.version_file('wiz-id2', wiz_id)
537
541
transform.set_executability(True, wiz_id)
538
542
self.assertEqual(transform.find_conflicts(),
539
543
[('non-file executability', wiz_id)])
540
544
transform.set_executability(None, wiz_id)
541
545
transform.apply()
542
self.assertEqual(self.wt.path2id('oz/wizard'), 'wizard-id')
543
self.assertEqual(file_kind(self.wt.abspath('oz/wizard')), 'symlink')
544
self.assertEqual(os.readlink(self.wt.abspath('oz/wizard2')),
546
self.assertEqual(os.readlink(self.wt.abspath('oz/wizard')),
546
self.assertEqual(self.wt.path2id(ozpath(link_name1)), 'wizard-id')
547
self.assertEqual('symlink',
548
file_kind(self.wt.abspath(ozpath(link_name1))))
549
self.assertEqual(link_target2,
550
osutils.readlink(self.wt.abspath(ozpath(link_name2))))
551
self.assertEqual(link_target1,
552
osutils.readlink(self.wt.abspath(ozpath(link_name1))))
554
def test_symlinks(self):
555
self._test_symlinks('wizard', 'wizard-target',
556
'wizard2', 'behind_curtain')
558
def test_symlinks_unicode(self):
559
self.requireFeature(tests.UnicodeFilenameFeature)
560
self._test_symlinks(u'\N{Euro Sign}wizard',
561
u'wizard-targ\N{Euro Sign}t',
562
u'\N{Euro Sign}wizard2',
563
u'b\N{Euro Sign}hind_curtain')
549
565
def test_unable_create_symlink(self):
1841
1857
self.assertTrue(source.is_executable('file1-id'))
1843
1859
def test_case_insensitive_build_tree_inventory(self):
1844
if (not tests.CaseInsensitiveFilesystemFeature.available()
1845
or not tests.CaseInsCasePresFilenameFeature.available()):
1860
if (tests.CaseInsensitiveFilesystemFeature.available()
1861
or tests.CaseInsCasePresFilenameFeature.available()):
1846
1862
raise tests.UnavailableFeature('Fully case sensitive filesystem')
1847
1863
source = self.make_branch_and_tree('source')
1848
1864
self.build_tree(['source/file', 'source/FILE'])
2688
2704
self.assertSerializesTo(self.symlink_creation_records(), tt)
2690
2706
def test_deserialize_symlink_creation(self):
2707
self.requireFeature(tests.SymlinkFeature)
2691
2708
tt = self.get_preview()
2692
2709
tt.deserialize(iter(self.symlink_creation_records()))
2693
# XXX readlink should be returning unicode, not utf-8
2694
foo_content = os.readlink(tt._limbo_name('new-1')).decode('utf-8')
2710
abspath = tt._limbo_name('new-1')
2711
foo_content = osutils.readlink(abspath)
2695
2712
self.assertEqual(u'bar\u1234', foo_content)
2697
2714
def make_destruction_preview(self):