Commit Graph

95 Commits (4403107f990858f9f1f0ce5d8ecd119bd191001d)

Author SHA1 Message Date
Raul Tambre 80ee78e7fa Convert print statements to Python 3 style
Ran "2to3 -w -n -f print ./" and manually added imports.
Ran "^\s*print " and "\s+print " to find batch/shell scripts, comments and the like with embedded code, and updated them manually.
Also manually added imports to files, which used print as a function, but were missing the import.

The scripts still work with Python 2.
There are no intended behaviour changes.

Bug: 942522
Change-Id: Id777e4d4df4adcdfdab1b18bde89f235ef491b9f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1595684
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@chromium.org>
Auto-Submit: Raul Tambre <raul@tambre.ee>
6 years ago
William Hesse e9e89e3aa5 Improve error message for missing gerrit credentials in git-cl.
Bug:
Change-Id: I058fcd85548c6e17f33de71ed2ad04549294e13d
R: dpranke@chromium.org, iannucci@chromium.org
Reviewed-on: https://chromium-review.googlesource.com/c/558250
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
6 years ago
Quinten Yearsley 0e617c0294 Change git cl comments to list robot comments.
In particular, only show robot comments from the latest patchset.

Bug: 924780
Change-Id: I12038ddd2d90a5cb561b248de3fd37908d5b927e
Reviewed-on: https://chromium-review.googlesource.com/c/1457282
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Quinten Yearsley <qyearsley@chromium.org>
6 years ago
Edward Lemur 687ca907fd git-cl: Set Code-Review label as a git push argument.
Bug: 877717
Change-Id: I6541a971068aae662b086eba84448bd0769f1a09
Reviewed-on: https://chromium-review.googlesource.com/c/1362405
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
6 years ago
Edward Lemur 49c8eafcd5 git-cl: Stop logging response headers on 404 Gerrit RPC status.
Bug: 881860
Change-Id: I96a1e8f3ed9fe032307b49d7a130d512e050369e
Reviewed-on: https://chromium-review.googlesource.com/c/1306013
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
6 years ago
Edward Lemur 5a9ff43554 git-cl: Report Gerrit RPC requests information.
Bug: 897394
Change-Id: I055e844299e262be81d5ac52ef24571b8fdfd47c
Reviewed-on: https://chromium-review.googlesource.com/c/1292245
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Andy Perelson <ajp@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
6 years ago
Edward Lemur b0b43f3a9e git-cl: Log response IP and host for Gerrit RPC failures.
Bug: 881860
Change-Id: I32a8c27ba912bf76feda86940c7f30a5462f527f
Reviewed-on: https://chromium-review.googlesource.com/c/1279128
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
6 years ago
Andrii Shyshkalov ba7b0a466d 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>
6 years ago
Andrii Shyshkalov 94faf3281c git cl upload: also explicitly use eu1 mirror for retries.
R=ehmaldonado

Bug: 881860
Change-Id: Ia02905a8b71486d771a691c31114d692e62a369f
Reviewed-on: https://chromium-review.googlesource.com/c/1277796
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
6 years ago
Edward Lemur 47faa068e8 git-cl: Make request to upload logs more visible.
Print the message asking the user to upload gerrit logs for git-cl upload
failures after the exception.

Also, initialize the error logger only for git-cl upload, so that the
headers are not overwritten unless git-cl upload is executed again.

Bug: 881860
Change-Id: I8e63432eecca5253e56096e3ad0218eec4058e12
Reviewed-on: https://chromium-review.googlesource.com/c/1277426
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
6 years ago
Edward Lemur 83bd7f4cd5 git-cl: Print response headers on 404 Gerrit RPC status.
And ask the user to report the printed headers to the bug.

Bug: 881860
Change-Id: I0a6cc0d90b4a721f72cd7eee4cba59934facbb1e
Reviewed-on: https://chromium-review.googlesource.com/c/1266837
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
6 years ago
Eric Boren 2fb6310237 Reland gerrit_util: Support OAuth2 bearer tokens in CookieAuthenticator
Bug: skia:8394
Change-Id: I928eaec8459a5905360ce760c6361e4554852b44
Reviewed-on: https://chromium-review.googlesource.com/c/1261796
Reviewed-by: Vadim Shtayura <vadimsh@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Eric Boren <borenet@chromium.org>
7 years ago
Vadim Shtayura b250ec16d3 [git_cl] Don't check .gitcookies when running on LUCI.
This CL basically replaces "skip if is_gce" with "skip if default auth method
is not gitcookies".

