| Index: git_cl.py
|
| diff --git a/git_cl.py b/git_cl.py
|
| index 1b375e856ca190fa4c7217cdfb30316f5c37a088..1a83c6de6b9821cdf529c22537c18319cfe209ea 100755
|
| --- a/git_cl.py
|
| +++ b/git_cl.py
|
| @@ -1328,6 +1328,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
|
| + 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.
|
| @@ -1377,41 +1420,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))
|
|
|