Revert "Update gclient to use git config caching"

This reverts commit 3edda8d185.

Reason for revert: Breaks rebase-update; crbug.com/324358728

Original change's description:
> Update gclient to use git config caching
>
> This change updates all the modules used by gclient to use `scm.GIT` for git config calls over directly invoking the subprocess.
>
> This change currently doesn't modify git_cache since the config reads and writes within it are done on bare repository. A follow-up CL will update git_cache.
>
> A follow-up CL will also update git_cl and git_map_branches since they have shown performance improvements too: https://crrev.com/c/4697786.
>
> Benchmarking
> ============
> With chromium/src as the baseline super project, this change reduces about 380 git config calls out of 507 total calls on cache hits during no-op. The below numbers are benchmarked with `update_depot_tools` turned off.
>
> Windows Benchmark
> =================
> Baseline (gpaste/6360045736951808): ~1min 12 sec.
> With Caching (gpaste/6480065209040896): ~1min 3sec.
> ~12.5% decrease in gclient sync noop runtime.
>
> Linux Benchmark
> ===============
> Baseline (gpaste/4730436763254784): ~3.739 sec.
> With Caching (gpaste/4849870978940928): ~3.534 sec.
> ~5.5% decrease in gclient sync noop runtime.
>
> Bug: 1501984
> Change-Id: Ib48df2d26a0c742a9b555a1e2ed6366221c7db17
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5252498
> Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
> Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>

Bug: 1501984
Change-Id: I4a603238d9ed43edafc8e574493800670520a1d9
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5279198
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
This commit is contained in:
Aravind Vasudevan
2024-02-08 17:21:29 +00:00
committed by LUCI CQ
parent e98e458a9f
commit 3569608028
8 changed files with 96 additions and 92 deletions

View File

@@ -38,7 +38,6 @@ import signal
import tempfile
import textwrap
import scm
import subprocess2
from io import BytesIO
@@ -350,10 +349,8 @@ def branch_config_map(option):
"""Return {branch: <|option| value>} for all branches."""
try:
reg = re.compile(r'^branch\.(.*)\.%s$' % option)
return {
reg.match(k).group(1): v
for k, v in get_config_regexp(reg.pattern)
}
lines = get_config_regexp(reg.pattern)
return {reg.match(k).group(1): v for k, v in (l.split() for l in lines)}
except subprocess2.CalledProcessError:
return {}
@@ -387,7 +384,11 @@ def branches(use_limit=True, *args):
def get_config(option, default=None):
return scm.GIT.GetConfig(os.getcwd(), option, default)
try:
return run('config', '--get', option) or default
except subprocess2.CalledProcessError:
return default
def get_config_int(option, default=0):
assert isinstance(default, int)
@@ -398,11 +399,19 @@ def get_config_int(option, default=0):
def get_config_list(option):
return scm.GIT.GetConfigList(os.getcwd(), option)
try:
return run('config', '--get-all', option).split()
except subprocess2.CalledProcessError:
return []
def get_config_regexp(pattern):
return scm.GIT.YieldConfigRegexp(os.getcwd(), pattern)
if IS_WIN: # pragma: no cover
# this madness is because we call git.bat which calls git.exe which
# calls bash.exe (or something to that effect). Each layer divides the
# number of ^'s by 2.
pattern = pattern.replace('^', '^' * 8)
return run('config', '--get-regexp', pattern).splitlines()
def is_fsmonitor_enabled():
@@ -446,7 +455,7 @@ def del_branch_config(branch, option, scope='local'):
def del_config(option, scope='local'):
try:
scm.GIT.SetConfig(os.getcwd(), option, scope=scope)
run('config', '--' + scope, '--unset', option)
except subprocess2.CalledProcessError:
pass
@@ -888,7 +897,7 @@ def set_branch_config(branch, option, value, scope='local'):
def set_config(option, value, scope='local'):
scm.GIT.SetConfig(os.getcwd(), option, value, scope=scope)
run('config', '--' + scope, option, value)
def get_dirty_files():
@@ -1107,7 +1116,10 @@ def tree(treeref, recurse=False):
def get_remote_url(remote='origin'):
return scm.GIT.GetConfig(os.getcwd(), 'remote.%s.url' % remote)
try:
return run('config', 'remote.%s.url' % remote)
except subprocess2.CalledProcessError:
return None
def upstream(branch):