Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1332)

Side by Side Diff: appengine/findit/libs/gitiles/change_log.py

Issue 2657913002: [Predator] Add ``Project`` class and ``ClassifySuspect`` method to project and component classifier (Closed)
Patch Set: Fix nits. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 from collections import namedtuple 5 from collections import namedtuple
6 6
7 from libs.gitiles.diff import ChangeType 7 from libs.gitiles.diff import ChangeType
8 8
9 9
10 # TODO(wrengr): it'd be better to have a class hierarchy here, so we can 10 # TODO(wrengr): it'd be better to have a class hierarchy here, so we can
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 def FromDict(cls, info): 43 def FromDict(cls, info):
44 return cls(info['change_type'].lower(), info['old_path'], info['new_path']) 44 return cls(info['change_type'].lower(), info['old_path'], info['new_path'])
45 45
46 def ToDict(self): 46 def ToDict(self):
47 return { 47 return {
48 'change_type': self.change_type, 48 'change_type': self.change_type,
49 'old_path': self.old_path, 49 'old_path': self.old_path,
50 'new_path': self.new_path 50 'new_path': self.new_path
51 } 51 }
52 52
53 @property
54 def changed_path(self):
55 """Returns the changed path to check when analyzing component or project.
56
57 Except for delete change type, the changed path means the new path after
58 change, for delete type, it is the old path.
59 """
60 # TODO(crbug.com/685884): use component of new path as default. RENAME might
61 # need to return two (old path new path may have different components)
62 if self.change_type == ChangeType.DELETE:
63 return self.old_path
64
65 return self.new_path
66
53 67
54 class Contributor(namedtuple('Contributor', ['name', 'email', 'time'])): 68 class Contributor(namedtuple('Contributor', ['name', 'email', 'time'])):
55 """A generalization of the "author" and "committer" in Git's terminology.""" 69 """A generalization of the "author" and "committer" in Git's terminology."""
56 __slots__ = () 70 __slots__ = ()
57 71
58 72
59 class ChangeLog(namedtuple('ChangeLog', 73 class ChangeLog(namedtuple('ChangeLog',
60 ['author', 'committer', 'revision', 'commit_position', 'message', 74 ['author', 'committer', 'revision', 'commit_position', 'message',
61 'touched_files', 'commit_url', 'code_review_url', 'reverted_revision'])): 75 'touched_files', 'commit_url', 'code_review_url', 'reverted_revision'])):
62 """Represents the change log of a revision.""" 76 """Represents the change log of a revision."""
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 122
109 return ChangeLog( 123 return ChangeLog(
110 Contributor(info['author']['name'], info['author']['email'], 124 Contributor(info['author']['name'], info['author']['email'],
111 info['author']['time']), 125 info['author']['time']),
112 Contributor(info['committer']['name'], info['committer']['email'], 126 Contributor(info['committer']['name'], info['committer']['email'],
113 info['committer']['time']), 127 info['committer']['time']),
114 info['revision'], info['commit_position'], info['message'], 128 info['revision'], info['commit_position'], info['message'],
115 touched_files, info['commit_url'], info['code_review_url'], 129 touched_files, info['commit_url'], info['code_review_url'],
116 info['reverted_revision'] 130 info['reverted_revision']
117 ) 131 )
OLDNEW
« no previous file with comments | « appengine/findit/handlers/crash/test/crash_config_test.py ('k') | appengine/findit/libs/gitiles/test/change_log_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698