This presumable makes 'git cl' work on LUCI in a consistent manner. Before, it
worked only if the LUCI bot happened to also be GCE bot.

R=tandrii@chromium.org
BUG=891755

Change-Id: I2caa219a4082438a5e026e728bfb62f46a0c80fd
Reviewed-on: https://chromium-review.googlesource.com/c/1260053
Commit-Queue: Vadim Shtayura <vadimsh@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
7 years ago
Andrii Shyshkalov d4c867355a git cl: use explicit Gerrit mirrors on 404s during upload.
This will cycle through known gerrit mirrors for chromium-review host
if Gerrit HTTP RPC results in 404 after successful initial
git push refs/for/refs/...

Tested locally by intentionally using wrong change number (2000000):

    $ PATH=`pwd`:$PATH git cl upload --bypass-hooks
        ...
        remote: Processing changes: refs: 1, new: 1, done
        remote: SUCCESS
        remote: New Changes:
        remote:   https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1227440

                * [new branch]        ea9aea5faa -> refs/for/refs/heads/master%wip,m=Initial_upload,hashtag=git-cl

        WARNING:root:404 NotFound error occurred while querying POST https://chromium-review.googlesource.com/a/changes/chromium%2Ftools%2Fdepot_tools~2000000/revisions/current/review: Not Found
        WARNING:root:404 NotFound error occurred while querying POST https://ap1-mirror-chromium-review.googlesource.com/a/changes/chromium%2Ftools%2Fdepot_tools~2000000/revisions/current/review: Not Found
        WARNING:root:404 NotFound error occurred while querying POST https://us1-mirror-chromium-review.googlesource.com/a/changes/chromium%2Ftools%2Fdepot_tools~2000000/revisions/current/review: Not Found

        ^C

Bug: 881860
Change-Id: Iac7dbe4e35052007650a7a2646a394caed6bd400
Reviewed-on: https://chromium-review.googlesource.com/1227441
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
7 years ago
Andy Perelson a06cd091a9 Revert "git cl upload: print response headers on 404 Gerrit RPC status."
This reverts commit ea4301e5c5. We now have many
reponse headers, stopping contributions until and unless we are asked for more
as part of debugging git cl upload issues.

R=tandrii@chromium.org

Bug: 881860
Change-Id: Ic3524aa93f146cebd882efe30b2e3f110cf74838
Reviewed-on: https://chromium-review.googlesource.com/1241613
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Andy Perelson <ajp@chromium.org>
7 years ago
Andrii Shyshkalov 86c823e88d gerrit_util: document hack.
R=ajp@chromium.org

Bug: 881860
Change-Id: I2608132730cf907ea5bb86476490eafc37e24275
Reviewed-on: https://chromium-review.googlesource.com/1227438
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
7 years ago
Eric Boren 0526335226 Revert "gerrit_util: Support OAuth2 bearer tokens in CookieAuthenticator"
This reverts commit 18b4479cee.

Reason for revert: Breaking WebRTC roller: https://luci-milo.appspot.com/buildbot/client.webrtc.fyi/Auto-roll%20-%20WebRTC%20DEPS/12788

Original change's description:
> gerrit_util: Support OAuth2 bearer tokens in CookieAuthenticator
> 
> Change-Id: I9fd3e2fa9ea16d7f057290e77a81f7009c7c9d91
> Reviewed-on: https://chromium-review.googlesource.com/1221826
> Reviewed-by: Vadim Shtayura <vadimsh@chromium.org>
> Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
> Commit-Queue: Eric Boren <borenet@chromium.org>

TBR=vadimsh@chromium.org,dnj@chromium.org,borenet@chromium.org,tandrii@chromium.org

