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

Side by Side Diff: apply_issue.py

Issue 264823003: Add black/whitelisting to apply_issue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Updated assert message Created 6 years, 7 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 | checkout.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/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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
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='Base git ref to patch on top of, '
89 'used for verification.') 89 'used for verification.')
90 parser.add_option('--whitelist', action='append', default=[],
91 help='Patch only specified file(s).')
92 parser.add_option('--blacklist', action='append', default=[],
93 help='Don\'t patch specified file(s).')
90 parser.add_option('-d', '--ignore_deps', action='store_true', 94 parser.add_option('-d', '--ignore_deps', action='store_true',
91 help='Don\'t run gclient sync on DEPS changes.') 95 help='Don\'t run gclient sync on DEPS changes.')
92 options, args = parser.parse_args() 96 options, args = parser.parse_args()
93 97
98 if options.whitelist and options.blacklist:
99 parser.error('Cannot specify both --whitelist and --blacklist')
100
94 if options.password and options.private_key_file: 101 if options.password and options.private_key_file:
95 parser.error('-k and -w options are incompatible') 102 parser.error('-k and -w options are incompatible')
96 if options.email and options.email_file: 103 if options.email and options.email_file:
97 parser.error('-e and -E options are incompatible') 104 parser.error('-e and -E options are incompatible')
98 105
99 if (os.path.isfile(os.path.join(os.getcwd(), 'update.flag')) 106 if (os.path.isfile(os.path.join(os.getcwd(), 'update.flag'))
100 and not options.force): 107 and not options.force):
101 print 'update.flag file found: bot_update has run and checkout is already ' 108 print 'update.flag file found: bot_update has run and checkout is already '
102 print 'in a consistent state. No actions will be performed in this step.' 109 print 'in a consistent state. No actions will be performed in this step.'
103 return 0 110 return 0
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 print('Downloading the patch.') 185 print('Downloading the patch.')
179 try: 186 try:
180 patchset = obj.get_patch(options.issue, options.patchset) 187 patchset = obj.get_patch(options.issue, options.patchset)
181 except urllib2.HTTPError, e: 188 except urllib2.HTTPError, e:
182 print( 189 print(
183 'Failed to fetch the patch for issue %d, patchset %d.\n' 190 'Failed to fetch the patch for issue %d, patchset %d.\n'
184 'Try visiting %s/%d') % ( 191 'Try visiting %s/%d') % (
185 options.issue, options.patchset, 192 options.issue, options.patchset,
186 options.server, options.issue) 193 options.server, options.issue)
187 return 1 194 return 1
195 if options.whitelist:
196 patchset.patches = [patch for patch in patchset.patches
197 if patch.filename in options.whitelist]
198 if options.blacklist:
199 patchset.patches = [patch for patch in patchset.patches
200 if patch.filename not in options.blacklist]
188 for patch in patchset.patches: 201 for patch in patchset.patches:
189 print(patch) 202 print(patch)
190 full_dir = os.path.abspath(options.root_dir) 203 full_dir = os.path.abspath(options.root_dir)
191 scm_type = scm.determine_scm(full_dir) 204 scm_type = scm.determine_scm(full_dir)
192 if scm_type == 'svn': 205 if scm_type == 'svn':
193 scm_obj = checkout.SvnCheckout(full_dir, None, None, None, None) 206 scm_obj = checkout.SvnCheckout(full_dir, None, None, None, None)
194 elif scm_type == 'git': 207 elif scm_type == 'git':
195 scm_obj = checkout.GitCheckout(full_dir, None, None, None, None, 208 scm_obj = checkout.GitCheckout(full_dir, None, None, None, None,
196 base_ref=options.base_ref,) 209 base_ref=options.base_ref,)
197 elif scm_type == None: 210 elif scm_type == None:
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 f, options.revision_mapping) 261 f, options.revision_mapping)
249 annotated_gclient.emit_buildprops(revisions) 262 annotated_gclient.emit_buildprops(revisions)
250 263
251 return retcode 264 return retcode
252 return 0 265 return 0
253 266
254 267
255 if __name__ == "__main__": 268 if __name__ == "__main__":
256 fix_encoding.fix_encoding() 269 fix_encoding.fix_encoding()
257 sys.exit(main()) 270 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | checkout.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698