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

Side by Side Diff: presubmit_support.py

Issue 6646040: suppress messages for PresubmitAddText results (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 9 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
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Enables directory-specific presubmit checks to run at upload and/or commit. 6 """Enables directory-specific presubmit checks to run at upload and/or commit.
7 """ 7 """
8 8
9 __version__ = '1.3.5' 9 __version__ = '1.3.5'
10 10
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 def IsFatal(self): 147 def IsFatal(self):
148 """An error that is fatal stops g4 mail/submit immediately, i.e. before 148 """An error that is fatal stops g4 mail/submit immediately, i.e. before
149 other presubmit scripts are run. 149 other presubmit scripts are run.
150 """ 150 """
151 return False 151 return False
152 152
153 def ShouldPrompt(self): 153 def ShouldPrompt(self):
154 """Whether this presubmit result should result in a prompt warning.""" 154 """Whether this presubmit result should result in a prompt warning."""
155 return False 155 return False
156 156
157 def IsMessage(self):
M-A Ruel 2011/03/10 13:41:44 I'm wondering; this should have all been properti
158 """Whether this result contains anything needing to be displayed."""
159 return True
160
157 class PresubmitAddText(PresubmitResult): 161 class PresubmitAddText(PresubmitResult):
158 """Propagates a line of text back to the caller.""" 162 """Propagates a line of text back to the caller."""
159 def __init__(self, message, items=None, long_text=''): 163 def __init__(self, message, items=None, long_text=''):
160 super(OutputApi.PresubmitAddText, self).__init__("ADD: " + message, 164 super(OutputApi.PresubmitAddText, self).__init__("ADD: " + message,
161 items, long_text) 165 items, long_text)
162 166
167 def IsMessage(self):
168 return False
169
163 class PresubmitError(PresubmitResult): 170 class PresubmitError(PresubmitResult):
164 """A hard presubmit error.""" 171 """A hard presubmit error."""
165 def IsFatal(self): 172 def IsFatal(self):
166 return True 173 return True
167 174
168 class PresubmitPromptWarning(PresubmitResult): 175 class PresubmitPromptWarning(PresubmitResult):
169 """An warning that prompts the user if they want to continue.""" 176 """An warning that prompts the user if they want to continue."""
170 def ShouldPrompt(self): 177 def ShouldPrompt(self):
171 return True 178 return True
172 179
(...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 else: 1056 else:
1050 errors.append(result) 1057 errors.append(result)
1051 1058
1052 error_count = 0 1059 error_count = 0
1053 for name, items in (('Messages', notifications), 1060 for name, items in (('Messages', notifications),
1054 ('Warnings', warnings), 1061 ('Warnings', warnings),
1055 ('ERRORS', errors)): 1062 ('ERRORS', errors)):
1056 if items: 1063 if items:
1057 output_stream.write('** Presubmit %s **\n' % name) 1064 output_stream.write('** Presubmit %s **\n' % name)
1058 for item in items: 1065 for item in items:
1066 if not item.IsMessage():
1067 continue
1068
1059 # Access to a protected member XXX of a client class 1069 # Access to a protected member XXX of a client class
1060 # pylint: disable=W0212 1070 # pylint: disable=W0212
1061 if not item._Handle(output_stream, input_stream, 1071 if not item._Handle(output_stream, input_stream,
1062 may_prompt=False): 1072 may_prompt=False):
1063 error_count += 1 1073 error_count += 1
1064 output_stream.write('\n') 1074 output_stream.write('\n')
1065 1075
1066 total_time = time.time() - start_time 1076 total_time = time.time() - start_time
1067 if total_time > 1.0: 1077 if total_time > 1.0:
1068 print "Presubmit checks took %.1fs to calculate." % total_time 1078 print "Presubmit checks took %.1fs to calculate." % total_time
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1174 options.commit, 1184 options.commit,
1175 options.verbose, 1185 options.verbose,
1176 sys.stdout, 1186 sys.stdout,
1177 sys.stdin, 1187 sys.stdin,
1178 options.default_presubmit, 1188 options.default_presubmit,
1179 options.may_prompt) 1189 options.may_prompt)
1180 1190
1181 1191
1182 if __name__ == '__main__': 1192 if __name__ == '__main__':
1183 sys.exit(Main(sys.argv)) 1193 sys.exit(Main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698