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