Commit Graph

11 Commits (32769fe9391bcbe32eba867db2b358d47c170562)

Author SHA1 Message Date
Andrew Grieve 6e8c18239d Cache values in gclient_paths.py
Several clients of this module call its methods repeatedly. Cache them
to speed them up.

E.g. "autosiso" calls FindGclientRoot() 5 times before building
E.g. "git cl format" calls it 5 times in one of my CLs.

Bug: None
Change-Id: I70995c2def9689d46a89896640cc748d9629df3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4904697
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
1 year ago
Mike Frysinger 124bb8e53c switch to 4 space indent
Leave the recipes/ code at 2 space to match the rest of the recipes
project in other repos.

Reformatted using:
files=( $(
	git ls-tree -r --name-only HEAD | \
		grep -Ev -e '^(third_party|recipes)/' | \
		grep '\.py$';
	git grep -l '#!/usr/bin/env.*python' | grep -v '\.py$'
) )
parallel ./yapf -i -- "${files[@]}"
~/chromiumos/chromite/contrib/reflow_overlong_comments "${files[@]}"

The files that still had strings that were too long were manually
reformatted because they were easy and only a few issues.
autoninja.py
clang_format.py
download_from_google_storage.py
fix_encoding.py
gclient_utils.py
git_cache.py
git_common.py
git_map_branches.py
git_reparent_branch.py
gn.py
my_activity.py
owners_finder.py
presubmit_canned_checks.py
reclient_helper.py
reclientreport.py
roll_dep.py
rustfmt.py
siso.py
split_cl.py
subcommand.py
subprocess2.py
swift_format.py
upload_to_google_storage.py

These files still had lines (strings) that were too long, so the pylint
warnings were suppressed with a TODO.
auth.py
gclient.py
gclient_eval.py
gclient_paths.py
gclient_scm.py
gerrit_util.py
git_cl.py
presubmit_canned_checks.py
presubmit_support.py
scm.py

Change-Id: Ia6535c4f2c48d46b589ec1e791dde6c6b2ea858f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4836379
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
2 years ago
Gavin Mak 65c49b18b9 Drop py2 support in gclient and related files
python3 is the only supported version of python in depot_tools.

Bug: 1475402
Change-Id: I17174d7252b5cbf698700333d3cd561c6591d0a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4809190
Reviewed-by: Aravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
2 years ago
Wan-Teh Chang bc5906f6ff Suppress stderr of the git rev-parse command
In GetPrimarySolutionPath(), redirect the stderr of the
git rev-parse --show-toplevel command to /dev/null. This avoids the
following error message when running depot_tools' ninja command outside
the Chrome source tree:
fatal: not a git repository (or any of the parent directories): .git

I believe this error message was an unintended side effect of the work
on bug 1340825.

Bug: 1340825
Change-Id: I5679a854d1ff23f581564c54c765e13f8ba8b534
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4392154
Commit-Queue: Wan-Teh Chang <wtc@google.com>
Reviewed-by: Junji Watanabe <jwata@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
2 years ago
Robert Liao b888780d17 Change FindGclientRoot to Use os.path.abspath instead of os.path.realpath
os.path.realpath will resolve back to the subst paths, leading to
inappropriate current working directories for all downstream hooks.

BUG=1208688

Change-Id: Idfcb0fe4d25ab1317db5aae34663b1017d4c4937
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2893669
Commit-Queue: Dirk Pranke <dpranke@google.com>
Auto-Submit: Robert Liao <robliao@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@google.com>
4 years ago
Edward Lemur 84b5f9a215 depot_tools: Add tests for gclient_paths
Change-Id: I544aa85b040544508df8ed16310def982356fbcc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1949417
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
Reviewed-by: Anthony Polito <apolito@google.com>
5 years ago
Robert Liao 7211cf6444 Import gclient_utils for gclient_paths CheckCallAndFilter
CheckCallAndFilter isn't part of the global namespace, and as a result,
this call was silently failing.

BUG=1007553

Change-Id: Ie2f3135fc3d56be189d8be0fe996a068e0645705
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1823664
Auto-Submit: Robert Liao <robliao@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Robert Liao <robliao@chromium.org>
6 years ago
Raul Tambre b946b2389c Improve gclient Python 3 compatibility
This enables gclient sync and gclient runhooks to run, barring hook script failures.
git cl upload also now works.

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

Bug: 942522
Change-Id: I2ac587b5f803ba7f5bb5e412337ce049f4b1a741
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1524583
Commit-Queue: Raul Tambre <raul@tambre.ee>
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
6 years ago
Dirk Pranke 112a77f4bf Make sys a top-level import in gclient_paths.
sys takes essentially no time to import (I think possibly because
it's a built-in?), and importing it as-needed is fragile. Make
it a top-level import to gclient_paths to prevent future breakages.

BUG=939959

Change-Id: I1ebe1260afd927355d668acf3cab5067ff0a2e03
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1515669
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@chromium.org>
6 years ago
Nico Weber ad116ba9f6 Unbreak clang-format / GetBuildtoolsPlatformBinaryPath() after depot_tools/+/1512058
TBR=tandrii
Bug: 939959
Change-Id: Ia200eb38fda3d2572c4f1c3dc0d9f8f8fbd34362
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1515874
Auto-Submit: Nico Weber <thakis@chromium.org>
Reviewed-by: Nico Weber <thakis@chromium.org>
Commit-Queue: Nico Weber <thakis@chromium.org>
6 years ago
Nico Weber 09e0b38f0f Move gclient path access to separate module.
gclient_utils.py is a kitchen sink and is for that reason expensive
to import. Move the comparatively cheap and simple path routines
to a new gclient_paths module and use that in gn.py, clang_format.py,
dart_format.py.

(To be able to move FindGclientRoot() to gclient_paths.py,
make it use io.open() instead of FileRead(). FileRead() tries
to paper over invalid utf-8, but that was added for presubmits,
not for .gclient files, so this is hopefully fine.)

Cuts gn.py overhead in half (on my Windows laptop from 0.6s to 0.25s,
still high; on my Mac laptop from 0.1s to 0.05s), and probably helps
the other two too.

Completely remove PathDifference() since it's unused.

Bug: 939959
Change-Id: I6a70f6e4c16062b622fb2df8778e8a598d4cc956
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1512058
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
6 years ago