Chromium Code Reviews| Index: git_cl.py |
| diff --git a/git_cl.py b/git_cl.py |
| index bcd4a6252b018978cc860b3ebebf75dd6f197d54..4d97825f0f231775a29f8317d5d99e7f68eb0b48 100755 |
| --- a/git_cl.py |
| +++ b/git_cl.py |
| @@ -1338,6 +1338,49 @@ def color_for_status(status): |
| 'error': Fore.WHITE, |
| }.get(status, Fore.WHITE) |
| +def get_cl_statuses(branches, fast=False): |
| + """Returns a blocking Queue of (branch, issue, color) for provided branches. |
| + |
| + If fast is false, this will spawn len(branches) number of threads and fetch |
|
iannucci
2015/03/03 01:00:14
I think this is a bit misleading (and 'fast' is a
calamity
2015/03/03 04:58:12
Done. It spawns as many jobs as there are branches
|
| + the remote cl statuses. |
| + """ |
| + # Adhoc thread pool to request data concurrently. |
| + output = Queue.Queue() |
| + |
| + # Silence upload.py otherwise it becomes unweldly. |
| + upload.verbosity = 0 |
| + |
| + if not fast: |
| + def fetch(b): |
| + """Fetches information for an issue and returns (branch, issue, color).""" |
| + c = Changelist(branchref=b) |
| + i = c.GetIssueURL() |
| + status = c.GetStatus() |
| + color = color_for_status(status) |
| + |
| + if i and (not status or status == 'error'): |
| + # The issue probably doesn't exist anymore. |
| + i += ' (broken)' |
| + |
| + output.put((b, i, color)) |
| + |
| + # Process one branch synchronously to work through authentication, then |
| + # spawn threads to process all the other branches in parallel. |
| + if branches: |
| + fetch(branches[0]) |
| + threads = [ |
| + threading.Thread(target=fetch, args=(b,)) for b in branches[1:]] |
| + for t in threads: |
| + t.daemon = True |
| + t.start() |
| + else: |
| + # Do not use GetApprovingReviewers(), since it requires an HTTP request. |
| + for b in branches: |
| + c = Changelist(branchref=b) |
| + url = c.GetIssueURL() |
| + output.put((b, url, Fore.BLUE if url else Fore.WHITE)) |
| + |
| + return output |
| def CMDstatus(parser, args): |
| """Show status of changelists. |
| @@ -1387,41 +1430,7 @@ def CMDstatus(parser, args): |
| branches = [c.GetBranch() for c in changes] |
| alignment = max(5, max(len(b) for b in branches)) |
| print 'Branches associated with reviews:' |
| - # Adhoc thread pool to request data concurrently. |
| - output = Queue.Queue() |
| - |
| - # Silence upload.py otherwise it becomes unweldly. |
| - upload.verbosity = 0 |
| - |
| - if not options.fast: |
| - def fetch(b): |
| - """Fetches information for an issue and returns (branch, issue, color).""" |
| - c = Changelist(branchref=b) |
| - i = c.GetIssueURL() |
| - status = c.GetStatus() |
| - color = color_for_status(status) |
| - |
| - if i and (not status or status == 'error'): |
| - # The issue probably doesn't exist anymore. |
| - i += ' (broken)' |
| - |
| - output.put((b, i, color)) |
| - |
| - # Process one branch synchronously to work through authentication, then |
| - # spawn threads to process all the other branches in parallel. |
| - if branches: |
| - fetch(branches[0]) |
| - threads = [ |
| - threading.Thread(target=fetch, args=(b,)) for b in branches[1:]] |
| - for t in threads: |
| - t.daemon = True |
| - t.start() |
| - else: |
| - # Do not use GetApprovingReviewers(), since it requires an HTTP request. |
| - for b in branches: |
| - c = Changelist(branchref=b) |
| - url = c.GetIssueURL() |
| - output.put((b, url, Fore.BLUE if url else Fore.WHITE)) |
| + output = get_cl_statuses(branches, options.fast) |
| tmp = {} |
| alignment = max(5, max(len(ShortBranchName(b)) for b in branches)) |