| 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 3045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3056 | 3056 |
| 3057 See GetStatus() for a list of possible statuses. | 3057 See GetStatus() for a list of possible statuses. |
| 3058 """ | 3058 """ |
| 3059 # Silence upload.py otherwise it becomes unwieldly. | 3059 # Silence upload.py otherwise it becomes unwieldly. |
| 3060 upload.verbosity = 0 | 3060 upload.verbosity = 0 |
| 3061 | 3061 |
| 3062 if fine_grained: | 3062 if fine_grained: |
| 3063 # Process one branch synchronously to work through authentication, then | 3063 # Process one branch synchronously to work through authentication, then |
| 3064 # spawn processes to process all the other branches in parallel. | 3064 # spawn processes to process all the other branches in parallel. |
| 3065 if changes: | 3065 if changes: |
| 3066 fetch = lambda cl: (cl, cl.GetStatus()) | 3066 def fetch(cl): |
| 3067 try: |
| 3068 return (cl, cl.GetStatus()) |
| 3069 except: |
| 3070 # See http://crbug.com/629863. |
| 3071 logging.exception('failed to fetch status for %s:', cl) |
| 3072 raise |
| 3067 yield fetch(changes[0]) | 3073 yield fetch(changes[0]) |
| 3068 | 3074 |
| 3069 if not changes: | 3075 changes_to_fetch = changes[1:] |
| 3076 if not changes_to_fetch: |
| 3070 # Exit early if there was only one branch to fetch. | 3077 # Exit early if there was only one branch to fetch. |
| 3071 return | 3078 return |
| 3072 | 3079 |
| 3073 changes_to_fetch = changes[1:] | |
| 3074 pool = ThreadPool( | 3080 pool = ThreadPool( |
| 3075 min(max_processes, len(changes_to_fetch)) | 3081 min(max_processes, len(changes_to_fetch)) |
| 3076 if max_processes is not None | 3082 if max_processes is not None |
| 3077 else max(len(changes_to_fetch), 1)) | 3083 else max(len(changes_to_fetch), 1)) |
| 3078 | 3084 |
| 3079 fetched_cls = set() | 3085 fetched_cls = set() |
| 3080 it = pool.imap_unordered(fetch, changes_to_fetch).__iter__() | 3086 it = pool.imap_unordered(fetch, changes_to_fetch).__iter__() |
| 3081 while True: | 3087 while True: |
| 3082 try: | 3088 try: |
| 3083 row = it.next(timeout=5) | 3089 row = it.next(timeout=5) |
| (...skipping 2025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5109 if __name__ == '__main__': | 5115 if __name__ == '__main__': |
| 5110 # These affect sys.stdout so do it outside of main() to simplify mocks in | 5116 # These affect sys.stdout so do it outside of main() to simplify mocks in |
| 5111 # unit testing. | 5117 # unit testing. |
| 5112 fix_encoding.fix_encoding() | 5118 fix_encoding.fix_encoding() |
| 5113 setup_color.init() | 5119 setup_color.init() |
| 5114 try: | 5120 try: |
| 5115 sys.exit(main(sys.argv[1:])) | 5121 sys.exit(main(sys.argv[1:])) |
| 5116 except KeyboardInterrupt: | 5122 except KeyboardInterrupt: |
| 5117 sys.stderr.write('interrupted\n') | 5123 sys.stderr.write('interrupted\n') |
| 5118 sys.exit(1) | 5124 sys.exit(1) |
| OLD | NEW |