Change-Id: I93bbd2d09cd2b27d9a7aa98fc15d60c5033a38cd
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/1231433
Reviewed-by: Eric Boren <borenet@chromium.org>
Commit-Queue: Eric Boren <borenet@chromium.org>
7 years ago
Eric Boren 18b4479cee gerrit_util: Support OAuth2 bearer tokens in CookieAuthenticator
Change-Id: I9fd3e2fa9ea16d7f057290e77a81f7009c7c9d91
Reviewed-on: https://chromium-review.googlesource.com/1221826
Reviewed-by: Vadim Shtayura <vadimsh@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Eric Boren <borenet@chromium.org>
7 years ago
Andrii Shyshkalov ea4301e5c5 git cl upload: print response headers on 404 Gerrit RPC status.
R=ajp@chromium.org

Bug: 881860
Change-Id: I2a5fc981fce05664ea077cad74458bc38c37f1e7
Reviewed-on: https://chromium-review.googlesource.com/1227439
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Auto-Submit: Andrii Shyshkalov <tandrii@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
7 years ago
Steve Kobes 5611772056 Increase gerrit_util retry count and delay.
Bug: 881860
Change-Id: I6402ff2665b70b46558799dbb16ac9c7a9d7d640
Reviewed-on: https://chromium-review.googlesource.com/1224990
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Steve Kobes <skobes@chromium.org>
7 years ago
Andrii Shyshkalov 0ec9d15571 git cl: use project~number on Gerrit for better routing when setting reviewers
R=ehmaldonado@chromium.org

Testing
  patched my own depot_tools in $PATH and uploaded
  https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1186072
  which set reviewers and ccs as expected.

Bug: 876910
Change-Id: I43c0f2284941cf703133bb51132226d4a0472d8e
Reviewed-on: https://chromium-review.googlesource.com/1186068
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
7 years ago
Sylvain Defresne 2b138f742b Avoid creating an empty netrc file in $TEMP
The code to load .netrc file copies it to a temporary file
named $TEMP/XXXXXXXXXgerrit_util/netrc before loading it
to workaround crbug.com/664664.

However, using a netrc file is deprecated (in favor of a
gitcookies file instead) so most of the time, the file is
empty. Instead of creating an empty file, load data from
/dev/null (named os.devnull).

This avoid leaving an empty file lying around (since the
temporary file is not deleted), and avoid race-conditions
on Windows when multiple processes/threads try to create
the same file.

Bug: none
Change-Id: I873b72402038ca3f0d32387353dc89b731aaa927
Reviewed-on: https://chromium-review.googlesource.com/1132998
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Reviewed-by: Ryan Tseng <hinoka@chromium.org>
7 years ago
Michael Moss 120b2e4f26 Add gerrit retries for HTTP 409 Conflict responses.
BUG=crbug.com/854886,b/110032771
R=tandrii@google.com

