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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>