|
@@ -85,6 +85,9 @@ global_options.add_option('--color',
|
|
|
global_options.add_option('--trace',
|
|
global_options.add_option('--trace',
|
|
|
dest='trace', action='store_true',
|
|
dest='trace', action='store_true',
|
|
|
help='trace git command execution (REPO_TRACE=1)')
|
|
help='trace git command execution (REPO_TRACE=1)')
|
|
|
|
|
+global_options.add_option('--trace-python',
|
|
|
|
|
+ dest='trace_python', action='store_true',
|
|
|
|
|
+ help='trace python command execution')
|
|
|
global_options.add_option('--time',
|
|
global_options.add_option('--time',
|
|
|
dest='time', action='store_true',
|
|
dest='time', action='store_true',
|
|
|
help='time repo command execution')
|
|
help='time repo command execution')
|
|
@@ -102,8 +105,8 @@ class _Repo(object):
|
|
|
# add 'branch' as an alias for 'branches'
|
|
# add 'branch' as an alias for 'branches'
|
|
|
all_commands['branch'] = all_commands['branches']
|
|
all_commands['branch'] = all_commands['branches']
|
|
|
|
|
|
|
|
- def _Run(self, argv):
|
|
|
|
|
- result = 0
|
|
|
|
|
|
|
+ def _ParseArgs(self, argv):
|
|
|
|
|
+ """Parse the main `repo` command line options."""
|
|
|
name = None
|
|
name = None
|
|
|
glob = []
|
|
glob = []
|
|
|
|
|
|
|
@@ -120,6 +123,12 @@ class _Repo(object):
|
|
|
argv = []
|
|
argv = []
|
|
|
gopts, _gargs = global_options.parse_args(glob)
|
|
gopts, _gargs = global_options.parse_args(glob)
|
|
|
|
|
|
|
|
|
|
+ return (name, gopts, argv)
|
|
|
|
|
+
|
|
|
|
|
+ def _Run(self, name, gopts, argv):
|
|
|
|
|
+ """Execute the requested subcommand."""
|
|
|
|
|
+ result = 0
|
|
|
|
|
+
|
|
|
if gopts.trace:
|
|
if gopts.trace:
|
|
|
SetTrace()
|
|
SetTrace()
|
|
|
if gopts.show_version:
|
|
if gopts.show_version:
|
|
@@ -526,7 +535,15 @@ def _Main(argv):
|
|
|
try:
|
|
try:
|
|
|
init_ssh()
|
|
init_ssh()
|
|
|
init_http()
|
|
init_http()
|
|
|
- result = repo._Run(argv) or 0
|
|
|
|
|
|
|
+ name, gopts, argv = repo._ParseArgs(argv)
|
|
|
|
|
+ run = lambda: repo._Run(name, gopts, argv) or 0
|
|
|
|
|
+ if gopts.trace_python:
|
|
|
|
|
+ import trace
|
|
|
|
|
+ tracer = trace.Trace(count=False, trace=True, timing=True,
|
|
|
|
|
+ ignoredirs=set(sys.path[1:]))
|
|
|
|
|
+ result = tracer.runfunc(run)
|
|
|
|
|
+ else:
|
|
|
|
|
+ result = run()
|
|
|
finally:
|
|
finally:
|
|
|
close_ssh()
|
|
close_ssh()
|
|
|
except KeyboardInterrupt:
|
|
except KeyboardInterrupt:
|