158
159
os.rename('tree/foo', 'tree/baz')
159
160
RenameMap.guess_renames(tree)
160
161
self.assertEqual('baz/empty', tree.id2path('empty-id'))
163
def test_guess_renames_dry_run(self):
164
tree = self.make_branch_and_tree('tree')
166
self.addCleanup(tree.unlock)
167
self.build_tree(['tree/file'])
168
tree.add('file', 'file-id')
169
tree.commit('Added file')
170
os.rename('tree/file', 'tree/file2')
171
RenameMap.guess_renames(tree, dry_run=True)
172
self.assertEqual('file', tree.id2path('file-id'))
175
def captureNotes(cmd, *args, **kwargs):
177
def my_note(fmt, *args):
178
notes.append(fmt % args)
179
old_note = trace.note
182
result = cmd(*args, **kwargs)
184
trace.note = old_note
187
def test_guess_renames_output(self):
188
"""guess_renames emits output whether dry_run is True or False."""
189
tree = self.make_branch_and_tree('tree')
191
self.addCleanup(tree.unlock)
192
self.build_tree(['tree/file'])
193
tree.add('file', 'file-id')
194
tree.commit('Added file')
195
os.rename('tree/file', 'tree/file2')
196
notes = self.captureNotes(RenameMap.guess_renames, tree,
198
self.assertEqual('file => file2', ''.join(notes))
199
notes = self.captureNotes(RenameMap.guess_renames, tree,
201
self.assertEqual('file => file2', ''.join(notes))