ast.Str et al. have been deprecated since Py3.8 and have been
completely removed in 3.14. Replace their usage with ast.Constant.
This change should not have any functional impact, since
according to [1]:
> Changed in version 3.8: Class ast.Constant is now used for
> all constants.
> Deprecated since version 3.8: Old classes ast.Num, ast.Str,
> [...] instantiating them will return an instance of a
> different class.
[1] https://docs.python.org/3/library/ast.html
Bug: 40283283
Change-Id: I0ed8ef3910f921483bff118976f516c5a935e0fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7228507
Reviewed-by: Gavin Mak <gavinmak@google.com>
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: jj <jj@chromium.org>
This updates _EnabledTurboCiCheckHandler.set_result so that it adds a
BotUpdateResults when finalizing the associated source check. This
result provides information about all of the unpatched revisions that
were checked out.
Bug: b:443496677
Change-Id: I5ea0f798ef720e02fa130ec108a44d273187d964
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7227736
Reviewed-by: Robbie Iannucci <iannucci@google.com>
Commit-Queue: Garrett Beaty <gbeaty@google.com>
This adds a script for updating the depot_tools protos and imports the
initial version. This provides the BotUpdateResults type for reporting
the revisions that were checked out by bot_update in its associated
source check.
Bug: b:443496677
Change-Id: I8b67dcf1419c48f2a684c59c265fbe1caa9f0d43
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7227735
Reviewed-by: Robbie Iannucci <iannucci@google.com>
Commit-Queue: Robbie Iannucci <iannucci@google.com>
Auto-Submit: Garrett Beaty <gbeaty@google.com>
This setting ensures that bot_update/gclient will delete conflicting
directories instead of moving them to _bad_scm, which avoids wasting
disk space on bots.
Recipe-Nontrivial-Roll: build
Recipe-Nontrivial-Roll: build_internal
Recipe-Nontrivial-Roll: chrome_release
Recipe-Nontrivial-Roll: chromiumos
Recipe-Nontrivial-Roll: infra
Bug: 462013257
Change-Id: I247427179205bf22bd24d142fa851d6628846a48
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7208105
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Reviewed-by: Junji Watanabe <jwata@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
crrev.com/c/7152830 overhauled how the bot_update output json was
generated but neglected to handle the ref:revision syntax and
crrev.com/c/7147310 added a test data method to enable overriding the
URLs returned for the repos but neglected to actually pass it to the
output_json method. This change rectifies both issues.
Change-Id: I604b0d7ff3f7e68e4829624e5de66efa2f5a61b0
Recipe-Nontrivial-Roll: build
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7219689
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Garrett Beaty <gbeaty@google.com>
This adds and fixes documentation for the TurboCI check handler types
and the turboci_check_id parameter to bot_update.ensure_checkout.
Additionally, the gclient_config to _TurboCICheckHandler.create and
_EnabledTurboCiCheckHandler.__init__ was removed because the gclient
config wasn't being used.
Bug: b:443496677
Change-Id: I4acc3170522735e63062bed47f555aabcd2a4304
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7172970
Auto-Submit: Garrett Beaty <gbeaty@google.com>
Commit-Queue: Garrett Beaty <gbeaty@google.com>
Reviewed-by: Robbie Iannucci <iannucci@google.com>
Refactor GetCommentsSummary to group individual comments into threads. A
thread is considered unresolved if and only if its last comment is
unresolved.
This fixes a bug where a resolved thread (one that had been replied to
and the resolved box checked in the reply) would still appear with the
--unresolved flag, because the initial comment in the thread is
permanently marked as unresolved.
This change also introduces a CommentInfo dataclass to improve
ergonomics for handling comment data from the Gerrit API.
The display of comments have not been made thread-aware to reduce the
scope of this change.
R=agrieve@chromium.org
Bug: 463411949
Fixed: 463411949
Change-Id: I966f011140ee3874b54d8afbbe00caed7bbe14eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7200823
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Auto-Submit: Peter Wen <wnwen@chromium.org>
Commit-Queue: Peter Wen <wnwen@chromium.org>
The presubmit format validation hook and git cl format is given or
generate a patch such that they check/format the modified lines only.
The context lines matter because the diff parsers extract the line
numbers and length from the diffs, which include the context lines,
if included. For instance, if a patch is generated with -U3,
the presubmit hook actually verifies the format of not only the changed
lines but also the context lines. Therefore, it's important to make sure
that all the diff(s) commands use the same -U to ensure that they check
and format the same lines.
crrev.com/c/6952890 was submitted to match the context line numbers.
However, it was missing one case. The Chromium Cider extension also
generates the diff but with -U3. Therefore, cl/834917755 was made
to have it generating patches with -U0.
Another issue is that "git apply" fails by default if a given patch
was generated with -U0. It expects context lines in case a user tries
to apply a patch into a different commit so that it could adjust
the patches and applies even if the location of the corresponding,
original block has changed in the file to apply the patch.
However, the scenario of smartly modifying the patch to make it
applicable to as many commits as possible is not applicable to
depot_tools' case. The patch is not made to be shared with others.
It's generated instantly for a specific, base commit and applies it
to the current commit.
"--unidiff-zero" is the option to allow patches even if it was
generated with -U0. It's fine to use the option because the smart
patch adjustment is not applicable to our use cases.
This CL adds the option to _ProvidedDiffCache() so that it is
happy with the patch generated with -U0. The reason why the other
functionalities have been working, even though crrev.com/c/6952890
changed the context option to -U0 is that other logic doesn't use
`git apply`. They just parse the hunks and use the numbers.
Bug: 458442277
Change-Id: I8af98e9a8bcbd8d3175a162fced127ff89ce526c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7211480
Reviewed-by: Yiwei Zhang <yiwzhang@google.com>
Commit-Queue: Scott Lee <ddoman@chromium.org>
Since fetches involve multiple subprocess calls, any of which can be
slow, the per-subprocess caffeination strategy does not seem suitable --
the Mac might sleep as soon as the wake lock is dropped, before it
starts a new one. This instead implements a context manager to allow
caffeinating a scope.
To allow flag control, caffeinate.scope takes an argument that decides
whether or not it should actually do anything useful; it looks silly,
but the alternative is to interfere with flag parsing more or to require
users to write separate codepaths to decide whether to enter the context
manager scope or not; the "use the context manager in a mode where it
does not do anything" prevents this.
Bug: 462507017
Change-Id: Icc5bb9cadda30b5a120f112b10bf96ffd3b6550f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7183647
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Adam Norberg <norberg@google.com>
I'm looking at caffeinating more long-running depot_tools commands on
Mac, which use a variety of `subprocess` APIs; one implementation
strategy I'm considering is to wrap more of them, including
`subprocess.run`, but the most obvious name to wrap `subprocess.run`
into is already taken! I think it makes the most sense to name the
`caffeinate` function(s) after the `subprocess` call it wraps.
The callers to other parts of `subprocess` use more of the features
exposed by those APIs. For consistency, I am plumbing through more of
`subprocess.call`'s identifiable behaviors here, too:
* command-to-invoke parameter is named "args"
* as explicitly checked in cpython's subprocess.py's `_posix_spawn`:
77cb39e0c7/Lib/subprocess.py (L1816)
also allow `str`, `bytes`, and `os.PathLike` for the type of `args`,
converting the non-list-like types into a single-element list
* use kwargs packing and unpacking to forward other parameters into
`subprocess.call`
kwargs packing does not provide perfect emulation as implemented:
77cb39e0c7/Lib/subprocess.py (L386)
`timeout` could be provided as a positional parameter. However, Python
documents all subprocess.call parameters as keyword only:
https://docs.python.org/3.12/library/subprocess.html#older-high-level-api
...specifically because they don't want to bother distinguishing
between parameters "local" to a higher-level `subprocess` helper and
those that get forwarded (via `**kwargs`) to the underlying `Popen`,
so I think it is reasonable to follow their lead on that.
Bug: 462507017
Change-Id: Ia520ced7f8188c23c38826d22ccf20a3c52ddfc5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7181621
Reviewed-by: Junji Watanabe <jwata@google.com>
Commit-Queue: Adam Norberg <norberg@google.com>
This adds an optional turboci_check_id parameter to
bot_update.ensure_checkout. If set, it will cause a SOURCE check to be
emitted based on the gclient config being used and any gitiles commit or
gerrit change that is used.
Bug: b:443496677
Change-Id: Ic7fc55511b9b698cffb85fe872221e534fee742d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7147310
Commit-Queue: Garrett Beaty <gbeaty@google.com>
Reviewed-by: Robbie Iannucci <iannucci@google.com>
The json output for bot_update reports the value that are passed as
--revision flags to bot_update.py in the fixed_revisions field in the
json output. In the case of a revision of 'HEAD' for a project that has
a CL, the 'HEAD' gets resolved to the target ref of the CL. In
simulation tests, the --revision flag in the command correctly shows the
target ref, but the fixed_revisions in the json output shows 'HEAD'.
This updates the code so that the target ref resolution happens before
setting the value in the dict that is used as the fixed_revisions field
in the output json. This results in a change to the revision since the
input to produce the hash will incorporate the ref.
Change-Id: I4fc0594039faf0725ef9c293b00f31bc7b2692a2
Recipe-Nontrivial-Roll: build
Recipe-Nontrivial-Roll: build_internal
Recipe-Nontrivial-Roll: infra
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7148746
Auto-Submit: Garrett Beaty <gbeaty@google.com>
Reviewed-by: Scott Lee <ddoman@chromium.org>
Commit-Queue: Scott Lee <ddoman@chromium.org>
Makes the following changes related to the exception made for fake
Chromium checkouts when checking git submodules:
1. Adds an instance of this being used in Dawn to the comment
2. Adds third_party/placeholder_chromium as an allowed dependency name
since the "dummy" from third_party/dummy_chromium runs into the
inclusive language checks.
Bug: 452840620
Change-Id: I65099d150cf9c4971e3183f1cb208df668582e4c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/7170740
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Commit-Queue: Scott Lee <ddoman@chromium.org>
Auto-Submit: Brian Sheedy <bsheedy@chromium.org>
Reviewed-by: Scott Lee <ddoman@chromium.org>