178
178
expected_added=[('b',)])
181
class TestCopy(TestCaseForGenericProcessor):
183
def file_command_iter(self, src_path, dest_path):
185
author = ['', 'bugs@a.com', time.time(), time.timezone]
186
committer = ['', 'elmer@a.com', time.time(), time.timezone]
188
yield commands.FileModifyCommand(src_path, 'file', False,
190
yield commands.CommitCommand('head', '1', author,
191
committer, "commit 1", None, [], files_one)
193
yield commands.FileCopyCommand(src_path, dest_path)
194
yield commands.CommitCommand('head', '2', author,
195
committer, "commit 2", ":1", [], files_two)
198
def assertContent(self, branch, tree, path, content):
199
file_id = tree.inventory.path2id(path)
201
self.addCleanup(branch.unlock)
202
self.assertEqual(tree.get_file_text(file_id), content)
204
def test_copy_file_in_root(self):
205
handler, branch = self.get_handler()
208
handler.process(self.file_command_iter(src_path, dest_path))
209
revtree1, revtree2 = self.assertChanges(branch, 1,
210
expected_added=[(dest_path,)])
211
self.assertContent(branch, revtree2, dest_path, "aaa")
212
self.assertEqual(revtree1.get_revision_id(),
213
revtree1.inventory.root.children['a'].revision)
214
self.assertEqual(revtree2.get_revision_id(),
215
revtree2.inventory.root.children['b'].revision)
217
def test_copy_file_in_subdir(self):
218
handler, branch = self.get_handler()
221
handler.process(self.file_command_iter(src_path, dest_path))
222
revtree1, revtree2 = self.assertChanges(branch, 1,
223
expected_added=[(dest_path,)])
224
self.assertContent(branch, revtree2, dest_path, "aaa")
226
def test_copy_file_to_new_dir(self):
227
handler, branch = self.get_handler()
230
handler.process(self.file_command_iter(src_path, dest_path))
231
revtree1, revtree2 = self.assertChanges(branch, 1,
232
expected_added=[('b',), (dest_path,)])
233
self.assertContent(branch, revtree2, dest_path, "aaa")
181
236
class TestFileKinds(TestCaseForGenericProcessor):
183
238
def get_command_iter(self, path, kind, content):