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

Side by Side Diff: apply_issue.py

Issue 273543002: Have apply_patch.py/checkout.py stage git patches instead of committing them (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Test fixes, make commit not amend (to match apply patch behavior), add todo to nuke commit 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, '
89 'used for verification.')
90 parser.add_option('--whitelist', action='append', default=[], 88 parser.add_option('--whitelist', action='append', default=[],
91 help='Patch only specified file(s).') 89 help='Patch only specified file(s).')
92 parser.add_option('--blacklist', action='append', default=[], 90 parser.add_option('--blacklist', action='append', default=[],
93 help='Don\'t patch specified file(s).') 91 help='Don\'t patch specified file(s).')
94 parser.add_option('-d', '--ignore_deps', action='store_true', 92 parser.add_option('-d', '--ignore_deps', action='store_true',
95 help='Don\'t run gclient sync on DEPS changes.') 93 help='Don\'t run gclient sync on DEPS changes.')
96 options, args = parser.parse_args() 94 options, args = parser.parse_args()
97 95
98 if options.whitelist and options.blacklist: 96 if options.whitelist and options.blacklist:
99 parser.error('Cannot specify both --whitelist and --blacklist') 97 parser.error('Cannot specify both --whitelist and --blacklist')
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 if options.blacklist: 196 if options.blacklist:
199 patchset.patches = [patch for patch in patchset.patches 197 patchset.patches = [patch for patch in patchset.patches
200 if patch.filename not in options.blacklist] 198 if patch.filename not in options.blacklist]
201 for patch in patchset.patches: 199 for patch in patchset.patches:
202 print(patch) 200 print(patch)
203 full_dir = os.path.abspath(options.root_dir) 201 full_dir = os.path.abspath(options.root_dir)
204 scm_type = scm.determine_scm(full_dir) 202 scm_type = scm.determine_scm(full_dir)
205 if scm_type == 'svn': 203 if scm_type == 'svn':
206 scm_obj = checkout.SvnCheckout(full_dir, None, None, None, None) 204 scm_obj = checkout.SvnCheckout(full_dir, None, None, None, None)
207 elif scm_type == 'git': 205 elif scm_type == 'git':
208 scm_obj = checkout.GitCheckout(full_dir, None, None, None, None, 206 scm_obj = checkout.GitCheckout(full_dir, None, None, None, None)
209 base_ref=options.base_ref,)
210 elif scm_type == None: 207 elif scm_type == None:
211 scm_obj = checkout.RawCheckout(full_dir, None, None) 208 scm_obj = checkout.RawCheckout(full_dir, None, None)
212 else: 209 else:
213 parser.error('Couldn\'t determine the scm') 210 parser.error('Couldn\'t determine the scm')
214 211
215 # TODO(maruel): HACK, remove me. 212 # TODO(maruel): HACK, remove me.
216 # When run a build slave, make sure buildbot knows that the checkout was 213 # When run a build slave, make sure buildbot knows that the checkout was
217 # modified. 214 # modified.
218 if options.root_dir == 'src' and getpass.getuser() == 'chrome-bot': 215 if options.root_dir == 'src' and getpass.getuser() == 'chrome-bot':
219 # See sourcedirIsPatched() in: 216 # See sourcedirIsPatched() in:
220 # http://src.chromium.org/viewvc/chrome/trunk/tools/build/scripts/slave/ 217 # http://src.chromium.org/viewvc/chrome/trunk/tools/build/scripts/slave/
221 # chromium_commands.py?view=markup 218 # chromium_commands.py?view=markup
222 open('.buildbot-patched', 'w').close() 219 open('.buildbot-patched', 'w').close()
223 220
224 print('\nApplying the patch.') 221 print('\nApplying the patch.')
225 try: 222 try:
226 scm_obj.apply_patch( 223 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: 224 except checkout.PatchApplicationFailed, e:
231 print(str(e)) 225 print(str(e))
232 print('CWD=%s' % os.getcwd()) 226 print('CWD=%s' % os.getcwd())
233 print('Checkout path=%s' % scm_obj.project_path) 227 print('Checkout path=%s' % scm_obj.project_path)
234 return 1 228 return 1
235 229
236 if ('DEPS' in map(os.path.basename, patchset.filenames) 230 if ('DEPS' in map(os.path.basename, patchset.filenames)
237 and not options.ignore_deps): 231 and not options.ignore_deps):
238 gclient_root = gclient_utils.FindGclientRoot(full_dir) 232 gclient_root = gclient_utils.FindGclientRoot(full_dir)
239 if gclient_root and scm_type: 233 if gclient_root and scm_type:
(...skipping 21 matching lines...) Expand all
261 f, options.revision_mapping) 255 f, options.revision_mapping)
262 annotated_gclient.emit_buildprops(revisions) 256 annotated_gclient.emit_buildprops(revisions)
263 257
264 return retcode 258 return retcode
265 return 0 259 return 0
266 260
267 261
268 if __name__ == "__main__": 262 if __name__ == "__main__":
269 fix_encoding.fix_encoding() 263 fix_encoding.fix_encoding()
270 sys.exit(main()) 264 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