git cl: find which reviewers and ccs are OK for Gerrit before upload.

This adds O(reviewers+cc) RPC to Gerrit before upload,
though done concurrently in up to 10 threads. This information isn't
used yet, but will be in follow up CLs.

R=ehmaldonado

Bug: 877717
Change-Id: I2374f249ee874a71089244309e50e8e88a3dee7d
Reviewed-on: https://chromium-review.googlesource.com/c/1242847
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index 1fc3139..24be0eb 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -3122,7 +3122,6 @@
       change_desc.update_reviewers(options.reviewers, options.tbrs,
                                    options.add_owners_to, change)
 
-    # TODO(tandrii): process reviewers and ccs into refspec.
     reviewers = sorted(change_desc.get_reviewers())
     # Add cc's from the CC_LIST and --cc flag (if any).
     if not options.private and not options.no_autocc:
@@ -3134,6 +3133,11 @@
     cc = filter(None, [email.strip() for email in cc])
     if change_desc.get_cced():
       cc.extend(change_desc.get_cced())
+    valid_accounts = gerrit_util.ValidAccounts(
+        self._GetGerritHost(), reviewers + cc)
+    logging.debug('accounts %s are valid, %s invalid', sorted(valid_accounts),
+                   set(reviewers + cc).difference(set(valid_accounts)))
+    # TODO(tandrii): add valid reviwers and ccs to push option.
 
     # Extra options that can be specified at push time. Doc:
     # https://gerrit-review.googlesource.com/Documentation/user-upload.html