OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2012 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 """Applies an issue from Rietveld. | 6 """Applies an issue from Rietveld. |
7 """ | 7 """ |
8 | 8 |
9 import getpass | 9 import getpass |
10 import json | 10 import json |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 default='http://codereview.chromium.org', | 78 default='http://codereview.chromium.org', |
79 help='Rietveld server') | 79 help='Rietveld server') |
80 parser.add_option('--no-auth', action='store_true', | 80 parser.add_option('--no-auth', action='store_true', |
81 help='Do not attempt authenticated requests.') | 81 help='Do not attempt authenticated requests.') |
82 parser.add_option('--revision-mapping', default='{}', | 82 parser.add_option('--revision-mapping', default='{}', |
83 help='When running gclient, annotate the got_revisions ' | 83 help='When running gclient, annotate the got_revisions ' |
84 'using the revision-mapping.') | 84 'using the revision-mapping.') |
85 parser.add_option('-f', '--force', action='store_true', | 85 parser.add_option('-f', '--force', action='store_true', |
86 help='Really run apply_issue, even if .update.flag ' | 86 help='Really run apply_issue, even if .update.flag ' |
87 'is detected.') | 87 'is detected.') |
88 parser.add_option('-b', '--base_ref', help='Base git ref to patch on top of, ' | 88 parser.add_option('-b', '--base_ref', help='DEPRECATED do not use.') |
89 'used for verification.') | |
90 parser.add_option('--whitelist', action='append', default=[], | 89 parser.add_option('--whitelist', action='append', default=[], |
91 help='Patch only specified file(s).') | 90 help='Patch only specified file(s).') |
92 parser.add_option('--blacklist', action='append', default=[], | 91 parser.add_option('--blacklist', action='append', default=[], |
93 help='Don\'t patch specified file(s).') | 92 help='Don\'t patch specified file(s).') |
94 parser.add_option('-d', '--ignore_deps', action='store_true', | 93 parser.add_option('-d', '--ignore_deps', action='store_true', |
95 help='Don\'t run gclient sync on DEPS changes.') | 94 help='Don\'t run gclient sync on DEPS changes.') |
96 options, args = parser.parse_args() | 95 options, args = parser.parse_args() |
97 | 96 |
98 if options.whitelist and options.blacklist: | 97 if options.whitelist and options.blacklist: |
99 parser.error('Cannot specify both --whitelist and --blacklist') | 98 parser.error('Cannot specify both --whitelist and --blacklist') |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 if options.blacklist: | 197 if options.blacklist: |
199 patchset.patches = [patch for patch in patchset.patches | 198 patchset.patches = [patch for patch in patchset.patches |
200 if patch.filename not in options.blacklist] | 199 if patch.filename not in options.blacklist] |
201 for patch in patchset.patches: | 200 for patch in patchset.patches: |
202 print(patch) | 201 print(patch) |
203 full_dir = os.path.abspath(options.root_dir) | 202 full_dir = os.path.abspath(options.root_dir) |
204 scm_type = scm.determine_scm(full_dir) | 203 scm_type = scm.determine_scm(full_dir) |
205 if scm_type == 'svn': | 204 if scm_type == 'svn': |
206 scm_obj = checkout.SvnCheckout(full_dir, None, None, None, None) | 205 scm_obj = checkout.SvnCheckout(full_dir, None, None, None, None) |
207 elif scm_type == 'git': | 206 elif scm_type == 'git': |
208 scm_obj = checkout.GitCheckout(full_dir, None, None, None, None, | 207 scm_obj = checkout.GitCheckout(full_dir, None, None, None, None) |
209 base_ref=options.base_ref,) | |
210 elif scm_type == None: | 208 elif scm_type == None: |
211 scm_obj = checkout.RawCheckout(full_dir, None, None) | 209 scm_obj = checkout.RawCheckout(full_dir, None, None) |
212 else: | 210 else: |
213 parser.error('Couldn\'t determine the scm') | 211 parser.error('Couldn\'t determine the scm') |
214 | 212 |
215 # TODO(maruel): HACK, remove me. | 213 # TODO(maruel): HACK, remove me. |
216 # When run a build slave, make sure buildbot knows that the checkout was | 214 # When run a build slave, make sure buildbot knows that the checkout was |
217 # modified. | 215 # modified. |
218 if options.root_dir == 'src' and getpass.getuser() == 'chrome-bot': | 216 if options.root_dir == 'src' and getpass.getuser() == 'chrome-bot': |
219 # See sourcedirIsPatched() in: | 217 # See sourcedirIsPatched() in: |
220 # http://src.chromium.org/viewvc/chrome/trunk/tools/build/scripts/slave/ | 218 # http://src.chromium.org/viewvc/chrome/trunk/tools/build/scripts/slave/ |
221 # chromium_commands.py?view=markup | 219 # chromium_commands.py?view=markup |
222 open('.buildbot-patched', 'w').close() | 220 open('.buildbot-patched', 'w').close() |
223 | 221 |
224 print('\nApplying the patch.') | 222 print('\nApplying the patch.') |
225 try: | 223 try: |
226 scm_obj.apply_patch( | 224 scm_obj.apply_patch(patchset, verbose=True) |
227 patchset, verbose=True, | |
228 email=properties.get('owner_email', 'chrome-bot@chromium.org'), | |
229 name=properties.get('owner', 'chrome-bot')) | |
230 except checkout.PatchApplicationFailed, e: | 225 except checkout.PatchApplicationFailed, e: |
231 print(str(e)) | 226 print(str(e)) |
232 print('CWD=%s' % os.getcwd()) | 227 print('CWD=%s' % os.getcwd()) |
233 print('Checkout path=%s' % scm_obj.project_path) | 228 print('Checkout path=%s' % scm_obj.project_path) |
234 return 1 | 229 return 1 |
235 | 230 |
236 if ('DEPS' in map(os.path.basename, patchset.filenames) | 231 if ('DEPS' in map(os.path.basename, patchset.filenames) |
237 and not options.ignore_deps): | 232 and not options.ignore_deps): |
238 gclient_root = gclient_utils.FindGclientRoot(full_dir) | 233 gclient_root = gclient_utils.FindGclientRoot(full_dir) |
239 if gclient_root and scm_type: | 234 if gclient_root and scm_type: |
(...skipping 21 matching lines...) Expand all Loading... |
261 f, options.revision_mapping) | 256 f, options.revision_mapping) |
262 annotated_gclient.emit_buildprops(revisions) | 257 annotated_gclient.emit_buildprops(revisions) |
263 | 258 |
264 return retcode | 259 return retcode |
265 return 0 | 260 return 0 |
266 | 261 |
267 | 262 |
268 if __name__ == "__main__": | 263 if __name__ == "__main__": |
269 fix_encoding.fix_encoding() | 264 fix_encoding.fix_encoding() |
270 sys.exit(main()) | 265 sys.exit(main()) |
OLD | NEW |