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

Side by Side Diff: trychange.py

Issue 507072: Factor out PathDifference into gclient_utils for a later reuse. (Closed)
Patch Set: Created 10 years, 12 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
« no previous file with comments | « tests/gclient_utils_test.py ('k') | no next file » | 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) 2009 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2009 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 """Client-side script to send a try job to the try server. It communicates to 5 """Client-side script to send a try job to the try server. It communicates to
6 the try server by either writting to a svn repository or by directly connecting 6 the try server by either writting to a svn repository or by directly connecting
7 to the server by HTTP. 7 to the server by HTTP.
8 """ 8 """
9 9
10 import datetime 10 import datetime
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 const=_SendChangeSVN, 420 const=_SendChangeSVN,
421 dest="send_patch", 421 dest="send_patch",
422 help="Use SVN to talk to the try server") 422 help="Use SVN to talk to the try server")
423 group.add_option("--svn_repo", 423 group.add_option("--svn_repo",
424 metavar="SVN_URL", 424 metavar="SVN_URL",
425 help="SVN url to use to write the changes in; --use_svn is " 425 help="SVN url to use to write the changes in; --use_svn is "
426 "implied when using --svn_repo") 426 "implied when using --svn_repo")
427 parser.add_option_group(group) 427 parser.add_option_group(group)
428 428
429 options, args = parser.parse_args(argv) 429 options, args = parser.parse_args(argv)
430 if len(args) == 1 and args[0] == 'help':
431 parser.print_help()
430 432
431 # Switch the default accordingly if there was no default send_patch. 433 # Switch the default accordingly if there was no default send_patch.
432 if not options.send_patch: 434 if not options.send_patch:
433 if options.port and options.host: 435 if options.port and options.host:
434 options.send_patch = _SendChangeHTTP 436 options.send_patch = _SendChangeHTTP
435 elif options.svn_repo: 437 elif options.svn_repo:
436 options.send_patch = _SendChangeSVN 438 options.send_patch = _SendChangeSVN
437 else: 439 else:
438 parser.error('Please specify an access method.') 440 parser.error('Please specify an access method.')
439 441
440 if len(args) == 1 and args[0] == 'help':
441 parser.print_help()
442 if (not options.files and (not options.issue and options.patchset) and
443 not options.diff and not options.url):
444 # TODO(maruel): It should just try the modified files showing up in a
445 # svn status.
446 parser.error('Nothing to try, changelist is empty.')
447
448 try: 442 try:
449 # Convert options.diff into the content of the diff. 443 # Convert options.diff into the content of the diff.
450 if options.url: 444 if options.url:
445 if options.files:
446 parser.error('You cannot specify files and --url at the same time.')
451 options.diff = urllib.urlopen(options.url).read() 447 options.diff = urllib.urlopen(options.url).read()
452 elif options.diff: 448 elif options.diff:
449 if options.files:
450 parser.error('You cannot specify files and --diff at the same time.')
453 options.diff = gclient_utils.FileRead(options.diff, 'rb') 451 options.diff = gclient_utils.FileRead(options.diff, 'rb')
454 # Process the VCS in any case at least to retrieve the email address. 452 # Process the VCS in any case at least to retrieve the email address.
455 try: 453 try:
456 options.scm = GuessVCS(options) 454 options.scm = GuessVCS(options)
457 except NoTryServerAccess, e: 455 except NoTryServerAccess, e:
458 # If we got the diff, we don't care. 456 # If we got the diff, we don't care.
459 if not options.diff: 457 if not options.diff:
460 # TODO(maruel): Raise what? 458 # TODO(maruel): Raise what?
461 raise 459 raise
462 460
(...skipping 16 matching lines...) Expand all
479 # If no bot is specified, either the default pool will be selected or the 477 # If no bot is specified, either the default pool will be selected or the
480 # try server will refuse the job. Either case we don't need to interfere. 478 # try server will refuse the job. Either case we don't need to interfere.
481 479
482 if options.name is None: 480 if options.name is None:
483 if options.issue: 481 if options.issue:
484 options.name = 'Issue %s' % options.issue 482 options.name = 'Issue %s' % options.issue
485 else: 483 else:
486 options.name = 'Unnamed' 484 options.name = 'Unnamed'
487 print('Note: use --name NAME to change the try job name.') 485 print('Note: use --name NAME to change the try job name.')
488 if not options.email: 486 if not options.email:
489 print('Warning: TRYBOT_RESULTS_EMAIL_ADDRESS is not set. Try server ' 487 parser.error('Using an anonymous checkout. Please use --email or set '
490 'results might\ngo to: %s@google.com.\n' % options.user) 488 'the TRYBOT_RESULTS_EMAIL_ADDRESS environment variable.')
491 else: 489 else:
492 print('Results will be emailed to: ' + options.email) 490 print('Results will be emailed to: ' + options.email)
493 491
494 # Send the patch. 492 # Send the patch.
495 options.send_patch(options) 493 options.send_patch(options)
496 if not options.dry_run: 494 if not options.dry_run:
497 text = 'Patch \'%s\' sent to try server' % options.name 495 text = 'Patch \'%s\' sent to try server' % options.name
498 if options.bot: 496 if options.bot:
499 text += ': %s' % ', '.join(options.bot) 497 text += ': %s' % ', '.join(options.bot)
500 print(text) 498 print(text)
501 except (InvalidScript, NoTryServerAccess), e: 499 except (InvalidScript, NoTryServerAccess), e:
502 if swallow_exception: 500 if swallow_exception:
503 return 1 501 return 1
504 print e 502 print e
505 return 1 503 return 1
506 return 0 504 return 0
507 505
508 506
509 if __name__ == "__main__": 507 if __name__ == "__main__":
510 sys.exit(TryChange(None, [], False)) 508 sys.exit(TryChange(None, [], False))
OLDNEW
« no previous file with comments | « tests/gclient_utils_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698