OLD | NEW |
| (Empty) |
1 # Copyright (c) 2010 Google Inc. All rights reserved. | |
2 # | |
3 # Redistribution and use in source and binary forms, with or without | |
4 # modification, are permitted provided that the following conditions are | |
5 # met: | |
6 # | |
7 # * Redistributions of source code must retain the above copyright | |
8 # notice, this list of conditions and the following disclaimer. | |
9 # * Redistributions in binary form must reproduce the above | |
10 # copyright notice, this list of conditions and the following disclaimer | |
11 # in the documentation and/or other materials provided with the | |
12 # distribution. | |
13 # * Neither the name of Google Inc. nor the names of its | |
14 # contributors may be used to endorse or promote products derived from | |
15 # this software without specific prior written permission. | |
16 # | |
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
19 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
20 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
21 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
22 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
23 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
28 # | |
29 # WebKit's python module for holding information on a commit | |
30 | |
31 from webkitpy.common.config import urls | |
32 from webkitpy.common.config.committers import CommitterList | |
33 | |
34 | |
35 class CommitInfo(object): | |
36 def __init__(self, revision, committer_email, changelog_data, committer_list
=CommitterList()): | |
37 self._revision = revision | |
38 self._committer_email = committer_email | |
39 self._changelog_data = changelog_data | |
40 | |
41 # Derived values: | |
42 self._committer = committer_list.committer_by_email(committer_email) | |
43 | |
44 def revision(self): | |
45 return self._revision | |
46 | |
47 def committer(self): | |
48 return self._committer # None if committer isn't in committers.py | |
49 | |
50 def committer_email(self): | |
51 return self._committer_email | |
52 | |
53 def bug_id(self): | |
54 return self._changelog_data["bug_id"] # May be None | |
55 | |
56 def author(self): | |
57 return self._changelog_data["author"] # May be None | |
58 | |
59 def author_name(self): | |
60 return self._changelog_data["author_name"] | |
61 | |
62 def author_email(self): | |
63 return self._changelog_data["author_email"] | |
64 | |
65 def reviewer(self): | |
66 return self._changelog_data["reviewer"] # May be None | |
67 | |
68 def reviewer_text(self): | |
69 return self._changelog_data["reviewer_text"] # May be None | |
70 | |
71 def changed_files(self): | |
72 return self._changelog_data["changed_files"] | |
73 | |
74 def to_json(self): | |
75 return { | |
76 "bug_id": self.bug_id(), | |
77 "author_name": self.author_name(), | |
78 "author_email": self.author_email(), | |
79 "reviewer_text": self.reviewer_text(), | |
80 "changed_files": self.changed_files(), | |
81 } | |
82 | |
83 def responsible_parties(self): | |
84 responsible_parties = [ | |
85 self.committer(), | |
86 self.author(), | |
87 self.reviewer(), | |
88 ] | |
89 return set([party for party in responsible_parties if party]) # Filter o
ut None | |
90 | |
91 # FIXME: It is slightly lame that this "view" method is on this "model" clas
s (in MVC terms) | |
92 def blame_string(self, bugs): | |
93 string = "r%s:\n" % self.revision() | |
94 string += " %s\n" % urls.view_revision_url(self.revision()) | |
95 string += " Bug: %s (%s)\n" % (self.bug_id(), bugs.bug_url_for_bug_id(s
elf.bug_id())) | |
96 author_line = "\"%s\" <%s>" % (self.author_name(), self.author_email()) | |
97 string += " Author: %s\n" % (self.author() or author_line) | |
98 string += " Reviewer: %s\n" % (self.reviewer() or self.reviewer_text()) | |
99 string += " Committer: %s" % self.committer() | |
100 return string | |
OLD | NEW |