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

Side by Side Diff: trychange.py

Issue 423002: Small cleanup (Closed)
Patch Set: Created 11 years, 1 month 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 | « no previous file | 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 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 %prog --url http://url/to/patch.diff --patchlevel 1 --root src 45 %prog --url http://url/to/patch.diff --patchlevel 1 --root src
46 46
47 Use svn to store the try job, specify an alternate email address and use a 47 Use svn to store the try job, specify an alternate email address and use a
48 premade diff file on the local drive: 48 premade diff file on the local drive:
49 %prog --email user@example.com 49 %prog --email user@example.com
50 --svn_repo svn://svn.chromium.org/chrome-try/try --diff foo.diff 50 --svn_repo svn://svn.chromium.org/chrome-try/try --diff foo.diff
51 51
52 Running only on a 'mac' slave with revision 123 and clobber first; specify 52 Running only on a 'mac' slave with revision 123 and clobber first; specify
53 manually the 3 source files to use for the try job: 53 manually the 3 source files to use for the try job:
54 %prog --bot mac --revision 123 --clobber -f src/a.cc -f src/a.h 54 %prog --bot mac --revision 123 --clobber -f src/a.cc -f src/a.h
55 -f include/b.h 55 -f include/b.h"""
56
57 """
58 56
59 class InvalidScript(Exception): 57 class InvalidScript(Exception):
60 def __str__(self): 58 def __str__(self):
61 return self.args[0] + '\n' + HELP_STRING 59 return self.args[0] + '\n' + HELP_STRING
62 60
63 61
64 class NoTryServerAccess(Exception): 62 class NoTryServerAccess(Exception):
65 def __str__(self): 63 def __str__(self):
66 return self.args[0] + '\n' + HELP_STRING 64 return self.args[0] + '\n' + HELP_STRING
67 65
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 parser.add_option_group(group) 498 parser.add_option_group(group)
501 499
502 options, args = parser.parse_args(argv) 500 options, args = parser.parse_args(argv)
503 501
504 # Switch the default accordingly if there was no default send_patch. 502 # Switch the default accordingly if there was no default send_patch.
505 if not options.send_patch: 503 if not options.send_patch:
506 if options.port and options.host: 504 if options.port and options.host:
507 options.send_patch = _SendChangeHTTP 505 options.send_patch = _SendChangeHTTP
508 elif options.svn_repo: 506 elif options.svn_repo:
509 options.send_patch = _SendChangeSVN 507 options.send_patch = _SendChangeSVN
508 else:
509 parser.error('Please specify an access method.')
510 510
511 if len(args) == 1 and args[0] == 'help': 511 if len(args) == 1 and args[0] == 'help':
512 parser.print_help() 512 parser.print_help()
513 if (not options.files and (not options.issue and options.patchset) and 513 if (not options.files and (not options.issue and options.patchset) and
514 not options.diff and not options.url): 514 not options.diff and not options.url):
515 # TODO(maruel): It should just try the modified files showing up in a 515 # TODO(maruel): It should just try the modified files showing up in a
516 # svn status. 516 # svn status.
517 print "Nothing to try, changelist is empty." 517 parser.error('Nothing to try, changelist is empty.')
518 return 1
519 518
520 try: 519 try:
521 # Convert options.diff into the content of the diff. 520 # Convert options.diff into the content of the diff.
522 if options.url: 521 if options.url:
523 options.diff = urllib.urlopen(options.url).read() 522 options.diff = urllib.urlopen(options.url).read()
524 elif options.diff: 523 elif options.diff:
525 options.diff = gcl.ReadFile(options.diff) 524 options.diff = gcl.ReadFile(options.diff)
526 # Process the VCS in any case at least to retrieve the email address. 525 # Process the VCS in any case at least to retrieve the email address.
527 try: 526 try:
528 options.scm = GuessVCS(options) 527 options.scm = GuessVCS(options)
529 options.scm.ProcessOptions() 528 options.scm.ProcessOptions()
530 except NoTryServerAccess, e: 529 except NoTryServerAccess, e:
531 # If we got the diff, we don't care. 530 # If we got the diff, we don't care.
532 if not options.diff: 531 if not options.diff:
533 # TODO(maruel): Raise what? 532 # TODO(maruel): Raise what?
534 raise 533 raise
535 534
536 # Get try slaves from PRESUBMIT.py files if not specified. 535 # Get try slaves from PRESUBMIT.py files if not specified.
537 if not options.bot: 536 if not options.bot:
538 if options.url: 537 if options.url:
539 print('You need to specify which bots to use.') 538 parser.error('You need to specify which bots to use.')
540 return 1
541 root_presubmit = gcl.GetCachedFile('PRESUBMIT.py', use_root=True) 539 root_presubmit = gcl.GetCachedFile('PRESUBMIT.py', use_root=True)
542 options.bot = presubmit_support.DoGetTrySlaves(options.scm.GetFileNames(), 540 options.bot = presubmit_support.DoGetTrySlaves(options.scm.GetFileNames(),
543 options.scm.GetLocalRoot(), 541 options.scm.GetLocalRoot(),
544 root_presubmit, 542 root_presubmit,
545 False, 543 False,
546 sys.stdout) 544 sys.stdout)
547 545
548 if options.name is None: 546 if options.name is None:
549 if options.issue: 547 if options.issue:
550 options.name = 'Issue %s' % options.issue 548 options.name = 'Issue %s' % options.issue
(...skipping 13 matching lines...) Expand all
564 except (InvalidScript, NoTryServerAccess), e: 562 except (InvalidScript, NoTryServerAccess), e:
565 if swallow_exception: 563 if swallow_exception:
566 return 1 564 return 1
567 print e 565 print e
568 return 1 566 return 1
569 return 0 567 return 0
570 568
571 569
572 if __name__ == "__main__": 570 if __name__ == "__main__":
573 sys.exit(TryChange(None, None, False)) 571 sys.exit(TryChange(None, None, False))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698