Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 | 5 |
| 6 """Client-side script to send a try job to the try server. It communicates to | 6 """Client-side script to send a try job to the try server. It communicates to |
| 7 the try server by either writting to a svn repository or by directly connecting | 7 the try server by either writting to a svn repository or by directly connecting |
| 8 to the server by HTTP. | 8 to the server by HTTP. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 363 raise NoTryServerAccess('Please use the --svn_repo option to specify the' | 363 raise NoTryServerAccess('Please use the --svn_repo option to specify the' |
| 364 ' try server svn repository to connect to.') | 364 ' try server svn repository to connect to.') |
| 365 | 365 |
| 366 values = _ParseSendChangeOptions(options) | 366 values = _ParseSendChangeOptions(options) |
| 367 description = ''.join("%s=%s\n" % (k, v) for (k, v) in values.iteritems()) | 367 description = ''.join("%s=%s\n" % (k, v) for (k, v) in values.iteritems()) |
| 368 logging.info('Sending by SVN') | 368 logging.info('Sending by SVN') |
| 369 logging.info(description) | 369 logging.info(description) |
| 370 logging.info(options.svn_repo) | 370 logging.info(options.svn_repo) |
| 371 logging.info(options.diff) | 371 logging.info(options.diff) |
| 372 if options.dry_run: | 372 if options.dry_run: |
| 373 print options.diff | |
|
M-A Ruel
2011/03/09 15:30:34
It's assumed that --dry-run is used with --verbose
Bernhard Bauer
2011/03/09 15:55:11
I see. I wanted to make it analog to _SendChangeHT
| |
| 373 return | 374 return |
| 374 | 375 |
| 375 # Create a temporary directory, put a uniquely named file in it with the diff | 376 # Create a temporary directory, put a uniquely named file in it with the diff |
| 376 # content and svn import that. | 377 # content and svn import that. |
| 377 temp_dir = tempfile.mkdtemp() | 378 temp_dir = tempfile.mkdtemp() |
| 378 temp_file = tempfile.NamedTemporaryFile() | 379 temp_file = tempfile.NamedTemporaryFile() |
| 379 try: | 380 try: |
| 380 try: | 381 try: |
| 381 # Description | 382 # Description |
| 382 temp_file.write(description) | 383 temp_file.write(description) |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 604 dest="send_patch", | 605 dest="send_patch", |
| 605 help="Use SVN to talk to the try server") | 606 help="Use SVN to talk to the try server") |
| 606 group.add_option("-S", "--svn_repo", | 607 group.add_option("-S", "--svn_repo", |
| 607 metavar="SVN_URL", | 608 metavar="SVN_URL", |
| 608 help="SVN url to use to write the changes in; --use_svn is " | 609 help="SVN url to use to write the changes in; --use_svn is " |
| 609 "implied when using --svn_repo") | 610 "implied when using --svn_repo") |
| 610 parser.add_option_group(group) | 611 parser.add_option_group(group) |
| 611 | 612 |
| 612 options, args = parser.parse_args(argv) | 613 options, args = parser.parse_args(argv) |
| 613 | 614 |
| 614 # Note that the args array includes the script name, so | |
| 615 # a single argument results in len(args) == 2. | |
| 616 | |
| 617 # If they've asked for help, give it to them | 615 # If they've asked for help, give it to them |
| 618 if len(args) == 2 and args[1] == 'help': | 616 if len(args) == 1 and args[0] == 'help': |
| 619 parser.print_help() | 617 parser.print_help() |
| 620 return 0 | 618 return 0 |
| 621 | 619 |
| 622 # If they've said something confusing, don't spawn a try job until you | 620 # If they've said something confusing, don't spawn a try job until you |
| 623 # understand what they want. | 621 # understand what they want. |
| 624 if len(args) > 1: | 622 if len(args) > 0: |
|
M-A Ruel
2011/03/09 15:30:34
Ugh, this code is ugly. Since you're touching it a
Bernhard Bauer
2011/03/09 15:55:11
Done.
| |
| 625 plural = "" | 623 plural = "" |
| 626 if len(args) > 2: | 624 if len(args) > 1: |
| 627 plural = "s" | 625 plural = "s" |
| 628 print >> sys.stderr, ( | 626 print >> sys.stderr, ( |
| 629 'Argument%s \"%s\" not understood' % (plural, ' '.join(args[1:]))) | 627 'Argument%s \"%s\" not understood' % (plural, ' '.join(args))) |
| 630 parser.print_help() | 628 parser.print_help() |
| 631 return 1 | 629 return 1 |
| 632 | 630 |
| 633 LOG_FORMAT = '%(levelname)s %(filename)s(%(lineno)d): %(message)s' | 631 LOG_FORMAT = '%(levelname)s %(filename)s(%(lineno)d): %(message)s' |
| 634 if not swallow_exception: | 632 if not swallow_exception: |
| 635 if options.verbose == 0: | 633 if options.verbose == 0: |
| 636 logging.basicConfig(level=logging.WARNING, format=LOG_FORMAT) | 634 logging.basicConfig(level=logging.WARNING, format=LOG_FORMAT) |
| 637 elif options.verbose == 1: | 635 elif options.verbose == 1: |
| 638 logging.basicConfig(level=logging.INFO, format=LOG_FORMAT) | 636 logging.basicConfig(level=logging.INFO, format=LOG_FORMAT) |
| 639 elif options.verbose > 1: | 637 elif options.verbose > 1: |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 769 print >> sys.stderr, e | 767 print >> sys.stderr, e |
| 770 return 1 | 768 return 1 |
| 771 except gclient_utils.Error, e: | 769 except gclient_utils.Error, e: |
| 772 print >> sys.stderr, e | 770 print >> sys.stderr, e |
| 773 return 1 | 771 return 1 |
| 774 return 0 | 772 return 0 |
| 775 | 773 |
| 776 | 774 |
| 777 if __name__ == "__main__": | 775 if __name__ == "__main__": |
| 778 sys.exit(TryChange(None, [], False)) | 776 sys.exit(TryChange(None, [], False)) |
| OLD | NEW |