|
|
@ -17,9 +17,11 @@ import json
|
|
|
|
import logging
|
|
|
|
import logging
|
|
|
|
import optparse
|
|
|
|
import optparse
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
|
|
|
|
import Queue
|
|
|
|
import re
|
|
|
|
import re
|
|
|
|
import stat
|
|
|
|
import stat
|
|
|
|
import sys
|
|
|
|
import sys
|
|
|
|
|
|
|
|
import tempfile
|
|
|
|
import textwrap
|
|
|
|
import textwrap
|
|
|
|
import time
|
|
|
|
import time
|
|
|
|
import traceback
|
|
|
|
import traceback
|
|
|
@ -2899,8 +2901,20 @@ def color_for_status(status):
|
|
|
|
'error': Fore.WHITE,
|
|
|
|
'error': Fore.WHITE,
|
|
|
|
}.get(status, Fore.WHITE)
|
|
|
|
}.get(status, Fore.WHITE)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def fetch_cl_status(branch, auth_config=None):
|
|
|
|
|
|
|
|
"""Fetches information for an issue and returns (branch, issue, status)."""
|
|
|
|
|
|
|
|
cl = Changelist(branchref=branch, auth_config=auth_config)
|
|
|
|
|
|
|
|
url = cl.GetIssueURL()
|
|
|
|
|
|
|
|
status = cl.GetStatus()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if url and (not status or status == 'error'):
|
|
|
|
|
|
|
|
# The issue probably doesn't exist anymore.
|
|
|
|
|
|
|
|
url += ' (broken)'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (branch, url, status)
|
|
|
|
|
|
|
|
|
|
|
|
def get_cl_statuses(
|
|
|
|
def get_cl_statuses(
|
|
|
|
changes, fine_grained, max_processes=None):
|
|
|
|
branches, fine_grained, max_processes=None, auth_config=None):
|
|
|
|
"""Returns a blocking iterable of (branch, issue, color) for given branches.
|
|
|
|
"""Returns a blocking iterable of (branch, issue, color) for given branches.
|
|
|
|
|
|
|
|
|
|
|
|
If fine_grained is true, this will fetch CL statuses from the server.
|
|
|
|
If fine_grained is true, this will fetch CL statuses from the server.
|
|
|
@ -2916,21 +2930,23 @@ def get_cl_statuses(
|
|
|
|
if fine_grained:
|
|
|
|
if fine_grained:
|
|
|
|
# Process one branch synchronously to work through authentication, then
|
|
|
|
# Process one branch synchronously to work through authentication, then
|
|
|
|
# spawn processes to process all the other branches in parallel.
|
|
|
|
# spawn processes to process all the other branches in parallel.
|
|
|
|
if changes:
|
|
|
|
if branches:
|
|
|
|
fetch = lambda cl: (cl, cl.GetStatus())
|
|
|
|
fetch = lambda branch: fetch_cl_status(branch, auth_config=auth_config)
|
|
|
|
yield fetch(changes[0])
|
|
|
|
yield fetch(branches[0])
|
|
|
|
|
|
|
|
|
|
|
|
changes_to_fetch = changes[1:]
|
|
|
|
branches_to_fetch = branches[1:]
|
|
|
|
pool = ThreadPool(
|
|
|
|
pool = ThreadPool(
|
|
|
|
min(max_processes, len(changes_to_fetch))
|
|
|
|
min(max_processes, len(branches_to_fetch))
|
|
|
|
if max_processes is not None
|
|
|
|
if max_processes is not None
|
|
|
|
else len(changes_to_fetch))
|
|
|
|
else len(branches_to_fetch))
|
|
|
|
for x in pool.imap_unordered(fetch, changes_to_fetch):
|
|
|
|
for x in pool.imap_unordered(fetch, branches_to_fetch):
|
|
|
|
yield x
|
|
|
|
yield x
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
# Do not use GetApprovingReviewers(), since it requires an HTTP request.
|
|
|
|
# Do not use GetApprovingReviewers(), since it requires an HTTP request.
|
|
|
|
for cl in changes:
|
|
|
|
for b in branches:
|
|
|
|
yield (cl, 'waiting' if cl.GetIssueURL() else 'error')
|
|
|
|
cl = Changelist(branchref=b, auth_config=auth_config)
|
|
|
|
|
|
|
|
url = cl.GetIssueURL()
|
|
|
|
|
|
|
|
yield (b, url, 'waiting' if url else 'error')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def upload_branch_deps(cl, args):
|
|
|
|
def upload_branch_deps(cl, args):
|
|
|
@ -3083,27 +3099,25 @@ def CMDstatus(parser, args):
|
|
|
|
print('No local branch found.')
|
|
|
|
print('No local branch found.')
|
|
|
|
return 0
|
|
|
|
return 0
|
|
|
|
|
|
|
|
|
|
|
|
changes = [
|
|
|
|
changes = (
|
|
|
|
Changelist(branchref=b, auth_config=auth_config)
|
|
|
|
Changelist(branchref=b, auth_config=auth_config)
|
|
|
|
for b in branches.splitlines()]
|
|
|
|
for b in branches.splitlines())
|
|
|
|
|
|
|
|
# TODO(tandrii): refactor to use CLs list instead of branches list.
|
|
|
|
|
|
|
|
branches = [c.GetBranch() for c in changes]
|
|
|
|
|
|
|
|
alignment = max(5, max(len(b) for b in branches))
|
|
|
|
print 'Branches associated with reviews:'
|
|
|
|
print 'Branches associated with reviews:'
|
|
|
|
output = get_cl_statuses(changes,
|
|
|
|
output = get_cl_statuses(branches,
|
|
|
|
fine_grained=not options.fast,
|
|
|
|
fine_grained=not options.fast,
|
|
|
|
max_processes=options.maxjobs)
|
|
|
|
max_processes=options.maxjobs,
|
|
|
|
|
|
|
|
auth_config=auth_config)
|
|
|
|
|
|
|
|
|
|
|
|
branch_statuses = {}
|
|
|
|
branch_statuses = {}
|
|
|
|
alignment = max(5, max(len(ShortBranchName(c.GetBranch())) for c in changes))
|
|
|
|
alignment = max(5, max(len(ShortBranchName(b)) for b in branches))
|
|
|
|
for cl in sorted(changes, key=lambda c: c.GetBranch()):
|
|
|
|
for branch in sorted(branches):
|
|
|
|
branch = cl.GetBranch()
|
|
|
|
|
|
|
|
while branch not in branch_statuses:
|
|
|
|
while branch not in branch_statuses:
|
|
|
|
c, status = output.next()
|
|
|
|
b, i, status = output.next()
|
|
|
|
branch_statuses[c.GetBranch()] = status
|
|
|
|
branch_statuses[b] = (i, status)
|
|
|
|
status = branch_statuses.pop(branch)
|
|
|
|
issue_url, status = branch_statuses.pop(branch)
|
|
|
|
url = cl.GetIssueURL()
|
|
|
|
|
|
|
|
if url and (not status or status == 'error'):
|
|
|
|
|
|
|
|
# The issue probably doesn't exist anymore.
|
|
|
|
|
|
|
|
url += ' (broken)'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
color = color_for_status(status)
|
|
|
|
color = color_for_status(status)
|
|
|
|
reset = Fore.RESET
|
|
|
|
reset = Fore.RESET
|
|
|
|
if not setup_color.IS_TTY:
|
|
|
|
if not setup_color.IS_TTY:
|
|
|
@ -3111,8 +3125,8 @@ def CMDstatus(parser, args):
|
|
|
|
reset = ''
|
|
|
|
reset = ''
|
|
|
|
status_str = '(%s)' % status if status else ''
|
|
|
|
status_str = '(%s)' % status if status else ''
|
|
|
|
print ' %*s : %s%s %s%s' % (
|
|
|
|
print ' %*s : %s%s %s%s' % (
|
|
|
|
alignment, ShortBranchName(branch), color, url,
|
|
|
|
alignment, ShortBranchName(branch), color, issue_url, status_str,
|
|
|
|
status_str, reset)
|
|
|
|
reset)
|
|
|
|
|
|
|
|
|
|
|
|
cl = Changelist(auth_config=auth_config)
|
|
|
|
cl = Changelist(auth_config=auth_config)
|
|
|
|
print
|
|
|
|
print
|
|
|
|