Exemplo n.º 1
0
    def testFileChangeinfoChangedPathProperty(self):
        """Test ``changed_file`` property of ``FileChangeInfo``."""
        modified_file = FileChangeInfo.Modify('a.cc')
        self.assertEqual(modified_file.changed_path, 'a.cc')

        added_file = FileChangeInfo.Modify('a.cc')
        self.assertEqual(added_file.changed_path, 'a.cc')

        copied_file = FileChangeInfo.Copy('old.cc', 'new.cc')
        self.assertEqual(copied_file.changed_path, 'new.cc')

        deleted_file = FileChangeInfo.Delete('old.cc')
        self.assertEqual(deleted_file.changed_path, 'old.cc')
Exemplo n.º 2
0
def GetFileChangeInfo(change_type, path1, path2):
    """Set old/new path and old/new mode."""
    change_type = change_type.lower()
    if change_type == ChangeType.MODIFY:
        return FileChangeInfo.Modify(path1)

    if change_type == ChangeType.ADD:
        return FileChangeInfo.Add(path1)

    if change_type == ChangeType.DELETE:
        return FileChangeInfo.Delete(path1)

    if change_type == ChangeType.RENAME:
        return FileChangeInfo.Rename(path1, path2)

    # TODO(http://crbug.com/659346): write coverage test for this branch
    if change_type.lower() == ChangeType.COPY:  # pragma: no cover
        return FileChangeInfo.Copy(path1, path2)

    return None