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 # Copyright (C) 2008 Evan Martin <martine@danga.com> | 6 # Copyright (C) 2008 Evan Martin <martine@danga.com> |
7 | 7 |
8 """A git-command for integrating reviews on Rietveld and Gerrit.""" | 8 """A git-command for integrating reviews on Rietveld and Gerrit.""" |
9 | 9 |
10 from __future__ import print_function | 10 from __future__ import print_function |
(...skipping 4652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4663 group.add_option( | 4663 group.add_option( |
4664 '-p', '--property', dest='properties', action='append', default=[], | 4664 '-p', '--property', dest='properties', action='append', default=[], |
4665 help='Specify generic properties in the form -p key1=value1 -p ' | 4665 help='Specify generic properties in the form -p key1=value1 -p ' |
4666 'key2=value2 etc. The value will be treated as ' | 4666 'key2=value2 etc. The value will be treated as ' |
4667 'json if decodable, or as string otherwise. ' | 4667 'json if decodable, or as string otherwise. ' |
4668 'NOTE: using this may make your try job not usable for CQ, ' | 4668 'NOTE: using this may make your try job not usable for CQ, ' |
4669 'which will then schedule another try job with default properties') | 4669 'which will then schedule another try job with default properties') |
4670 # TODO(tandrii): if this even used? | 4670 # TODO(tandrii): if this even used? |
4671 group.add_option( | 4671 group.add_option( |
4672 '-n', '--name', help='Try job name; default to current branch name') | 4672 '-n', '--name', help='Try job name; default to current branch name') |
4673 # TODO(tandrii): get rid of this. | |
4674 group.add_option( | |
4675 '--use-rietveld', action='store_true', default=False, | |
4676 help='DEPRECATED, NOT SUPPORTED.') | |
4677 group.add_option( | 4673 group.add_option( |
4678 '--buildbucket-host', default='cr-buildbucket.appspot.com', | 4674 '--buildbucket-host', default='cr-buildbucket.appspot.com', |
4679 help='Host of buildbucket. The default host is %default.') | 4675 help='Host of buildbucket. The default host is %default.') |
4680 parser.add_option_group(group) | 4676 parser.add_option_group(group) |
4681 auth.add_auth_options(parser) | 4677 auth.add_auth_options(parser) |
4682 options, args = parser.parse_args(args) | 4678 options, args = parser.parse_args(args) |
4683 auth_config = auth.extract_auth_config_from_options(options) | 4679 auth_config = auth.extract_auth_config_from_options(options) |
4684 | 4680 |
4685 if options.use_rietveld: | |
4686 parser.error('--use-rietveld is not longer supported.') | |
4687 | |
4688 # Make sure that all properties are prop=value pairs. | 4681 # Make sure that all properties are prop=value pairs. |
4689 bad_params = [x for x in options.properties if '=' not in x] | 4682 bad_params = [x for x in options.properties if '=' not in x] |
4690 if bad_params: | 4683 if bad_params: |
4691 parser.error('Got properties with missing "=": %s' % bad_params) | 4684 parser.error('Got properties with missing "=": %s' % bad_params) |
4692 | 4685 |
4693 if args: | 4686 if args: |
4694 parser.error('Unknown arguments: %s' % args) | 4687 parser.error('Unknown arguments: %s' % args) |
4695 | 4688 |
4696 cl = Changelist(auth_config=auth_config) | 4689 cl = Changelist(auth_config=auth_config) |
4697 if not cl.GetIssue(): | 4690 if not cl.GetIssue(): |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4805 ' Instead send your job to the parent.\n' | 4798 ' Instead send your job to the parent.\n' |
4806 'Bot list: %s' % builders, file=sys.stderr) | 4799 'Bot list: %s' % builders, file=sys.stderr) |
4807 return 1 | 4800 return 1 |
4808 | 4801 |
4809 patchset = cl.GetMostRecentPatchset() | 4802 patchset = cl.GetMostRecentPatchset() |
4810 if patchset and patchset != cl.GetPatchset(): | 4803 if patchset and patchset != cl.GetPatchset(): |
4811 print( | 4804 print( |
4812 '\nWARNING Mismatch between local config and server. Did a previous ' | 4805 '\nWARNING Mismatch between local config and server. Did a previous ' |
4813 'upload fail?\ngit-cl try always uses latest patchset from rietveld. ' | 4806 'upload fail?\ngit-cl try always uses latest patchset from rietveld. ' |
4814 'Continuing using\npatchset %s.\n' % patchset) | 4807 'Continuing using\npatchset %s.\n' % patchset) |
4815 if not options.use_rietveld: | 4808 try: |
4816 try: | 4809 trigger_try_jobs(auth_config, cl, options, masters, 'git_cl_try') |
4817 trigger_try_jobs(auth_config, cl, options, masters, 'git_cl_try') | 4810 except BuildbucketResponseException as ex: |
4818 except BuildbucketResponseException as ex: | 4811 print('ERROR: %s' % ex) |
4819 print('ERROR: %s' % ex) | 4812 return 1 |
4820 return 1 | 4813 except Exception as e: |
4821 except Exception as e: | 4814 stacktrace = (''.join(traceback.format_stack()) + traceback.format_exc()) |
4822 stacktrace = (''.join(traceback.format_stack()) + traceback.format_exc()) | 4815 print('ERROR: Exception when trying to trigger try jobs: %s\n%s' % |
4823 print('ERROR: Exception when trying to trigger try jobs: %s\n%s' % | 4816 (e, stacktrace)) |
4824 (e, stacktrace)) | 4817 return 1 |
4825 return 1 | |
4826 else: | |
4827 try: | |
4828 cl.RpcServer().trigger_distributed_try_jobs( | |
4829 cl.GetIssue(), patchset, options.name, options.clobber, | |
4830 options.revision, masters) | |
4831 except urllib2.HTTPError as e: | |
4832 if e.code == 404: | |
4833 print('404 from rietveld; ' | |
4834 'did you mean to use "git try" instead of "git cl try"?') | |
4835 return 1 | |
4836 print('Tried jobs on:') | |
4837 | |
4838 for (master, builders) in sorted(masters.iteritems()): | |
4839 if master: | |
4840 print('Master: %s' % master) | |
4841 length = max(len(builder) for builder in builders) | |
4842 for builder in sorted(builders): | |
4843 print(' %*s: %s' % (length, builder, ','.join(builders[builder]))) | |
4844 return 0 | 4818 return 0 |
4845 | 4819 |
4846 | 4820 |
4847 def CMDtry_results(parser, args): | 4821 def CMDtry_results(parser, args): |
4848 """Prints info about try jobs associated with current CL.""" | 4822 """Prints info about try jobs associated with current CL.""" |
4849 group = optparse.OptionGroup(parser, 'Try job results options') | 4823 group = optparse.OptionGroup(parser, 'Try job results options') |
4850 group.add_option( | 4824 group.add_option( |
4851 '-p', '--patchset', type=int, help='patchset number if not current.') | 4825 '-p', '--patchset', type=int, help='patchset number if not current.') |
4852 group.add_option( | 4826 group.add_option( |
4853 '--print-master', action='store_true', help='print master name as well.') | 4827 '--print-master', action='store_true', help='print master name as well.') |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5336 if __name__ == '__main__': | 5310 if __name__ == '__main__': |
5337 # These affect sys.stdout so do it outside of main() to simplify mocks in | 5311 # These affect sys.stdout so do it outside of main() to simplify mocks in |
5338 # unit testing. | 5312 # unit testing. |
5339 fix_encoding.fix_encoding() | 5313 fix_encoding.fix_encoding() |
5340 setup_color.init() | 5314 setup_color.init() |
5341 try: | 5315 try: |
5342 sys.exit(main(sys.argv[1:])) | 5316 sys.exit(main(sys.argv[1:])) |
5343 except KeyboardInterrupt: | 5317 except KeyboardInterrupt: |
5344 sys.stderr.write('interrupted\n') | 5318 sys.stderr.write('interrupted\n') |
5345 sys.exit(1) | 5319 sys.exit(1) |
OLD | NEW |