100
103
modified='unchanged',
101
104
exe_change=False):
102
105
reporter = InstrumentedReporter()
103
delta.report_changes([(file_id, path, content_change, versioned,
104
parent_id, name, kind, executable)], reporter)
106
_mod_delta.report_changes([(file_id, path, content_change, versioned,
107
parent_id, name, kind, executable)], reporter)
105
108
output = reporter.calls[0]
106
109
self.assertEqual(file_id, output[0])
107
110
self.assertEqual(path, output[1])
150
153
exe_change=True, versioned=(True, False),
151
154
content_change=True, name=('old', 'new'),
152
155
executable=(False, True))
158
class TestChangesFrom (tests.TestCaseWithTransport):
160
def show_string(self, delta, *args, **kwargs):
162
delta.show(to_file, *args, **kwargs)
163
return to_file.getvalue()
165
def test_kind_change(self):
166
"""Doing a status when a file has changed kind should work"""
167
tree = self.make_branch_and_tree('.')
168
self.build_tree(['filename'])
169
tree.add('filename', 'file-id')
170
tree.commit('added filename')
171
os.unlink('filename')
172
self.build_tree(['filename/'])
173
delta = tree.changes_from(tree.basis_tree())
174
self.assertEqual([('filename', 'file-id', 'file', 'directory')],
176
self.assertEqual([], delta.added)
177
self.assertEqual([], delta.removed)
178
self.assertEqual([], delta.renamed)
179
self.assertEqual([], delta.modified)
180
self.assertEqual([], delta.unchanged)
181
self.assertTrue(delta.has_changed())
182
self.assertTrue(delta.touches_file_id('file-id'))
183
self.assertEqual('kind changed:\n filename (file => directory)\n',
184
self.show_string(delta))
185
other_delta = _mod_delta.TreeDelta()
186
self.assertNotEqual(other_delta, delta)
187
other_delta.kind_changed = [('filename', 'file-id', 'file',
189
self.assertNotEqual(other_delta, delta)
190
other_delta.kind_changed = [('filename', 'file-id', 'file',
192
self.assertEqual(other_delta, delta)
193
self.assertEqualDiff("TreeDelta(added=[], removed=[], renamed=[],"
194
" kind_changed=[(u'filename', 'file-id', 'file', 'directory')],"
195
" modified=[], unchanged=[])", repr(delta))
196
self.assertEqual('K filename (file => directory) file-id\n',
197
self.show_string(delta, show_ids=True,
200
tree.rename_one('filename', 'dirname')
201
delta = tree.changes_from(tree.basis_tree())
202
self.assertEqual([], delta.kind_changed)
203
# This loses the fact that kind changed, remembering it as a
205
self.assertEqual([('filename', 'dirname', 'file-id', 'directory',
206
True, False)], delta.renamed)
207
self.assertTrue(delta.has_changed())
208
self.assertTrue(delta.touches_file_id('file-id'))