23
23
from bzrlib.diff import internal_diff
24
24
from bzrlib.mutabletree import MutableTree
25
from bzrlib.osutils import (
25
from bzrlib.osutils import has_symlinks
28
26
from bzrlib.symbol_versioning import zero_ninetyone
29
from bzrlib.tests import TestSkipped
27
from bzrlib.tests import SymlinkFeature, TestSkipped
30
28
from bzrlib.tests.tree_implementations import TestCaseWithTree
31
29
from bzrlib.uncommit import uncommit
37
35
super(TestEntryDiffing, self).setUp()
38
36
self.wt = self.make_branch_and_tree('.')
39
37
self.branch = self.wt.branch
40
print >> open('file', 'wb'), 'foo'
41
print >> open('binfile', 'wb'), 'foo'
38
open('file', 'wb').write('foo\n')
39
open('binfile', 'wb').write('foo\n')
42
40
self.wt.add(['file'], ['fileid'])
43
41
self.wt.add(['binfile'], ['binfileid'])
45
43
os.symlink('target1', 'symlink')
46
44
self.wt.add(['symlink'], ['linkid'])
47
45
self.wt.commit('message_1', rev_id = '1')
48
print >> open('file', 'wb'), 'bar'
49
print >> open('binfile', 'wb'), 'x' * 1023 + '\x00'
46
open('file', 'wb').write('bar\n')
47
open('binfile', 'wb').write('x' * 1023 + '\x00\n')
51
49
os.unlink('symlink')
52
50
os.symlink('target2', 'symlink')
110
108
self.assertEqual(output.getvalue(),
111
109
"Binary files /dev/null and new_label differ\n")
112
111
def test_link_diff_deleted(self):
113
if not has_symlinks():
112
self.requireFeature(SymlinkFeature)
115
113
output = StringIO()
116
114
self.link_1.diff(internal_diff,
117
115
"old_label", self.tree_1,
121
119
"=== target was 'target1'\n")
123
121
def test_link_diff_added(self):
124
if not has_symlinks():
122
self.requireFeature(SymlinkFeature)
126
123
output = StringIO()
127
124
self.link_1.diff(internal_diff,
128
125
"new_label", self.tree_1,
132
129
"=== target is 'target1'\n")
134
131
def test_link_diff_changed(self):
135
if not has_symlinks():
132
self.requireFeature(SymlinkFeature)
137
133
output = StringIO()
138
134
self.link_1.diff(internal_diff,
139
135
"/dev/null", self.tree_1,
222
218
self.inv = self.tree.inventory
224
220
def test_symlink_target(self):
225
if not has_symlinks():
226
raise TestSkipped('No symlink support')
221
self.requireFeature(SymlinkFeature)
228
223
if isinstance(self.tree, MutableTree):
229
224
raise TestSkipped(
232
227
self.assertEqual(entry.symlink_target, 'link-target')
234
229
def test_symlink(self):
235
if not has_symlinks():
236
raise TestSkipped('No symlink support')
230
self.requireFeature(SymlinkFeature)
238
232
entry = self.inv[self.inv.path2id('symlink')]
239
233
self.assertEqual(entry.kind, 'symlink')