Chromium Code Reviews| 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 class FileChangeInfo(object): | 5 class FileChangeInfo(object): |
| 6 """Represents a file change (add/delete/modify/rename/copy/etc).""" | 6 """Represents a file change (add/delete/modify/rename/copy/etc).""" |
| 7 def __init__(self, change_type, old_path, new_path): | 7 def __init__(self, change_type, old_path, new_path): |
| 8 self.change_type = change_type | 8 self.change_type = change_type |
| 9 self.old_path = old_path | 9 self.old_path = old_path |
| 10 self.new_path = new_path | 10 self.new_path = new_path |
| 11 | 11 |
| 12 def ToDict(self): | 12 def ToDict(self): |
| 13 return { | 13 return { |
| 14 'change_type': self.change_type, | 14 'change_type': self.change_type, |
| 15 'old_path': self.old_path, | 15 'old_path': self.old_path, |
| 16 'new_path': self.new_path | 16 'new_path': self.new_path |
| 17 } | 17 } |
| 18 | 18 |
| 19 @staticmethod | 19 @staticmethod |
| 20 def FromDict(info): | 20 def FromDict(info): |
| 21 return FileChangeInfo( | 21 return FileChangeInfo( |
| 22 info['change_type'], info['old_path'], info['new_path']) | 22 info['change_type'], info['old_path'], info['new_path']) |
| 23 | 23 |
| 24 | 24 |
| 25 # TODO(wrengr); convert this into a namedtuple. | |
|
stgao
2016/11/02 01:28:27
I like this idea. Maybe do the same for FileChange
wrengr
2016/11/02 23:52:26
I filed a bug: http://crbug.com/661822. Feel free
stgao
2016/11/03 04:48:10
Thanks!
| |
| 25 class ChangeLog(object): | 26 class ChangeLog(object): |
| 26 """Represents the change log of a revision.""" | 27 """Represents the change log of a revision.""" |
| 27 | 28 |
| 28 def __init__(self, author_name, author_email, author_time, committer_name, | 29 def __init__(self, author_name, author_email, author_time, committer_name, |
| 29 committer_email, committer_time, revision, commit_position, | 30 committer_email, committer_time, revision, commit_position, |
| 30 message, touched_files, commit_url, code_review_url=None, | 31 message, touched_files, commit_url, code_review_url=None, |
| 31 reverted_revision=None): | 32 reverted_revision=None): |
| 32 self.author_name = author_name | 33 self.author_name = author_name |
| 33 self.author_email = author_email | 34 self.author_email = author_email |
| 34 self.author_time = author_time | 35 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']: | 72 for touched_file_info in info['touched_files']: |
| 72 touched_files.append(FileChangeInfo.FromDict(touched_file_info)) | 73 touched_files.append(FileChangeInfo.FromDict(touched_file_info)) |
| 73 | 74 |
| 74 return ChangeLog( | 75 return ChangeLog( |
| 75 info['author_name'], info['author_email'], info['author_time'], | 76 info['author_name'], info['author_email'], info['author_time'], |
| 76 info['committer_name'], info['committer_email'], info['committer_time'], | 77 info['committer_name'], info['committer_email'], info['committer_time'], |
| 77 info['revision'], info['commit_position'], info['message'], | 78 info['revision'], info['commit_position'], info['message'], |
| 78 touched_files, info['commit_url'], info['code_review_url'], | 79 touched_files, info['commit_url'], info['code_review_url'], |
| 79 info['reverted_revision'] | 80 info['reverted_revision'] |
| 80 ) | 81 ) |
| OLD | NEW |