OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Top-level presubmit script for Chromium. | 5 """Top-level presubmit script for Chromium. |
6 | 6 |
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
8 for more details about the presubmit API built into depot_tools. | 8 for more details about the presubmit API built into depot_tools. |
9 """ | 9 """ |
10 | 10 |
(...skipping 1122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 add_rules.update([ | 1133 add_rules.update([ |
1134 rule[1:] for rule in rules | 1134 rule[1:] for rule in rules |
1135 if rule.startswith('+') or rule.startswith('!') | 1135 if rule.startswith('+') or rule.startswith('!') |
1136 ]) | 1136 ]) |
1137 return add_rules | 1137 return add_rules |
1138 | 1138 |
1139 | 1139 |
1140 def _ParseDeps(contents): | 1140 def _ParseDeps(contents): |
1141 """Simple helper for parsing DEPS files.""" | 1141 """Simple helper for parsing DEPS files.""" |
1142 # Stubs for handling special syntax in the root DEPS file. | 1142 # Stubs for handling special syntax in the root DEPS file. |
1143 def FromImpl(*_): | |
1144 pass # NOP function so "From" doesn't fail. | |
1145 | |
1146 def FileImpl(_): | |
1147 pass # NOP function so "File" doesn't fail. | |
1148 | |
1149 class _VarImpl: | 1143 class _VarImpl: |
1150 | 1144 |
1151 def __init__(self, local_scope): | 1145 def __init__(self, local_scope): |
1152 self._local_scope = local_scope | 1146 self._local_scope = local_scope |
1153 | 1147 |
1154 def Lookup(self, var_name): | 1148 def Lookup(self, var_name): |
1155 """Implements the Var syntax.""" | 1149 """Implements the Var syntax.""" |
1156 try: | 1150 try: |
1157 return self._local_scope['vars'][var_name] | 1151 return self._local_scope['vars'][var_name] |
1158 except KeyError: | 1152 except KeyError: |
1159 raise Exception('Var is not defined: %s' % var_name) | 1153 raise Exception('Var is not defined: %s' % var_name) |
1160 | 1154 |
1161 local_scope = {} | 1155 local_scope = {} |
1162 global_scope = { | 1156 global_scope = { |
1163 'File': FileImpl, | |
1164 'From': FromImpl, | |
1165 'Var': _VarImpl(local_scope).Lookup, | 1157 'Var': _VarImpl(local_scope).Lookup, |
1166 } | 1158 } |
1167 exec contents in global_scope, local_scope | 1159 exec contents in global_scope, local_scope |
1168 return local_scope | 1160 return local_scope |
1169 | 1161 |
1170 | 1162 |
1171 def _CalculateAddedDeps(os_path, old_contents, new_contents): | 1163 def _CalculateAddedDeps(os_path, old_contents, new_contents): |
1172 """Helper method for _CheckAddedDepsHaveTargetApprovals. Returns | 1164 """Helper method for _CheckAddedDepsHaveTargetApprovals. Returns |
1173 a set of DEPS entries that we should look up. | 1165 a set of DEPS entries that we should look up. |
1174 | 1166 |
(...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2472 output_api, | 2464 output_api, |
2473 json_url='http://chromium-status.appspot.com/current?format=json')) | 2465 json_url='http://chromium-status.appspot.com/current?format=json')) |
2474 | 2466 |
2475 results.extend( | 2467 results.extend( |
2476 input_api.canned_checks.CheckPatchFormatted(input_api, output_api)) | 2468 input_api.canned_checks.CheckPatchFormatted(input_api, output_api)) |
2477 results.extend(input_api.canned_checks.CheckChangeHasBugField( | 2469 results.extend(input_api.canned_checks.CheckChangeHasBugField( |
2478 input_api, output_api)) | 2470 input_api, output_api)) |
2479 results.extend(input_api.canned_checks.CheckChangeHasDescription( | 2471 results.extend(input_api.canned_checks.CheckChangeHasDescription( |
2480 input_api, output_api)) | 2472 input_api, output_api)) |
2481 return results | 2473 return results |
OLD | NEW |