OLD | NEW |
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 """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 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 new_file = posixpath.join(path_diff, diff[i][4:]).replace('\\', '/') | 517 new_file = posixpath.join(path_diff, diff[i][4:]).replace('\\', '/') |
518 if diff[i].startswith('--- '): | 518 if diff[i].startswith('--- '): |
519 file_path = new_file.split('\t')[0].strip() | 519 file_path = new_file.split('\t')[0].strip() |
520 if file_path.startswith('a/'): | 520 if file_path.startswith('a/'): |
521 file_path = file_path[2:] | 521 file_path = file_path[2:] |
522 changed_files.append(('M', file_path)) | 522 changed_files.append(('M', file_path)) |
523 diff[i] = diff[i][0:4] + new_file | 523 diff[i] = diff[i][0:4] + new_file |
524 return (diff, changed_files) | 524 return (diff, changed_files) |
525 | 525 |
526 | 526 |
527 class OptionParser(optparse.OptionParser): | |
528 def format_epilog(self, _): | |
529 """Removes epilog formatting.""" | |
530 return self.epilog or '' | |
531 | |
532 | |
533 def gen_parser(prog): | 527 def gen_parser(prog): |
534 # Parse argv | 528 # Parse argv |
535 parser = OptionParser(usage=USAGE, version=__version__, prog=prog) | 529 parser = optparse.OptionParser(usage=USAGE, |
| 530 version=__version__, |
| 531 prog=prog) |
536 parser.add_option("-v", "--verbose", action="count", default=0, | 532 parser.add_option("-v", "--verbose", action="count", default=0, |
537 help="Prints debugging infos") | 533 help="Prints debugging infos") |
538 group = optparse.OptionGroup(parser, "Result and status") | 534 group = optparse.OptionGroup(parser, "Result and status") |
539 group.add_option("-u", "--user", default=getpass.getuser(), | 535 group.add_option("-u", "--user", default=getpass.getuser(), |
540 help="Owner user name [default: %default]") | 536 help="Owner user name [default: %default]") |
541 group.add_option("-e", "--email", | 537 group.add_option("-e", "--email", |
542 default=os.environ.get('TRYBOT_RESULTS_EMAIL_ADDRESS', | 538 default=os.environ.get('TRYBOT_RESULTS_EMAIL_ADDRESS', |
543 os.environ.get('EMAIL_ADDRESS')), | 539 os.environ.get('EMAIL_ADDRESS')), |
544 help="Email address where to send the results. Use either " | 540 help="Email address where to send the results. Use either " |
545 "the TRYBOT_RESULTS_EMAIL_ADDRESS environment " | 541 "the TRYBOT_RESULTS_EMAIL_ADDRESS environment " |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 Args: | 668 Args: |
673 argv: Arguments and options. | 669 argv: Arguments and options. |
674 change: Change instance corresponding to the CL. | 670 change: Change instance corresponding to the CL. |
675 swallow_exception: Whether we raise or swallow exceptions. | 671 swallow_exception: Whether we raise or swallow exceptions. |
676 """ | 672 """ |
677 parser = gen_parser(prog) | 673 parser = gen_parser(prog) |
678 epilog = EPILOG % { 'prog': prog } | 674 epilog = EPILOG % { 'prog': prog } |
679 if extra_epilog: | 675 if extra_epilog: |
680 epilog += extra_epilog | 676 epilog += extra_epilog |
681 parser.epilog = epilog | 677 parser.epilog = epilog |
| 678 # Remove epilog formatting |
| 679 parser.format_epilog = lambda x: parser.epilog |
682 | 680 |
683 options, args = parser.parse_args(argv) | 681 options, args = parser.parse_args(argv) |
684 | 682 |
685 # If they've asked for help, give it to them | 683 # If they've asked for help, give it to them |
686 if len(args) == 1 and args[0] == 'help': | 684 if len(args) == 1 and args[0] == 'help': |
687 parser.print_help() | 685 parser.print_help() |
688 return 0 | 686 return 0 |
689 | 687 |
690 # If they've said something confusing, don't spawn a try job until you | 688 # If they've said something confusing, don't spawn a try job until you |
691 # understand what they want. | 689 # understand what they want. |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 return 1 | 886 return 1 |
889 except (gclient_utils.Error, subprocess2.CalledProcessError), e: | 887 except (gclient_utils.Error, subprocess2.CalledProcessError), e: |
890 print >> sys.stderr, e | 888 print >> sys.stderr, e |
891 return 1 | 889 return 1 |
892 return 0 | 890 return 0 |
893 | 891 |
894 | 892 |
895 if __name__ == "__main__": | 893 if __name__ == "__main__": |
896 fix_encoding.fix_encoding() | 894 fix_encoding.fix_encoding() |
897 sys.exit(TryChange(None, None, False)) | 895 sys.exit(TryChange(None, None, False)) |
OLD | NEW |