git cl try: reduce number of RPCs to Gerrit from 3 to 1.
R=agable@chromium.org
BUG=681704
Change-Id: I3c0ab781e0357e0855d50157c5653df57f68ac9a
Reviewed-on: https://chromium-review.googlesource.com/432336
Reviewed-by: Aaron Gable <agable@chromium.org>
diff --git a/git_cl.py b/git_cl.py
index 8856fd7..839d2e5 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -463,11 +463,6 @@
http = authenticator.authorize(httplib2.Http())
http.force_exception_to_status_code = True
- # TODO(tandrii): consider caching Gerrit CL details just like
- # _RietveldChangelistImpl does, then caching values in these two variables
- # won't be necessary.
- owner_email = changelist.GetIssueOwner()
-
buildbucket_put_url = (
'https://{hostname}/_ah/api/buildbucket/v1/builds/batch'.format(
hostname=options.buildbucket_host))
@@ -498,7 +493,7 @@
parameters = {
'builder_name': builder,
'changes': [{
- 'author': {'email': owner_email},
+ 'author': {'email': changelist.GetIssueOwner()},
'revision': options.revision,
}],
'properties': shared_parameters_properties.copy(),
@@ -4722,6 +4717,10 @@
if not cl.GetIssue():
parser.error('Need to upload first')
+ if cl.IsGerrit():
+ # HACK: warm up Gerrit change detail cache to save on RPCs.
+ cl._codereview_impl._GetChangeDetail(['DETAILED_ACCOUNTS', 'ALL_REVISIONS'])
+
error_message = cl.CannotTriggerTryJobReason()
if error_message:
parser.error('Can\'t trigger try jobs: %s' % error_message)