summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xrepo24
1 files changed, 24 insertions, 0 deletions
diff --git a/repo b/repo
index bbcf0d50..ea3df1d5 100755
--- a/repo
+++ b/repo
@@ -17,8 +17,29 @@ import subprocess
17import sys 17import sys
18 18
19 19
20# Keep basic logic in sync with repo_trace.py.
21class Trace(object):
22 """Trace helper logic."""
23
24 REPO_TRACE = 'REPO_TRACE'
25
26 def __init__(self):
27 self.set(os.environ.get(self.REPO_TRACE) == '1')
28
29 def set(self, value):
30 self.enabled = bool(value)
31
32 def print(self, *args, **kwargs):
33 if self.enabled:
34 print(*args, **kwargs)
35
36
37trace = Trace()
38
39
20def exec_command(cmd): 40def exec_command(cmd):
21 """Execute |cmd| or return None on failure.""" 41 """Execute |cmd| or return None on failure."""
42 trace.print(':', ' '.join(cmd))
22 try: 43 try:
23 if platform.system() == 'Windows': 44 if platform.system() == 'Windows':
24 ret = subprocess.call(cmd) 45 ret = subprocess.call(cmd)
@@ -309,6 +330,7 @@ def run_command(cmd, **kwargs):
309 stdout = stdout.decode('utf-8') 330 stdout = stdout.decode('utf-8')
310 if stderr is not None: 331 if stderr is not None:
311 stderr = stderr.decode('utf-8') 332 stderr = stderr.decode('utf-8')
333 trace.print(':', ' '.join(cmd))
312 ret = RunResult(proc.returncode, stdout, stderr) 334 ret = RunResult(proc.returncode, stdout, stderr)
313 335
314 # If things failed, print useful debugging output. 336 # If things failed, print useful debugging output.
@@ -810,6 +832,8 @@ def _ParseArguments(args):
810 opt.help = True 832 opt.help = True
811 elif a == '--version': 833 elif a == '--version':
812 opt.version = True 834 opt.version = True
835 elif a == '--trace':
836 trace.set(True)
813 elif not a.startswith('-'): 837 elif not a.startswith('-'):
814 cmd = a 838 cmd = a
815 arg = args[i + 1:] 839 arg = args[i + 1:]