diff options
Diffstat (limited to 'main.py')
| -rwxr-xr-x | main.py | 33 |
1 files changed, 12 insertions, 21 deletions
| @@ -37,7 +37,7 @@ except ImportError: | |||
| 37 | 37 | ||
| 38 | from color import SetDefaultColoring | 38 | from color import SetDefaultColoring |
| 39 | import event_log | 39 | import event_log |
| 40 | from repo_trace import SetTrace, Trace, SetTraceToStderr | 40 | from repo_trace import SetTrace |
| 41 | from git_command import user_agent | 41 | from git_command import user_agent |
| 42 | from git_config import RepoConfig | 42 | from git_config import RepoConfig |
| 43 | from git_trace2_event_log import EventLog | 43 | from git_trace2_event_log import EventLog |
| @@ -109,9 +109,6 @@ global_options.add_option('--color', | |||
| 109 | global_options.add_option('--trace', | 109 | global_options.add_option('--trace', |
| 110 | dest='trace', action='store_true', | 110 | dest='trace', action='store_true', |
| 111 | help='trace git command execution (REPO_TRACE=1)') | 111 | help='trace git command execution (REPO_TRACE=1)') |
| 112 | global_options.add_option('--trace_to_stderr', | ||
| 113 | dest='trace_to_stderr', action='store_true', | ||
| 114 | help='trace outputs go to stderr in addition to .repo/TRACE_FILE') | ||
| 115 | global_options.add_option('--trace-python', | 112 | global_options.add_option('--trace-python', |
| 116 | dest='trace_python', action='store_true', | 113 | dest='trace_python', action='store_true', |
| 117 | help='trace python command execution') | 114 | help='trace python command execution') |
| @@ -201,6 +198,9 @@ class _Repo(object): | |||
| 201 | """Execute the requested subcommand.""" | 198 | """Execute the requested subcommand.""" |
| 202 | result = 0 | 199 | result = 0 |
| 203 | 200 | ||
| 201 | if gopts.trace: | ||
| 202 | SetTrace() | ||
| 203 | |||
| 204 | # Handle options that terminate quickly first. | 204 | # Handle options that terminate quickly first. |
| 205 | if gopts.help or gopts.help_all: | 205 | if gopts.help or gopts.help_all: |
| 206 | self._PrintHelp(short=False, all_commands=gopts.help_all) | 206 | self._PrintHelp(short=False, all_commands=gopts.help_all) |
| @@ -652,26 +652,17 @@ def _Main(argv): | |||
| 652 | Version.wrapper_path = opt.wrapper_path | 652 | Version.wrapper_path = opt.wrapper_path |
| 653 | 653 | ||
| 654 | repo = _Repo(opt.repodir) | 654 | repo = _Repo(opt.repodir) |
| 655 | |||
| 656 | try: | 655 | try: |
| 657 | init_http() | 656 | init_http() |
| 658 | name, gopts, argv = repo._ParseArgs(argv) | 657 | name, gopts, argv = repo._ParseArgs(argv) |
| 659 | 658 | run = lambda: repo._Run(name, gopts, argv) or 0 | |
| 660 | if gopts.trace: | 659 | if gopts.trace_python: |
| 661 | SetTrace() | 660 | import trace |
| 662 | 661 | tracer = trace.Trace(count=False, trace=True, timing=True, | |
| 663 | if gopts.trace_to_stderr: | 662 | ignoredirs=set(sys.path[1:])) |
| 664 | SetTraceToStderr() | 663 | result = tracer.runfunc(run) |
| 665 | 664 | else: | |
| 666 | with Trace('starting new command: %s', ', '.join([name] + argv), first_trace=True): | 665 | result = run() |
| 667 | run = lambda: repo._Run(name, gopts, argv) or 0 | ||
| 668 | if gopts.trace_python: | ||
| 669 | import trace | ||
| 670 | tracer = trace.Trace(count=False, trace=True, timing=True, | ||
| 671 | ignoredirs=set(sys.path[1:])) | ||
| 672 | result = tracer.runfunc(run) | ||
| 673 | else: | ||
| 674 | result = run() | ||
| 675 | except KeyboardInterrupt: | 666 | except KeyboardInterrupt: |
| 676 | print('aborted by user', file=sys.stderr) | 667 | print('aborted by user', file=sys.stderr) |
| 677 | result = 1 | 668 | result = 1 |
