From f7d252f5dcfdcc01ae73d7a470bca1a7867c6d5b Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 22 Oct 2026 23:39:29 -0400 Subject: [PATCH] style: use `import repo_trace` everywhere Align with Google style guides and `import repo_trace` as a module rather than import symbols out of it. Change-Id: I6bea5e7a68775e93b6b7fcd218db666350aff690 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/647803 Tested-by: Mike Frysinger Commit-Queue: Mike Frysinger Reviewed-by: Gavin Mak --- git_command.py | 10 ++++------ git_config.py | 4 ++-- git_refs.py | 6 +++--- main.py | 10 ++++------ progress.py | 8 ++++---- project.py | 4 ++-- ssh.py | 8 +++++--- subcmds/sync.py | 4 ++-- 8 files changed, 26 insertions(+), 28 deletions(-) diff --git a/git_command.py b/git_command.py index 9558a9aeb..86c7738ab 100644 --- a/git_command.py +++ b/git_command.py @@ -24,9 +24,7 @@ import error from git_trace2_event_log_base import BaseEventLog import platform_utils from repo_logging import RepoLogger -from repo_trace import IsTrace -from repo_trace import REPO_TRACE -from repo_trace import Trace +import repo_trace from wrapper import Wrapper @@ -432,7 +430,7 @@ class GitCommand: kwargs = {} dbg = "" - if IsTrace(): + if repo_trace.IsTrace(): global LAST_CWD global LAST_GITDIR @@ -469,7 +467,7 @@ class GitCommand: elif stderr == subprocess.STDOUT: dbg += " 2>&1" - with Trace( + with repo_trace.Trace( "git command %s %s with debug: %s", LAST_GITDIR, command, dbg ): try: @@ -546,7 +544,7 @@ class GitCommand: """ env = os.environ.copy() for key in ( - REPO_TRACE, + repo_trace.REPO_TRACE, GIT_DIR, "GIT_ALTERNATE_OBJECT_DIRECTORIES", "GIT_OBJECT_DIRECTORY", diff --git a/git_config.py b/git_config.py index 756e9c2d5..6c9b96b90 100644 --- a/git_config.py +++ b/git_config.py @@ -32,7 +32,7 @@ from git_refs import R_CHANGES from git_refs import R_HEADS from git_refs import R_TAGS import platform_utils -from repo_trace import Trace +import repo_trace # Prefix that is prepended to all the keys of SyncAnalysisState's data @@ -427,7 +427,7 @@ class GitConfig: except OSError: return None try: - with Trace(": parsing %s", self.file): + with repo_trace.Trace(": parsing %s", self.file): with open(self._json) as fd: return json.load(fd) except (OSError, ValueError): diff --git a/git_refs.py b/git_refs.py index 0811377a5..08716c09f 100644 --- a/git_refs.py +++ b/git_refs.py @@ -17,7 +17,7 @@ import os from git_command import git_require from git_command import GitCommand import platform_utils -from repo_trace import Trace +import repo_trace HEAD = "HEAD" @@ -82,7 +82,7 @@ class GitRefs: self._LoadAll() def _NeedUpdate(self): - with Trace(": scan refs %s", self._gitdir): + with repo_trace.Trace(": scan refs %s", self._gitdir): for name, mtime in self._mtime.items(): try: if mtime != os.path.getmtime( @@ -94,7 +94,7 @@ class GitRefs: return False def _LoadAll(self): - with Trace(": load refs %s", self._gitdir): + with repo_trace.Trace(": load refs %s", self._gitdir): self._phyref = {} self._symref = {} self._mtime = {} diff --git a/main.py b/main.py index 818a4744b..3ff88bec8 100755 --- a/main.py +++ b/main.py @@ -53,9 +53,7 @@ from git_trace2_event_log import EventLog from manifest_xml import RepoClient from pager import RunPager from pager import TerminatePager -from repo_trace import SetTrace -from repo_trace import SetTraceToStderr -from repo_trace import Trace +import repo_trace from subcmds import all_commands from subcmds.version import Version from wrapper import Wrapper @@ -269,7 +267,7 @@ class _Repo: run = ( lambda: self._RunLong(name, gopts, argv, git_trace2_event_log) or 0 ) - with Trace( + with repo_trace.Trace( "starting new command: %s [sid=%s]", ", ".join([name] + argv), git_trace2_event_log.full_sid, @@ -933,10 +931,10 @@ def _Main(argv): name, gopts, argv = repo._ParseArgs(argv) if gopts.trace: - SetTrace() + repo_trace.SetTrace() if gopts.trace_to_stderr: - SetTraceToStderr() + repo_trace.SetTraceToStderr() result = repo._Run(name, gopts, argv) or 0 except error.RepoExitError as e: diff --git a/progress.py b/progress.py index 2c0fead5a..2cbac97b1 100644 --- a/progress.py +++ b/progress.py @@ -22,7 +22,7 @@ try: except ImportError: import dummy_threading as _threading -from repo_trace import IsTraceToStderr +import repo_trace # Capture the original stderr stream. We use this exclusively for progress @@ -166,7 +166,7 @@ class Progress: msg = self._last_msg self._last_msg = msg - if not _TTY or IsTraceToStderr() or self._quiet: + if not _TTY or repo_trace.IsTraceToStderr() or self._quiet: return elapsed_sec = time.time() - self._start @@ -211,7 +211,7 @@ class Progress: The progress bar is then redrawn on the next line. """ - if not _TTY or IsTraceToStderr() or self._quiet: + if not _TTY or repo_trace.IsTraceToStderr() or self._quiet: return # Erase the current line, print the message with a newline, @@ -227,7 +227,7 @@ class Progress: self._ended = True self._update_event.set() - if not _TTY or IsTraceToStderr() or self._quiet: + if not _TTY or repo_trace.IsTraceToStderr() or self._quiet: return duration = duration_str(time.time() - self._start) diff --git a/project.py b/project.py index f890071a8..01f5e4668 100644 --- a/project.py +++ b/project.py @@ -55,7 +55,7 @@ from git_trace2_event_log import EventLog import platform_utils import progress from repo_logging import RepoLogger -from repo_trace import Trace +import repo_trace logger = RepoLogger(__file__) @@ -3821,7 +3821,7 @@ class Project: cmd += [srcUrl] proc = None - with Trace("Fetching bundle: %s", " ".join(cmd)): + with repo_trace.Trace("Fetching bundle: %s", " ".join(cmd)): if verbose: print(f"{self.name}: Downloading bundle: {srcUrl}") stdout = None if verbose else subprocess.PIPE diff --git a/ssh.py b/ssh.py index 25152f1cc..6eb063239 100644 --- a/ssh.py +++ b/ssh.py @@ -26,7 +26,7 @@ import time from git_command import git import platform_utils -from repo_trace import Trace +import repo_trace PROXY_PATH = os.path.join(os.path.dirname(__file__), "git_ssh") @@ -201,7 +201,9 @@ class ProxyManager: # is the same as 'myhost.com' where "User git" is setup in the user's # ~/.ssh/config file. check_command = command_base + ["-O", "check"] - with Trace("Call to ssh (check call): %s", " ".join(check_command)): + with repo_trace.Trace( + "Call to ssh (check call): %s", " ".join(check_command) + ): try: check_process = subprocess.Popen( check_command, @@ -250,7 +252,7 @@ class ProxyManager: ) p = None try: - with Trace("Call to ssh: %s", " ".join(command)): + with repo_trace.Trace("Call to ssh: %s", " ".join(command)): p = subprocess.Popen(command) except Exception as e: self._master_broken.value = True diff --git a/subcmds/sync.py b/subcmds/sync.py index e33da7134..2ab9dbd35 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -77,7 +77,7 @@ from project import Project from project import RemoteSpec from project import SyncBuffer from repo_logging import RepoLogger -from repo_trace import Trace +import repo_trace import ssh from wrapper import Wrapper @@ -1565,7 +1565,7 @@ later is required to fix a server side protocol bug. if expected != actual: # If this is unexpected, log it and repair. - Trace( + repo_trace.Trace( f"{relpath} expected preciousObjects={expected}, got {actual}" ) if expected: