mirror of
https://git.codelinaro.org/clo/tools/repo.git
synced 2025-08-06 05:35:03 +08:00
sync: Add support to dump a JSON event log of all sync events.
Change-Id: Id4852968ac1b2bf0093007cf2e5ca951ddab8b3b
This commit is contained in:

committed by
David Pursehouse

parent
fef9f21b28
commit
e0684addee
15
main.py
15
main.py
@ -37,6 +37,7 @@ except ImportError:
|
||||
kerberos = None
|
||||
|
||||
from color import SetDefaultColoring
|
||||
import event_log
|
||||
from trace import SetTrace
|
||||
from git_command import git, GitCommand
|
||||
from git_config import init_ssh, close_ssh
|
||||
@ -85,6 +86,9 @@ global_options.add_option('--time',
|
||||
global_options.add_option('--version',
|
||||
dest='show_version', action='store_true',
|
||||
help='display this version of repo')
|
||||
global_options.add_option('--event-log',
|
||||
dest='event_log', action='store',
|
||||
help='filename of event log to append timeline to')
|
||||
|
||||
class _Repo(object):
|
||||
def __init__(self, repodir):
|
||||
@ -176,6 +180,8 @@ class _Repo(object):
|
||||
RunPager(config)
|
||||
|
||||
start = time.time()
|
||||
cmd_event = cmd.event_log.Add(name, event_log.TASK_COMMAND, start)
|
||||
cmd.event_log.SetParent(cmd_event)
|
||||
try:
|
||||
result = cmd.Execute(copts, cargs)
|
||||
except (DownloadError, ManifestInvalidRevisionError,
|
||||
@ -203,7 +209,8 @@ class _Repo(object):
|
||||
result = e.code
|
||||
raise
|
||||
finally:
|
||||
elapsed = time.time() - start
|
||||
finish = time.time()
|
||||
elapsed = finish - start
|
||||
hours, remainder = divmod(elapsed, 3600)
|
||||
minutes, seconds = divmod(remainder, 60)
|
||||
if gopts.time:
|
||||
@ -213,6 +220,12 @@ class _Repo(object):
|
||||
print('real\t%dh%dm%.3fs' % (hours, minutes, seconds),
|
||||
file=sys.stderr)
|
||||
|
||||
cmd.event_log.FinishEvent(cmd_event, finish,
|
||||
result is None or result == 0)
|
||||
if gopts.event_log:
|
||||
cmd.event_log.Write(os.path.abspath(
|
||||
os.path.expanduser(gopts.event_log)))
|
||||
|
||||
return result
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user