67
72
kind=(None, 'directory'))
68
73
self.assertReport('+ path/', versioned_change='added',
69
74
modified='unchanged', kind=(None, 'directory'))
75
self.assertReport('+ path', versioned_change='added',
76
modified='unchanged', kind=(None, None))
70
77
self.assertReport('+N path/', versioned_change='added',
71
78
modified='created', kind=(None, 'directory'))
72
79
self.assertReport('+M path/', versioned_change='added',
100
107
modified='unchanged',
101
108
exe_change=False):
102
109
reporter = InstrumentedReporter()
103
delta.report_changes([(file_id, path, content_change, versioned,
104
parent_id, name, kind, executable)], reporter)
110
_mod_delta.report_changes([(file_id, path, content_change, versioned,
111
parent_id, name, kind, executable)], reporter)
105
112
output = reporter.calls[0]
106
113
self.assertEqual(file_id, output[0])
107
114
self.assertEqual(path, output[1])
150
157
exe_change=True, versioned=(True, False),
151
158
content_change=True, name=('old', 'new'),
152
159
executable=(False, True))
162
class TestChangesFrom (tests.TestCaseWithTransport):
164
def show_string(self, delta, *args, **kwargs):
166
delta.show(to_file, *args, **kwargs)
167
return to_file.getvalue()
169
def test_kind_change(self):
170
"""Doing a status when a file has changed kind should work"""
171
tree = self.make_branch_and_tree('.')
172
self.build_tree(['filename'])
173
tree.add('filename', 'file-id')
174
tree.commit('added filename')
175
os.unlink('filename')
176
self.build_tree(['filename/'])
177
delta = tree.changes_from(tree.basis_tree())
178
self.assertEqual([('filename', 'file-id', 'file', 'directory')],
180
self.assertEqual([], delta.added)
181
self.assertEqual([], delta.removed)
182
self.assertEqual([], delta.renamed)
183
self.assertEqual([], delta.modified)
184
self.assertEqual([], delta.unchanged)
185
self.assertTrue(delta.has_changed())
186
self.assertTrue(delta.touches_file_id('file-id'))
187
self.assertEqual('kind changed:\n filename (file => directory)\n',
188
self.show_string(delta))
189
other_delta = _mod_delta.TreeDelta()
190
self.assertNotEqual(other_delta, delta)
191
other_delta.kind_changed = [('filename', 'file-id', 'file',
193
self.assertNotEqual(other_delta, delta)
194
other_delta.kind_changed = [('filename', 'file-id', 'file',
196
self.assertEqual(other_delta, delta)
197
self.assertEqualDiff("TreeDelta(added=[], removed=[], renamed=[],"
198
" kind_changed=[(u'filename', 'file-id', 'file', 'directory')],"
199
" modified=[], unchanged=[])", repr(delta))
200
self.assertEqual('K filename (file => directory) file-id\n',
201
self.show_string(delta, show_ids=True,
204
tree.rename_one('filename', 'dirname')
205
delta = tree.changes_from(tree.basis_tree())
206
self.assertEqual([], delta.kind_changed)
207
# This loses the fact that kind changed, remembering it as a
209
self.assertEqual([('filename', 'dirname', 'file-id', 'directory',
210
True, False)], delta.renamed)
211
self.assertTrue(delta.has_changed())
212
self.assertTrue(delta.touches_file_id('file-id'))