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.""" | 8 """A git-command for integrating reviews on Rietveld.""" |
9 | 9 |
10 from distutils.version import LooseVersion | 10 from distutils.version import LooseVersion |
(...skipping 2213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2224 return 0 | 2224 return 0 |
2225 | 2225 |
2226 | 2226 |
2227 def CMDtry(parser, args): | 2227 def CMDtry(parser, args): |
2228 """Triggers a try job through Rietveld.""" | 2228 """Triggers a try job through Rietveld.""" |
2229 group = optparse.OptionGroup(parser, "Try job options") | 2229 group = optparse.OptionGroup(parser, "Try job options") |
2230 group.add_option( | 2230 group.add_option( |
2231 "-b", "--bot", action="append", | 2231 "-b", "--bot", action="append", |
2232 help=("IMPORTANT: specify ONE builder per --bot flag. Use it multiple " | 2232 help=("IMPORTANT: specify ONE builder per --bot flag. Use it multiple " |
2233 "times to specify multiple builders. ex: " | 2233 "times to specify multiple builders. ex: " |
2234 "'-bwin_rel:ui_tests,webkit_unit_tests -bwin_layout'. See " | 2234 "'-b win_rel:ui_tests,webkit_unit_tests -b win_layout'. See " |
2235 "the try server waterfall for the builders name and the tests " | 2235 "the try server waterfall for the builders name and the tests " |
2236 "available. Can also be used to specify gtest_filter, e.g. " | 2236 "available. Can also be used to specify gtest_filter, e.g. " |
2237 "-bwin_rel:base_unittests:ValuesTest.*Value")) | 2237 "-b win_rel:base_unittests:ValuesTest.*Value")) |
2238 group.add_option( | 2238 group.add_option( |
2239 "-m", "--master", default='', | 2239 "-m", "--master", default='', |
2240 help=("Specify a try master where to run the tries.")) | 2240 help=("Specify a try master where to run the tries.")) |
2241 group.add_option( | 2241 group.add_option( |
2242 "-r", "--revision", | 2242 "-r", "--revision", |
2243 help="Revision to use for the try job; default: the " | 2243 help="Revision to use for the try job; default: the " |
2244 "revision will be determined by the try server; see " | 2244 "revision will be determined by the try server; see " |
2245 "its waterfall for more info") | 2245 "its waterfall for more info") |
2246 group.add_option( | 2246 group.add_option( |
2247 "-c", "--clobber", action="store_true", default=False, | 2247 "-c", "--clobber", action="store_true", default=False, |
(...skipping 21 matching lines...) Expand all Loading... | |
2269 parser.error('Need to upload first') | 2269 parser.error('Need to upload first') |
2270 | 2270 |
2271 props = cl.GetIssueProperties() | 2271 props = cl.GetIssueProperties() |
2272 if props.get('private'): | 2272 if props.get('private'): |
2273 parser.error('Cannot use trybots with private issue') | 2273 parser.error('Cannot use trybots with private issue') |
2274 | 2274 |
2275 if not options.name: | 2275 if not options.name: |
2276 options.name = cl.GetBranch() | 2276 options.name = cl.GetBranch() |
2277 | 2277 |
2278 if options.bot and not options.master: | 2278 if options.bot and not options.master: |
2279 parser.error('For manually specified bots please also specify the ' | 2279 err_msg = '' |
M-A Ruel
2014/08/13 12:47:07
Would you mind making this discovery part a functi
sheyang
2014/08/14 18:08:26
Done.
| |
2280 'tryserver master, e.g. "-m tryserver.chromium.linux".') | 2280 master_map = None |
2281 map_url = 'https://builders-map.appspot.com/' | |
2282 try: | |
2283 res = urllib2.urlopen(map_url) | |
2284 master_map = json.load(res) | |
2285 except urllib2.URLError as url_e: | |
2286 err_msg = ('Failed to fetch builder-to-master map from %s. Error: %s.' % | |
2287 (map_url, url_e)) | |
2288 except ValueError as val_e: | |
2289 err_msg = 'Invalid json string from %s. Error: %s.' % (map_url, val_e) | |
2290 | |
2291 if master_map: | |
2292 for bot in options.bot: | |
2293 if ':' in bot: | |
2294 builder, _ = bot.split(':', 1) | |
2295 else: | |
2296 builder = bot | |
2297 master_list = master_map.get(builder, []) | |
2298 if not master_list: | |
2299 err_msg = 'Cannot find a master for builder %s.' % builder | |
2300 break | |
2301 elif len(master_list) > 1: | |
2302 err_msg = ('The builder name %s exists in multiple masters %s.' % | |
2303 (builder, master_list)) | |
2304 break | |
2305 else: | |
2306 cur_master = master_list[0] | |
2307 if not options.master: | |
2308 options.master = cur_master | |
2309 elif options.master != cur_master: | |
2310 err_msg = 'The builders do not belong to the same master.' | |
2311 break | |
2312 | |
2313 if err_msg: | |
2314 parser.error('Tryserver master cannot be found because: %s\n' | |
2315 'Please manually specify the tryserver master' | |
2316 ', e.g. "-m tryserver.chromium.linux".' % err_msg) | |
2281 | 2317 |
2282 def GetMasterMap(): | 2318 def GetMasterMap(): |
2283 # Process --bot and --testfilter. | 2319 # Process --bot and --testfilter. |
2284 if not options.bot: | 2320 if not options.bot: |
2285 change = cl.GetChange(cl.GetCommonAncestorWithUpstream(), None) | 2321 change = cl.GetChange(cl.GetCommonAncestorWithUpstream(), None) |
2286 | 2322 |
2287 # Get try masters from PRESUBMIT.py files. | 2323 # Get try masters from PRESUBMIT.py files. |
2288 masters = presubmit_support.DoGetTryMasters( | 2324 masters = presubmit_support.DoGetTryMasters( |
2289 change, | 2325 change, |
2290 change.LocalPaths(), | 2326 change.LocalPaths(), |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2633 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' | 2669 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' |
2634 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) | 2670 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) |
2635 | 2671 |
2636 | 2672 |
2637 if __name__ == '__main__': | 2673 if __name__ == '__main__': |
2638 # These affect sys.stdout so do it outside of main() to simplify mocks in | 2674 # These affect sys.stdout so do it outside of main() to simplify mocks in |
2639 # unit testing. | 2675 # unit testing. |
2640 fix_encoding.fix_encoding() | 2676 fix_encoding.fix_encoding() |
2641 colorama.init() | 2677 colorama.init() |
2642 sys.exit(main(sys.argv[1:])) | 2678 sys.exit(main(sys.argv[1:])) |
OLD | NEW |