Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(273)

Side by Side Diff: git_cl.py

Issue 178223016: Support multiple try masters when sending tries to rietveld. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Fix JSON serialization. Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | presubmit_support.py » ('j') | presubmit_support.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2099 matching lines...) Expand 10 before | Expand all | Expand 10 after
2110 if args: 2110 if args:
2111 parser.error('Unknown arguments: %s' % args) 2111 parser.error('Unknown arguments: %s' % args)
2112 2112
2113 cl = Changelist() 2113 cl = Changelist()
2114 if not cl.GetIssue(): 2114 if not cl.GetIssue():
2115 parser.error('Need to upload first') 2115 parser.error('Need to upload first')
2116 2116
2117 if not options.name: 2117 if not options.name:
2118 options.name = cl.GetBranch() 2118 options.name = cl.GetBranch()
2119 2119
2120 # Process --bot and --testfilter. 2120 def GetMasterMap():
2121 if not options.bot: 2121 # Process --bot and --testfilter.
2122 # Get try slaves from PRESUBMIT.py files if not specified. 2122 if not options.bot:
2123 change = cl.GetChange(cl.GetCommonAncestorWithUpstream(), None) 2123 change = cl.GetChange(cl.GetCommonAncestorWithUpstream(), None)
2124 options.bot = presubmit_support.DoGetTrySlaves(
2125 change,
2126 change.LocalPaths(),
2127 settings.GetRoot(),
2128 None,
2129 None,
2130 options.verbose,
2131 sys.stdout)
2132 if not options.bot:
2133 parser.error('No default try builder to try, use --bot')
2134 2124
2135 builders_and_tests = {} 2125 # Get try masters from PRESUBMIT.py files.
2136 old_style = filter(lambda x: isinstance(x, basestring), options.bot) 2126 masters = presubmit_support.DoGetTryMasters(
2137 new_style = filter(lambda x: isinstance(x, tuple), options.bot) 2127 change,
2128 change.LocalPaths(),
2129 settings.GetRoot(),
2130 None,
2131 None,
2132 options.verbose,
2133 sys.stdout)
2134 if masters:
2135 return masters
2138 2136
2139 for bot in old_style: 2137 # Fall back to deprecated method: get try slaves from PRESUBMIT.py files.
2140 if ':' in bot: 2138 options.bot = presubmit_support.DoGetTrySlaves(
2141 builder, tests = bot.split(':', 1) 2139 change,
2142 builders_and_tests.setdefault(builder, []).extend(tests.split(',')) 2140 change.LocalPaths(),
2143 elif ',' in bot: 2141 settings.GetRoot(),
2144 parser.error('Specify one bot per --bot flag') 2142 None,
2145 else: 2143 None,
2146 builders_and_tests.setdefault(bot, []).append('defaulttests') 2144 options.verbose,
2145 sys.stdout)
2146 if not options.bot:
2147 parser.error('No default try builder to try, use --bot')
2147 2148
2148 for bot, tests in new_style: 2149 builders_and_tests = {}
2149 builders_and_tests.setdefault(bot, []).extend(tests) 2150 # TODO(machenbach): The old style command-line options don't support
2151 # multiple try masters yet.
Paweł Hajdan Jr. 2014/02/27 02:20:24 Not only that, but it'll be required to provide so
Michael Achenbach 2014/02/27 18:35:23 I added a master option. But even better would be
2152 old_style = filter(lambda x: isinstance(x, basestring), options.bot)
2153 new_style = filter(lambda x: isinstance(x, tuple), options.bot)
2154
2155 for bot in old_style:
2156 if ':' in bot:
2157 builder, tests = bot.split(':', 1)
2158 builders_and_tests.setdefault(builder, []).extend(tests.split(','))
2159 elif ',' in bot:
2160 parser.error('Specify one bot per --bot flag')
2161 else:
2162 builders_and_tests.setdefault(bot, []).append('defaulttests')
2163
2164 for bot, tests in new_style:
2165 builders_and_tests.setdefault(bot, []).extend(tests)
2166
2167 # Return a master map with an empty master to be backwards compatible.
2168 return {'': builders_and_tests}
2169
2170 masters = GetMasterMap()
2150 2171
2151 if options.testfilter: 2172 if options.testfilter:
2152 forced_tests = sum((t.split(',') for t in options.testfilter), []) 2173 forced_tests = sum((t.split(',') for t in options.testfilter), [])
2153 builders_and_tests = dict( 2174 masters = dict((master, dict(
2154 (b, forced_tests) for b, t in builders_and_tests.iteritems() 2175 (b, forced_tests) for b, t in slaves.iteritems()
2155 if t != ['compile']) 2176 if t != ['compile'])) for master, slaves in masters.iteritems())
2156 2177
2157 if any('triggered' in b for b in builders_and_tests): 2178 for builders in masters.itervalues():
2158 print >> sys.stderr, ( 2179 if any('triggered' in b for b in builders):
2159 'ERROR You are trying to send a job to a triggered bot. This type of' 2180 print >> sys.stderr, (
2160 ' bot requires an\ninitial job from a parent (usually a builder). ' 2181 'ERROR You are trying to send a job to a triggered bot. This type of'
2161 'Instead send your job to the parent.\n' 2182 ' bot requires an\ninitial job from a parent (usually a builder). '
2162 'Bot list: %s' % builders_and_tests) 2183 'Instead send your job to the parent.\n'
2163 return 1 2184 'Bot list: %s' % builders)
2185 return 1
2164 2186
2165 patchset = cl.GetMostRecentPatchset() 2187 patchset = cl.GetMostRecentPatchset()
2166 if patchset and patchset != cl.GetPatchset(): 2188 if patchset and patchset != cl.GetPatchset():
2167 print( 2189 print(
2168 '\nWARNING Mismatch between local config and server. Did a previous ' 2190 '\nWARNING Mismatch between local config and server. Did a previous '
2169 'upload fail?\ngit-cl try always uses latest patchset from rietveld. ' 2191 'upload fail?\ngit-cl try always uses latest patchset from rietveld. '
2170 'Continuing using\npatchset %s.\n' % patchset) 2192 'Continuing using\npatchset %s.\n' % patchset)
2171 try: 2193 try:
2172 cl.RpcServer().trigger_try_jobs( 2194 cl.RpcServer().trigger_try_jobs(
2173 cl.GetIssue(), patchset, options.name, options.clobber, 2195 cl.GetIssue(), patchset, options.name, options.clobber,
2174 options.revision, builders_and_tests) 2196 options.revision, masters)
2175 except urllib2.HTTPError, e: 2197 except urllib2.HTTPError, e:
2176 if e.code == 404: 2198 if e.code == 404:
2177 print('404 from rietveld; ' 2199 print('404 from rietveld; '
2178 'did you mean to use "git try" instead of "git cl try"?') 2200 'did you mean to use "git try" instead of "git cl try"?')
2179 return 1 2201 return 1
2180 print('Tried jobs on:') 2202 print('Tried jobs on:')
2181 length = max(len(builder) for builder in builders_and_tests) 2203
2182 for builder in sorted(builders_and_tests): 2204 for (master, builders) in masters.iteritems():
2183 print ' %*s: %s' % (length, builder, ','.join(builders_and_tests[builder])) 2205 if master:
2206 print 'Master: %s' % master
2207 length = max(len(builder) for builder in builders)
2208 for builder in sorted(builders):
2209 print ' %*s: %s' % (length, builder, ','.join(builders[builder]))
2184 return 0 2210 return 0
2185 2211
2186 2212
2187 @subcommand.usage('[new upstream branch]') 2213 @subcommand.usage('[new upstream branch]')
2188 def CMDupstream(parser, args): 2214 def CMDupstream(parser, args):
2189 """Prints or sets the name of the upstream branch, if any.""" 2215 """Prints or sets the name of the upstream branch, if any."""
2190 _, args = parser.parse_args(args) 2216 _, args = parser.parse_args(args)
2191 if len(args) > 1: 2217 if len(args) > 1:
2192 parser.error('Unrecognized args: %s' % ' '.join(args)) 2218 parser.error('Unrecognized args: %s' % ' '.join(args))
2193 2219
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
2430 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' 2456 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith '
2431 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) 2457 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)))
2432 2458
2433 2459
2434 if __name__ == '__main__': 2460 if __name__ == '__main__':
2435 # These affect sys.stdout so do it outside of main() to simplify mocks in 2461 # These affect sys.stdout so do it outside of main() to simplify mocks in
2436 # unit testing. 2462 # unit testing.
2437 fix_encoding.fix_encoding() 2463 fix_encoding.fix_encoding()
2438 colorama.init() 2464 colorama.init()
2439 sys.exit(main(sys.argv[1:])) 2465 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | presubmit_support.py » ('j') | presubmit_support.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698