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>
diff --git a/gclient.py b/gclient.py
index 07bf2f5..245c5e6 100755
--- a/gclient.py
+++ b/gclient.py
@@ -102,6 +102,7 @@
import fix_encoding
import gclient_eval
import gclient_scm
+import gclient_paths
import gclient_utils
import git_cache
import metrics
@@ -1459,7 +1460,7 @@
if options.verbose:
print('Looking for %s starting from %s\n' % (
options.config_filename, os.getcwd()))
- path = gclient_utils.FindGclientRoot(os.getcwd(), options.config_filename)
+ path = gclient_paths.FindGclientRoot(os.getcwd(), options.config_filename)
if not path:
if options.verbose:
print('Couldn\'t find configuration file.')