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

Side by Side Diff: git_cl.py

Issue 213573004: Process first branch status request before spawning threads. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: CHanged branches to a list. Created 6 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
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 1191 matching lines...) Expand 10 before | Expand all | Expand 10 after
1202 if url: 1202 if url:
1203 print url 1203 print url
1204 return 0 1204 return 0
1205 1205
1206 branches = RunGit(['for-each-ref', '--format=%(refname)', 'refs/heads']) 1206 branches = RunGit(['for-each-ref', '--format=%(refname)', 'refs/heads'])
1207 if not branches: 1207 if not branches:
1208 print('No local branch found.') 1208 print('No local branch found.')
1209 return 0 1209 return 0
1210 1210
1211 changes = (Changelist(branchref=b) for b in branches.splitlines()) 1211 changes = (Changelist(branchref=b) for b in branches.splitlines())
1212 branches = dict((c.GetBranch(), c.GetIssueURL()) for c in changes) 1212 branches = [c.GetBranch() for c in changes]
1213 alignment = max(5, max(len(b) for b in branches)) 1213 alignment = max(5, max(len(b) for b in branches))
1214 print 'Branches associated with reviews:' 1214 print 'Branches associated with reviews:'
1215 # Adhoc thread pool to request data concurrently. 1215 # Adhoc thread pool to request data concurrently.
1216 output = Queue.Queue() 1216 output = Queue.Queue()
1217 1217
1218 # Silence upload.py otherwise it becomes unweldly. 1218 # Silence upload.py otherwise it becomes unweldly.
1219 upload.verbosity = 0 1219 upload.verbosity = 0
1220 1220
1221 if not options.fast: 1221 if not options.fast:
1222 def fetch(b): 1222 def fetch(b):
(...skipping 25 matching lines...) Expand all
1248 color = Fore.GREEN 1248 color = Fore.GREEN
1249 elif not msgs: 1249 elif not msgs:
1250 # No message was sent. 1250 # No message was sent.
1251 color = Fore.RED 1251 color = Fore.RED
1252 elif msgs[-1]['sender'] != props.get('owner_email'): 1252 elif msgs[-1]['sender'] != props.get('owner_email'):
1253 color = Fore.YELLOW 1253 color = Fore.YELLOW
1254 else: 1254 else:
1255 color = Fore.BLUE 1255 color = Fore.BLUE
1256 output.put((b, i, color)) 1256 output.put((b, i, color))
1257 1257
1258 threads = [threading.Thread(target=fetch, args=(b,)) for b in branches] 1258 # Process one branch synchronously to work through authentication, then
1259 # spawn threads to process all the other branches in parallel.
1260 if branches:
1261 fetch(branches[0])
1262 threads = [
1263 threading.Thread(target=fetch, args=(b,)) for b in branches[1:]]
1259 for t in threads: 1264 for t in threads:
1260 t.daemon = True 1265 t.daemon = True
1261 t.start() 1266 t.start()
1262 else: 1267 else:
1263 # Do not use GetApprovingReviewers(), since it requires an HTTP request. 1268 # Do not use GetApprovingReviewers(), since it requires an HTTP request.
1264 for b in branches: 1269 for b in branches:
1265 c = Changelist(branchref=b) 1270 c = Changelist(branchref=b)
1266 url = c.GetIssueURL() 1271 url = c.GetIssueURL()
1267 output.put((b, url, Fore.BLUE if url else Fore.WHITE)) 1272 output.put((b, url, Fore.BLUE if url else Fore.WHITE))
1268 1273
(...skipping 1271 matching lines...) Expand 10 before | Expand all | Expand 10 after
2540 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith ' 2545 ('AppEngine is misbehaving and returned HTTP %d, again. Keep faith '
2541 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e))) 2546 'and retry or visit go/isgaeup.\n%s') % (e.code, str(e)))
2542 2547
2543 2548
2544 if __name__ == '__main__': 2549 if __name__ == '__main__':
2545 # These affect sys.stdout so do it outside of main() to simplify mocks in 2550 # These affect sys.stdout so do it outside of main() to simplify mocks in
2546 # unit testing. 2551 # unit testing.
2547 fix_encoding.fix_encoding() 2552 fix_encoding.fix_encoding()
2548 colorama.init() 2553 colorama.init()
2549 sys.exit(main(sys.argv[1:])) 2554 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698