Change-Id: Iabd67f8042ab3bc7c6ef15101effeeebf39d4500
Reviewed-on: https://chromium-review.googlesource.com/1111007
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Michael Moss <mmoss@chromium.org>
7 years ago
Andrii Shyshkalov 733d4ec8e3 [gerrit_util] learn about and use LUCI_CONTEXT when available.
Unfortunately, w/o rewrite of gerrit_util, one can't take advantage
of existing auth.Authenticator (which also doesn't know about ~/.netrc
or .gitcookies, but that's fixable). This rewrite, however, will likely
cause issues for nasty scripts outside of depot_tools which use
gerrit_util as a Python library. So, I followed outdated way of
gerrit_util :(

Also contains refactoring of auth library, which was kept backwards
compatible for the same reasons as above.

R=vadimsh@chromium.org

Test-with: led tool
Test-artifact: https://ci.chromium.org/swarming/task/3cf4687dfd26ca10?server=chromium-swarm.appspot.com
Bug: 834536
Change-Id: I6b84b8b5732aee5d345e2b2ba44f47aaecc0f6c5
Reviewed-on: https://chromium-review.googlesource.com/1018488
Reviewed-by: Vadim Shtayura <vadimsh@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
7 years ago
Sergio Villar Senin 0d466d22d8 git cl believes I'm working inside GCE
Looks like the error codes issued by python's http library might vary
between versions/distros. The code tries to reach an URL which is only valid
inside GCE and in the event of getting an error it assumes the user is
a non-googler.

At least in this case, we're seeing:

  third_party.httplib2.socks.HTTPError: (404, 'No such domain')

Adding this exception type allows the function to work correctly.

Change-Id: I08d3656b25d9046f8b2fc0da2a2b7c7a698c1d92
Reviewed-on: https://chromium-review.googlesource.com/978212
Commit-Queue: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
7 years ago
Aaron Gable 8797cab3ef git-cl: respect http.cookieFile for finding gitcookies
This allows people to configure their gitcookies file to be
whereever they want. As long as it actually exists and has
credentials in it, we'll accept it, just like git itself.

Change-Id: I4aa4806ddca0e61b28b003b0d3bc486407c13ab4
Reviewed-on: https://chromium-review.googlesource.com/951917
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>
7 years ago
Aaron Gable 92e9f38865 gerrit_util: Slightly modify retry backoff behavior
This is a bandaid (over Gerrit's replication lag), but hopefully
this will increase the likelihood of success and improve the
messaging around retries at the same time.

R=tandrii

Bug: 792679
Change-Id: Ia6e3133cc23ea9b2abfeacc05750c002f8804e8b
Reviewed-on: https://chromium-review.googlesource.com/812564
Commit-Queue: Aaron Gable <agable@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
7 years ago
Jonathan Nieder 1ea21322e3 Do not delete users' draft comments
Gerrit's "Set Review" API has a built-in trap:

 drafts (optional)
	How draft comments are handled that are already in the
	database but that were not also described in this input.

	Allowed values are DELETE, PUBLISH, PUBLISH_ALL_REVISIONS and
	KEEP. All values except PUBLISH_ALL_REVISIONS operate only on
	drafts for a single revision.

	If not set, the default is DELETE.

That destructive default is almost never what a person wants.  Use
KEEP instead.

Noticed because "git cl try" was losing people's comments.

Bug: gerrit:6812
Change-Id: I1d09231ea23b13c925d301241bef266df2ddf1cf
Reviewed-on: https://chromium-review.googlesource.com/764488
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Jonathan Nieder <jrn@google.com>
7 years ago
Nick Carter 8692b18870 Allow punctuation in patch set titles by means of percent encoding.
Bug: 663787
Change-Id: Ie7e2fca42db0c840d713dc6edba5dc0c2b65223d
Reviewed-on: https://chromium-review.googlesource.com/676086
Reviewed-by: Aaron Gable <agable@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Nick Carter <nick@chromium.org>
7 years ago
Michael Moss b40a45149a Allow specifying alternative "success" codes in gitiles requests.
This is needed in the release recipes because there are times when we
want to check that a file is _not_ there yet (i.e. 404 response).

R=agable@chromium.org, dnj@chromium.org

Change-Id: Iedf646d6c73ebf898e90afd2009840b1e5c5b1ab
Reviewed-on: https://chromium-review.googlesource.com/709916
Reviewed-by: Paweł Hajdan Jr. <phajdan.jr@chromium.org>
Commit-Queue: Michael Moss <mmoss@chromium.org>
7 years ago
Aaron Gable 5a4ef4537e Don't send email from git-cl-description
The 'notify' parameter was accidentally left out in
https://crrev.com/c/544118. The calling code in git_cl.py
already sets notify='NONE', so this will suppress all
notifications as before.

Bug: 757617
Change-Id: Ib0144d644d54b194fac0c0eb2fb51a6affa3340e
Reviewed-on: https://chromium-review.googlesource.com/634245
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>
8 years ago
smut 5e9401b7e6 Use fully qualified URL to GCE metadata server
The http://metadata shortcut only works on Linux, Windows requires
https://metadata.google.internal.

Bug: 738255
Change-Id: I06b6c34761bbee9912a8cd2a65ab43b3ae230f07
Reviewed-on: https://chromium-review.googlesource.com/611245
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: smut <smut@google.com>
8 years ago
Sergey Berezin e866182f33 depot_tools: Fix executable bit for gerrit_*.py
BUG=628259
TBR=agable@chromium.org

Change-Id: I79bd59bb922d70c59a42ec09f153e9c9220fd9bb
Reviewed-on: https://chromium-review.googlesource.com/599362
Reviewed-by: Sergey Berezin <sergeyberezin@chromium.org>
Commit-Queue: Sergey Berezin <sergeyberezin@chromium.org>
8 years ago
Aaron Gable fc62f76824 Simplify notify behavior in git-cl
Change-Id: I872658970c04cdadda2b0eaffd95e10717c09493
Reviewed-on: https://chromium-review.googlesource.com/575009
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>
8 years ago
Aaron Gable 636b13fc3d Let Changelist().AddComment() mark changes as Ready
In Rietveld, adding a comment to a change automatically
published it no matter what. In Gerrit, we need to explicitly
mark the change as Ready for Review. This CL adds a new
parameter to the wrapper methods around the SetReview
API so that they can mark changes as Ready.

Bug: 740950
Change-Id: Icb2ad7c5beb03a4760657a761841745f0d75514e
Reviewed-on: https://chromium-review.googlesource.com/572031
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>
8 years ago
Andrii Shyshkalov c81738256b git cl creds-check: improve report and give better recommendation.
R=machenbach@chromium.org,agable@chromium.org
Bug: N/A
Change-Id: I831e9e72c8687c248022f49ea405e149538ef02a
Reviewed-on: https://chromium-review.googlesource.com/563671
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Aaron Gable <agable@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
8 years ago
Michael Achenbach 6fbf12f21c Enable query for changes in gerrit recipe module
This'll allow to query gerrit from recipes for e.g. current changes in
CQ.

Bug: 685318
Change-Id: I73d08d4b186b2e5fe044fd4d4fafd9db62e27066
Reviewed-on: https://chromium-review.googlesource.com/558939
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Reviewed-by: Aaron Gable <agable@chromium.org>
8 years ago
Aaron Gable 7625d880d7 git-cl-description: use atomic edit API
https://gerrit-review.googlesource.com/c/110057/ has been deployed,
so this change can now take advantage of that new API to make
git-cl-description more reliable.

Both the API to add content to a change edit and to publish a
change edit return '204 No Content' on a successful call, but this
API returns 200. It seems likely to me that one or the other will
change, so this calling code accepts both codes for future-proofness.

Bug: gerrit:5099
Change-Id: I14d5323f92c807036f8aa11b314d10706c51dbf5
Reviewed-on: https://chromium-review.googlesource.com/544118
Commit-Queue: Aaron Gable <agable@chromium.org>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
8 years ago
Aaron Gable 75e7872acf Convert notify parameter inside gerrit_util
Bug: skia:6744
Change-Id: I0f84bd685bfacf692190f8636208122cf88d0b82
Reviewed-on: https://chromium-review.googlesource.com/529016
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>
8 years ago
Aaron Gable 0ffdf2de15 git-cl-comments: Support Gerrit file- and line-comments
This brings the gerrit version of "git cl comments" into line
with the Rietveld implementation by including file- and line-level
comments as well as top-level review comments. It requires an
extra API call to do so, so this may result in some slow-down, but
the result is worth it.

It formats the comments to match the formatting used in the
PolyGerrit UI, with the addition of visible URLs linking to
the comment since we can't hyperlink text in the terminal.

This CL also causes it to ignore messages and comments with
the 'autogenerated' tag, which are generally less interesting
and clutter the output.

Bug: 726514
Change-Id: I1fd939d90259b43886ddc209c0e727eab36cc9c9
Reviewed-on: https://chromium-review.googlesource.com/520722
Commit-Queue: Aaron Gable <agable@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
8 years ago
Wiktor Garbacz 6d0d04458d git-cl-upload: Fix reviewers notification with --no-squash.
Using --no-squash resulted in an exception being thrown, because issue
number is not set in that case.

Change-Id: Iaf0d7eb05851eba0d5231640c077b845bca486ee
Reviewed-on: https://chromium-review.googlesource.com/505509
Reviewed-by: Aaron Gable <agable@chromium.org>
Commit-Queue: Wiktor Garbacz <wiktorg@google.com>
8 years ago
Aaron Gable 62ca960a5f gerrit_util: retry on 404s for replication lag
We usually only retry on server errors. But most 404s that
clients will recieve are due to replication lag, not due to
querying an issue that truly doesn't exist. This CL lets
gerrit_util (which is used primarily by git-cl) to retry on
404s to help fight errors due to replication lag.

R=tandrii@chromium.org

Bug: 717197
Change-Id: I26dbbf6c4895a13f7d57e4be3c23450111c949bc
Reviewed-on: https://chromium-review.googlesource.com/510000
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>
8 years ago
Aaron Gable 6dadfbfcf7 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>
8 years ago
Aaron Gable 20d2cbb8f5 gerrit_util: Fix name of conn object data member
R=tandrii@chromium.org

Bug: 715072
Change-Id: Ia34d406e0c0065b9e12cb6595534173d75241e9a
Reviewed-on: https://chromium-review.googlesource.com/487046
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>
8 years ago
dimu 7d1af2b930 Fix the accept_status code for create_gerrit_branch
- gerrit create branch endpoint returns code 201 instead of 200

Bug:
R=agable

Change-Id: I07697e87e506d5545e9abd501775e0fc30a48f80
Reviewed-on: https://chromium-review.googlesource.com/482522
Reviewed-by: Aaron Gable <agable@chromium.org>
Commit-Queue: Di Mu <dimu@chromium.org>
8 years ago
Aaron Gable 6f5a8d9987 Flip gerrit_util to raise exceptions on 404 by default
This makes the library behave more like what we'd expect,
while still allowing certain function to specify that
returning 204 or 404 is expected/acceptable behavior.

Change-Id: If3ce5598d1603819ee97aaeab0072a9e786ed96d
Reviewed-on: https://chromium-review.googlesource.com/481043
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>
8 years ago
Aaron Gable 19ee16c860 Reland "Refactor ReadHttpResponse to be error-friendlier"
Gerrit sometimes returns a full response json object at
the same time as returning a non-200 status code. This
refactor makes it easier for calling code to request
access to that object and handle error cases on its own.

The original version of this commit had a bug where
ReadHttpResponse properly set the default value for
accept_statuses, but all calls which came through
ReadHttpJsonResponse were setting None instead.

Bug: 710028
Change-Id: I8cee435d8acd487fb777b3fd69b5e48e19d2e5a3
Reviewed-on: https://chromium-review.googlesource.com/481060
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>
8 years ago
Aaron Gable 382674be12 Revert "Refactor ReadHttpResponse to be error-friendlier"
This reverts commit 6d7ab1bfe5.

Reason for revert: Stacktrace:
 File "/s/depot_tools/gerrit_util.py", line 816, in GetAccountDetails
   return ReadHttpJsonResponse(conn)
 File "/s/depot_tools/gerrit_util.py", line 376, in ReadHttpJsonResponse
   fh = ReadHttpResponse(conn, accept_statuses)
 File "/s/depot_tools/gerrit_util.py", line 365, in ReadHttpResponse
   if response.status not in accept_statuses:
TypeError: argument of type 'NoneType' is not iterable

Original change's description:
> Refactor ReadHttpResponse to be error-friendlier
> 
> Gerrit sometimes returns a full response json object at
> the same time as returning a non-200 status code. This
> refactor makes it easier for calling code to request
> access to that object and handle error cases on its own.
> 
> Bug: 710028
> Change-Id: Id1017d580d2fb843d5ca6287efcfed8775c52cd6
> Reviewed-on: https://chromium-review.googlesource.com/479450
> Commit-Queue: Aaron Gable <agable@chromium.org>
> Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
> 

TBR=agable@chromium.org,tandrii@chromium.org,chromium-reviews@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true

Change-Id: Ia9d9ce835e207a32e7cc8ee35c0cf40c823c7b78
Reviewed-on: https://chromium-review.googlesource.com/481059
Reviewed-by: Aaron Gable <agable@chromium.org>
Commit-Queue: Aaron Gable <agable@chromium.org>
8 years ago
Aaron Gable 6d7ab1bfe5 Refactor ReadHttpResponse to be error-friendlier
Gerrit sometimes returns a full response json object at
the same time as returning a non-200 status code. This
refactor makes it easier for calling code to request
access to that object and handle error cases on its own.

Bug: 710028
Change-Id: Id1017d580d2fb843d5ca6287efcfed8775c52cd6
Reviewed-on: https://chromium-review.googlesource.com/479450
Commit-Queue: Aaron Gable <agable@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
8 years ago
Andrii Shyshkalov 4956f798fb git cl: suggest git cl creds-check if Gerrit API returns 401.
R=sergiyb@chromium.org
BUG=708785

Change-Id: Id25d3ef9a1449a0c259ed48b782e1b766e1a5fc9
Reviewed-on: https://chromium-review.googlesource.com/472906
Reviewed-by: Sergiy Byelozyorov <sergiyb@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
8 years ago