From 8896b68926b660a90f37a9a37221c30514c52523 Mon Sep 17 00:00:00 2001 From: Josip Sokcevic Date: Wed, 21 Feb 2024 11:04:03 -0800 Subject: [PATCH] trace: Save trace2 sid in REPO_TRACE file git-trace2 events contain additional information what git is doing under the hood, and repo doesn't have visibility into. Instead of relying on timestamp information to match REPO_TRACE with git-trace2 events, add SID information into REPO_TRACE. Change-Id: I37672a3face81858072c7a3ce34ca3379199dab5 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/410280 Tested-by: Josip Sokcevic Reviewed-by: Gavin Mak Commit-Queue: Josip Sokcevic --- main.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index 47dcde19..2e1058d4 100755 --- a/main.py +++ b/main.py @@ -270,10 +270,14 @@ class _Repo: self._PrintHelp(short=True) return 1 - run = lambda: self._RunLong(name, gopts, argv) or 0 + git_trace2_event_log = EventLog() + run = ( + lambda: self._RunLong(name, gopts, argv, git_trace2_event_log) or 0 + ) with Trace( - "starting new command: %s", + "starting new command: %s [sid=%s]", ", ".join([name] + argv), + git_trace2_event_log.full_sid, first_trace=True, ): if gopts.trace_python: @@ -290,12 +294,11 @@ class _Repo: result = run() return result - def _RunLong(self, name, gopts, argv): + def _RunLong(self, name, gopts, argv, git_trace2_event_log): """Execute the (longer running) requested subcommand.""" result = 0 SetDefaultColoring(gopts.color) - git_trace2_event_log = EventLog() outer_client = RepoClient(self.repodir) repo_client = outer_client if gopts.submanifest_path: