summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaMont Jones <lamontjones@google.com>2022-11-10 02:31:19 +0000
committerLaMont Jones <lamontjones@google.com>2022-11-14 23:46:06 +0000
commited25be569e1c2e1c222010565c186b904eb8646c (patch)
tree3c0b736fbe2156e857332091fd29300ced4af2b7
parentafd767103ee2b80a67beb6e5c4fa94dd025f6a75 (diff)
downloadgit-repo-ed25be569e1c2e1c222010565c186b904eb8646c.tar.gz
repo_trace: drop notification of trace file name.
The trace file is local to the workspace. We shouldn't tell the user that on every command that they run. Change-Id: I8674ab485bd5142814a043a225bf8aaca7795752 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/351234 Tested-by: LaMont Jones <lamontjones@google.com> Reviewed-by: Xin Li <delphij@google.com>
-rw-r--r--repo_trace.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/repo_trace.py b/repo_trace.py
index fcd8650e..d79408d9 100644
--- a/repo_trace.py
+++ b/repo_trace.py
@@ -57,9 +57,9 @@ def SetTrace():
57 _TRACE = True 57 _TRACE = True
58 58
59 59
60def _SetTraceFile(): 60def _SetTraceFile(quiet):
61 global _TRACE_FILE 61 global _TRACE_FILE
62 _TRACE_FILE = _GetTraceFile() 62 _TRACE_FILE = _GetTraceFile(quiet)
63 63
64 64
65class Trace(ContextDecorator): 65class Trace(ContextDecorator):
@@ -68,13 +68,21 @@ class Trace(ContextDecorator):
68 """Generate nanoseconds of time in a py3.6 safe way""" 68 """Generate nanoseconds of time in a py3.6 safe way"""
69 return int(time.time() * 1e+9) 69 return int(time.time() * 1e+9)
70 70
71 def __init__(self, fmt, *args, first_trace=False): 71 def __init__(self, fmt, *args, first_trace=False, quiet=True):
72 """Initialize the object.
73
74 Args:
75 fmt: The format string for the trace.
76 *args: Arguments to pass to formatting.
77 first_trace: Whether this is the first trace of a `repo` invocation.
78 quiet: Whether to suppress notification of trace file location.
79 """
72 if not IsTrace(): 80 if not IsTrace():
73 return 81 return
74 self._trace_msg = fmt % args 82 self._trace_msg = fmt % args
75 83
76 if not _TRACE_FILE: 84 if not _TRACE_FILE:
77 _SetTraceFile() 85 _SetTraceFile(quiet)
78 86
79 if first_trace: 87 if first_trace:
80 _ClearOldTraces() 88 _ClearOldTraces()
@@ -109,12 +117,13 @@ class Trace(ContextDecorator):
109 return False 117 return False
110 118
111 119
112def _GetTraceFile(): 120def _GetTraceFile(quiet):
113 """Get the trace file or create one.""" 121 """Get the trace file or create one."""
114 # TODO: refactor to pass repodir to Trace. 122 # TODO: refactor to pass repodir to Trace.
115 repo_dir = os.path.dirname(os.path.dirname(__file__)) 123 repo_dir = os.path.dirname(os.path.dirname(__file__))
116 trace_file = os.path.join(repo_dir, _TRACE_FILE_NAME) 124 trace_file = os.path.join(repo_dir, _TRACE_FILE_NAME)
117 print(f'Trace outputs in {trace_file}', file=sys.stderr) 125 if not quiet:
126 print(f'Trace outputs in {trace_file}', file=sys.stderr)
118 return trace_file 127 return trace_file
119 128
120 129