| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 # TODO(http://crbug.com/661822): convert this into a namedtuple. |
| 5 class FileChangeInfo(object): | 6 class FileChangeInfo(object): |
| 6 """Represents a file change (add/delete/modify/rename/copy/etc).""" | 7 """Represents a file change (add/delete/modify/rename/copy/etc).""" |
| 7 def __init__(self, change_type, old_path, new_path): | 8 def __init__(self, change_type, old_path, new_path): |
| 8 self.change_type = change_type | 9 self.change_type = change_type |
| 9 self.old_path = old_path | 10 self.old_path = old_path |
| 10 self.new_path = new_path | 11 self.new_path = new_path |
| 11 | 12 |
| 12 def ToDict(self): | 13 def ToDict(self): |
| 13 return { | 14 return { |
| 14 'change_type': self.change_type, | 15 'change_type': self.change_type, |
| 15 'old_path': self.old_path, | 16 'old_path': self.old_path, |
| 16 'new_path': self.new_path | 17 'new_path': self.new_path |
| 17 } | 18 } |
| 18 | 19 |
| 19 @staticmethod | 20 @staticmethod |
| 20 def FromDict(info): | 21 def FromDict(info): |
| 21 return FileChangeInfo( | 22 return FileChangeInfo( |
| 22 info['change_type'], info['old_path'], info['new_path']) | 23 info['change_type'], info['old_path'], info['new_path']) |
| 23 | 24 |
| 24 | 25 |
| 26 # TODO(http://crbug.com/661822): convert this into a namedtuple. |
| 25 class ChangeLog(object): | 27 class ChangeLog(object): |
| 26 """Represents the change log of a revision.""" | 28 """Represents the change log of a revision.""" |
| 27 | 29 |
| 28 def __init__(self, author_name, author_email, author_time, committer_name, | 30 def __init__(self, author_name, author_email, author_time, committer_name, |
| 29 committer_email, committer_time, revision, commit_position, | 31 committer_email, committer_time, revision, commit_position, |
| 30 message, touched_files, commit_url, code_review_url=None, | 32 message, touched_files, commit_url, code_review_url=None, |
| 31 reverted_revision=None): | 33 reverted_revision=None): |
| 32 self.author_name = author_name | 34 self.author_name = author_name |
| 33 self.author_email = author_email | 35 self.author_email = author_email |
| 34 self.author_time = author_time | 36 self.author_time = author_time |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 for touched_file_info in info['touched_files']: | 73 for touched_file_info in info['touched_files']: |
| 72 touched_files.append(FileChangeInfo.FromDict(touched_file_info)) | 74 touched_files.append(FileChangeInfo.FromDict(touched_file_info)) |
| 73 | 75 |
| 74 return ChangeLog( | 76 return ChangeLog( |
| 75 info['author_name'], info['author_email'], info['author_time'], | 77 info['author_name'], info['author_email'], info['author_time'], |
| 76 info['committer_name'], info['committer_email'], info['committer_time'], | 78 info['committer_name'], info['committer_email'], info['committer_time'], |
| 77 info['revision'], info['commit_position'], info['message'], | 79 info['revision'], info['commit_position'], info['message'], |
| 78 touched_files, info['commit_url'], info['code_review_url'], | 80 touched_files, info['commit_url'], info['code_review_url'], |
| 79 info['reverted_revision'] | 81 info['reverted_revision'] |
| 80 ) | 82 ) |
| OLD | NEW |