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 3055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3066 yield fetch(changes[0]) | 3066 yield fetch(changes[0]) |
3067 | 3067 |
3068 if not changes: | 3068 if not changes: |
3069 # Exit early if there was only one branch to fetch. | 3069 # Exit early if there was only one branch to fetch. |
3070 return | 3070 return |
3071 | 3071 |
3072 changes_to_fetch = changes[1:] | 3072 changes_to_fetch = changes[1:] |
3073 pool = ThreadPool( | 3073 pool = ThreadPool( |
3074 min(max_processes, len(changes_to_fetch)) | 3074 min(max_processes, len(changes_to_fetch)) |
3075 if max_processes is not None | 3075 if max_processes is not None |
3076 else len(changes_to_fetch)) | 3076 else max(len(changes_to_fetch), 1)) |
3077 | 3077 |
3078 fetched_cls = set() | 3078 fetched_cls = set() |
3079 it = pool.imap_unordered(fetch, changes_to_fetch).__iter__() | 3079 it = pool.imap_unordered(fetch, changes_to_fetch).__iter__() |
3080 while True: | 3080 while True: |
3081 try: | 3081 try: |
3082 row = it.next(timeout=5) | 3082 row = it.next(timeout=5) |
3083 except multiprocessing.TimeoutError: | 3083 except multiprocessing.TimeoutError: |
3084 break | 3084 break |
3085 | 3085 |
3086 fetched_cls.add(row[0]) | 3086 fetched_cls.add(row[0]) |
(...skipping 2017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5104 if __name__ == '__main__': | 5104 if __name__ == '__main__': |
5105 # These affect sys.stdout so do it outside of main() to simplify mocks in | 5105 # These affect sys.stdout so do it outside of main() to simplify mocks in |
5106 # unit testing. | 5106 # unit testing. |
5107 fix_encoding.fix_encoding() | 5107 fix_encoding.fix_encoding() |
5108 setup_color.init() | 5108 setup_color.init() |
5109 try: | 5109 try: |
5110 sys.exit(main(sys.argv[1:])) | 5110 sys.exit(main(sys.argv[1:])) |
5111 except KeyboardInterrupt: | 5111 except KeyboardInterrupt: |
5112 sys.stderr.write('interrupted\n') | 5112 sys.stderr.write('interrupted\n') |
5113 sys.exit(1) | 5113 sys.exit(1) |
OLD | NEW |