35
37
return next(tree.iter_entries_by_dir(specific_files=[path]))[1]
40
class TestSymlinkSupportFunction(per_tree.TestCaseWithTree):
42
def test_supports_symlinks(self):
43
self.tree = self.make_branch_and_tree('.')
44
self.assertIn(self.tree.supports_symlinks(), [True, False])
38
47
class TestTreeWithSymlinks(per_tree.TestCaseWithTree):
40
49
_test_needs_features = [features.SymlinkFeature]
65
74
entry = get_entry(self.tree, 'symlink')
66
75
self.assertEqual(entry.kind, 'symlink')
67
76
self.assertEqual(None, entry.text_size)
79
class TestTreeWithoutSymlinks(per_tree.TestCaseWithTree):
82
super(TestTreeWithoutSymlinks, self).setUp()
83
self.branch = self.make_branch('a')
84
mem_tree = self.branch.create_memorytree()
85
with mem_tree.lock_write():
86
mem_tree._file_transport.symlink('source', 'symlink')
87
mem_tree.add(['', 'symlink'])
88
rev1 = mem_tree.commit('rev1')
89
self.assertPathDoesNotExist('a/symlink')
91
def test_clone_skips_symlinks(self):
92
if isinstance(self.branch, (GitBranch,)):
93
# TODO(jelmer): Fix this test for git repositories
95
'git trees do not honor osutils.supports_symlinks yet')
96
self.overrideAttr(osutils, 'supports_symlinks', lambda p: False)
97
# This should not attempt to create any symlinks
98
result_dir = self.branch.controldir.sprout('b')
99
result_tree = result_dir.open_workingtree()
100
self.assertFalse(result_tree.supports_symlinks())
101
self.assertPathDoesNotExist('b/symlink')
102
# Even though 'symlink' does not exist, the tree does not have any delta
103
basis_tree = self.branch.basis_tree()
104
self.assertTrue(basis_tree.has_filename('symlink'))
105
with result_tree.lock_read():
108
list(result_tree.iter_changes(basis_tree)))