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

Side by Side Diff: Tools/Scripts/webkitpy/common/net/bugzilla/attachment.py

Issue 17639006: Remove committer list, bugzilla, watchlist code and transitive closure of stuff. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: merge on top of thakis' change in r153020 Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2009 Google Inc. All rights reserved.
2 # Copyright (c) 2009 Apple Inc. All rights reserved.
3 # Copyright (c) 2010 Research In Motion Limited. All rights reserved.
4 #
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
7 # met:
8 #
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above
12 # copyright notice, this list of conditions and the following disclaimer
13 # in the documentation and/or other materials provided with the
14 # distribution.
15 # * Neither the name of Google Inc. nor the names of its
16 # contributors may be used to endorse or promote products derived from
17 # this software without specific prior written permission.
18 #
19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
31 import logging
32
33 from webkitpy.common.memoized import memoized
34
35 _log = logging.getLogger(__name__)
36
37
38 class Attachment(object):
39
40 rollout_preamble = "ROLLOUT of r"
41
42 def __init__(self, attachment_dictionary, bug):
43 self._attachment_dictionary = attachment_dictionary
44 self._bug = bug
45 # FIXME: These should be replaced with @memoized after updating mocks.
46 self._reviewer = None
47 self._committer = None
48
49 def _bugzilla(self):
50 return self._bug._bugzilla
51
52 def id(self):
53 return int(self._attachment_dictionary.get("id"))
54
55 @memoized
56 def attacher(self):
57 return self._bugzilla().committers.contributor_by_email(self.attacher_em ail())
58
59 def attacher_email(self):
60 return self._attachment_dictionary.get("attacher_email")
61
62 def bug(self):
63 return self._bug
64
65 def bug_id(self):
66 return int(self._attachment_dictionary.get("bug_id"))
67
68 def is_patch(self):
69 return not not self._attachment_dictionary.get("is_patch")
70
71 def is_obsolete(self):
72 return not not self._attachment_dictionary.get("is_obsolete")
73
74 def is_rollout(self):
75 return self.name().startswith(self.rollout_preamble)
76
77 def name(self):
78 return self._attachment_dictionary.get("name")
79
80 def attach_date(self):
81 return self._attachment_dictionary.get("attach_date")
82
83 def review(self):
84 return self._attachment_dictionary.get("review")
85
86 def commit_queue(self):
87 return self._attachment_dictionary.get("commit-queue")
88
89 def url(self):
90 # FIXME: This should just return
91 # self._bugzilla().attachment_url_for_id(self.id()). scm_unittest.py
92 # depends on the current behavior.
93 return self._attachment_dictionary.get("url")
94
95 def contents(self):
96 # FIXME: We shouldn't be grabbing at _bugzilla.
97 return self._bug._bugzilla.fetch_attachment_contents(self.id())
98
99 def _validate_flag_value(self, flag):
100 email = self._attachment_dictionary.get("%s_email" % flag)
101 if not email:
102 return None
103 # FIXME: This is not a robust way to call committer_by_email
104 committer = getattr(self._bugzilla().committers,
105 "%s_by_email" % flag)(email)
106 if committer:
107 return committer
108 _log.warning("Warning, attachment %s on bug %s has invalid %s (%s)" % (
109 self._attachment_dictionary['id'],
110 self._attachment_dictionary['bug_id'], flag, email))
111
112 # FIXME: These could use @memoized like attacher(), but unit tests would nee d updates.
113 def reviewer(self):
114 if not self._reviewer:
115 self._reviewer = self._validate_flag_value("reviewer")
116 return self._reviewer
117
118 def committer(self):
119 if not self._committer:
120 self._committer = self._validate_flag_value("committer")
121 return self._committer
OLDNEW
« no previous file with comments | « Tools/Scripts/webkitpy/common/net/bugzilla/__init__.py ('k') | Tools/Scripts/webkitpy/common/net/bugzilla/bug.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698