From fd843fa45664e693f091e73a8ba49a00a32a3b80 Mon Sep 17 00:00:00 2001 From: Erik Chen Date: Thu, 17 Oct 2019 21:48:37 +0000 Subject: [PATCH] Add diagnostics to git_cache. These confirm that we're correctly using protocol v2. Change-Id: Ib8bd8a4dba27d44fc0ae14835ce5253dfa056318 Recipe-Nontrivial-Roll: skia Recipe-Nontrivial-Roll: chromiumos Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1867195 Commit-Queue: Erik Chen Auto-Submit: Erik Chen Reviewed-by: Andrii Shyshkalov --- git_cache.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/git_cache.py b/git_cache.py index 17b8cdee3..e41b82752 100755 --- a/git_cache.py +++ b/git_cache.py @@ -355,6 +355,14 @@ class Mirror(object): if cwd is None: cwd = self.mirror_path + # Print diagnostics and ignore errors. + try: + self.print('git exe: %s' % (self.git_exe,)) + self.RunGit(['version'], cwd=cwd) + self.RunGit(['config', 'protocol.version'], cwd=cwd) + except subprocess.CalledProcessError as e: + pass + if reset_fetch_config: try: self.RunGit(['config', '--unset-all', 'remote.origin.fetch'], cwd=cwd) @@ -544,8 +552,32 @@ class Mirror(object): spec = spec.decode() try: self.print('Fetching %s' % spec) + env = os.environ.copy() + env.update({ + 'GIT_TRACE_PACKET': '1', + 'GIT_TRACE_PERFORMANCE': '1', + 'GIT_TRACE_SETUP': '1' + }) + # Only print first 30 packets. We can use nonlocal keyword once we + # switch to python 3. + packet_count = [0] + + def FilterPacket(log_line): + if 'packet:' in log_line: + packet_count[0] += 1 + if packet_count[0] == 30: + self.print('Truncating remaining packets') + if packet_count[0] >= 30: + return + self.print(log_line) + with self.print_duration_of('fetch %s' % spec): - self.RunGit(fetch_cmd + [spec], cwd=rundir, retry=True) + self.RunGit( + fetch_cmd + [spec], + cwd=rundir, + retry=True, + env=env, + filter_fn=FilterPacket) except subprocess.CalledProcessError: if spec == '+refs/heads/*:refs/heads/*': raise ClobberNeeded() # Corrupted cache.