Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(186)

Unified Diff: git_cl.py

Issue 938583002: Make git-map-branches -vvv show CL status colors. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: rebase, address comment, remove unused var Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | git_map_branches.py » ('j') | git_map_branches.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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))
« no previous file with comments | « no previous file | git_map_branches.py » ('j') | git_map_branches.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698