git-cl-upload: Set all reviewers and ccs in a single batch api call
The old system had two faults:
* It set reviewers and ccs via different mechanisms, which is confusing
* It set CCs with a single call for each, resulting in N separate emails,
with each email going to the uploader and all reviewers and all previous
CCs.
This new system just collects all reviewers and CCs, and sets them
in a single call. That call will fail if *any* of the individual
reviewers or ccs fail, so it also parses the response and retries with
only the ones which would have succeeded on their own. If that second
call fails, or the first fails in an unexpected way, it raises an
exception like normal
Bug: 710028
Change-Id: I1be508487a41f0b68f9c41908229b8f5342830a3
Reviewed-on: https://chromium-review.googlesource.com/479712
Commit-Queue: Aaron Gable <agable@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py
index a1a1952..95d75d1 100755
--- a/tests/git_cl_test.py
+++ b/tests/git_cl_test.py
@@ -594,8 +594,8 @@
lambda *args, **kwargs: self._mocked_call(
'GetChangeDetail', *args, **kwargs))
self.mock(git_cl.gerrit_util, 'AddReviewers',
- lambda h, i, add, is_reviewer, notify: self._mocked_call(
- 'AddReviewers', h, i, add, is_reviewer, notify))
+ lambda h, i, reviewers, ccs, notify: self._mocked_call(
+ 'AddReviewers', h, i, reviewers, ccs, notify))
self.mock(git_cl.gerrit_util.GceAuthenticator, 'is_gce',
classmethod(lambda _: False))
self.mock(git_cl, 'DieWithError',
@@ -1515,16 +1515,12 @@
else:
ref_suffix = '%m=' + title
- notify_suffix = 'notify=%s' % ('ALL' if notify else 'NONE')
+ notify_suffix = 'notify=NONE'
if ref_suffix:
ref_suffix += ',' + notify_suffix
else:
ref_suffix = '%' + notify_suffix
- if reviewers:
- ref_suffix += ',' + ','.join('r=%s' % email
- for email in sorted(reviewers))
-
if git_mirror is None:
calls += [
((['git', 'config', 'remote.origin.url'],),
@@ -1571,8 +1567,8 @@
calls += [
((['git', 'config', 'rietveld.cc'],), ''),
(('AddReviewers', 'chromium-review.googlesource.com',
- 123456 if squash else None,
- ['joe@example.com'] + cc, False, notify), ''),
+ 123456 if squash else None, sorted(reviewers),
+ ['joe@example.com'] + cc, notify), ''),
]
calls += cls._git_post_upload_calls()
return calls