summaryrefslogtreecommitdiffstats
path: root/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'main.py')
-rwxr-xr-xmain.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/main.py b/main.py
index 35023d52..889fc216 100755
--- a/main.py
+++ b/main.py
@@ -85,6 +85,9 @@ global_options.add_option('--color',
85global_options.add_option('--trace', 85global_options.add_option('--trace',
86 dest='trace', action='store_true', 86 dest='trace', action='store_true',
87 help='trace git command execution (REPO_TRACE=1)') 87 help='trace git command execution (REPO_TRACE=1)')
88global_options.add_option('--trace-python',
89 dest='trace_python', action='store_true',
90 help='trace python command execution')
88global_options.add_option('--time', 91global_options.add_option('--time',
89 dest='time', action='store_true', 92 dest='time', action='store_true',
90 help='time repo command execution') 93 help='time repo command execution')
@@ -102,8 +105,8 @@ class _Repo(object):
102 # add 'branch' as an alias for 'branches' 105 # add 'branch' as an alias for 'branches'
103 all_commands['branch'] = all_commands['branches'] 106 all_commands['branch'] = all_commands['branches']
104 107
105 def _Run(self, argv): 108 def _ParseArgs(self, argv):
106 result = 0 109 """Parse the main `repo` command line options."""
107 name = None 110 name = None
108 glob = [] 111 glob = []
109 112
@@ -120,6 +123,12 @@ class _Repo(object):
120 argv = [] 123 argv = []
121 gopts, _gargs = global_options.parse_args(glob) 124 gopts, _gargs = global_options.parse_args(glob)
122 125
126 return (name, gopts, argv)
127
128 def _Run(self, name, gopts, argv):
129 """Execute the requested subcommand."""
130 result = 0
131
123 if gopts.trace: 132 if gopts.trace:
124 SetTrace() 133 SetTrace()
125 if gopts.show_version: 134 if gopts.show_version:
@@ -526,7 +535,15 @@ def _Main(argv):
526 try: 535 try:
527 init_ssh() 536 init_ssh()
528 init_http() 537 init_http()
529 result = repo._Run(argv) or 0 538 name, gopts, argv = repo._ParseArgs(argv)
539 run = lambda: repo._Run(name, gopts, argv) or 0
540 if gopts.trace_python:
541 import trace
542 tracer = trace.Trace(count=False, trace=True, timing=True,
543 ignoredirs=set(sys.path[1:]))
544 result = tracer.runfunc(run)
545 else:
546 result = run()
530 finally: 547 finally:
531 close_ssh() 548 close_ssh()
532 except KeyboardInterrupt: 549 except KeyboardInterrupt: