summaryrefslogtreecommitdiffstats
path: root/main.py
diff options
context:
space:
mode:
authorDavid Riley <davidriley@google.com>2017-04-05 00:02:59 -0700
committerDavid Pursehouse <dpursehouse@collab.net>2017-05-29 13:39:54 +0900
commite0684addeeb920ddf83168d5fbbbe50cb9287abd (patch)
tree03a3dd940950463c0c88062d1fce2aae78708777 /main.py
parentfef9f21b28d3b59804fdd5db2bbb86e797051dab (diff)
downloadgit-repo-e0684addeeb920ddf83168d5fbbbe50cb9287abd.tar.gz
sync: Add support to dump a JSON event log of all sync events.
Change-Id: Id4852968ac1b2bf0093007cf2e5ca951ddab8b3b
Diffstat (limited to 'main.py')
-rwxr-xr-xmain.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/main.py b/main.py
index f965d7e1..386b4f13 100755
--- a/main.py
+++ b/main.py
@@ -37,6 +37,7 @@ except ImportError:
37 kerberos = None 37 kerberos = None
38 38
39from color import SetDefaultColoring 39from color import SetDefaultColoring
40import event_log
40from trace import SetTrace 41from trace import SetTrace
41from git_command import git, GitCommand 42from git_command import git, GitCommand
42from git_config import init_ssh, close_ssh 43from git_config import init_ssh, close_ssh
@@ -85,6 +86,9 @@ global_options.add_option('--time',
85global_options.add_option('--version', 86global_options.add_option('--version',
86 dest='show_version', action='store_true', 87 dest='show_version', action='store_true',
87 help='display this version of repo') 88 help='display this version of repo')
89global_options.add_option('--event-log',
90 dest='event_log', action='store',
91 help='filename of event log to append timeline to')
88 92
89class _Repo(object): 93class _Repo(object):
90 def __init__(self, repodir): 94 def __init__(self, repodir):
@@ -176,6 +180,8 @@ class _Repo(object):
176 RunPager(config) 180 RunPager(config)
177 181
178 start = time.time() 182 start = time.time()
183 cmd_event = cmd.event_log.Add(name, event_log.TASK_COMMAND, start)
184 cmd.event_log.SetParent(cmd_event)
179 try: 185 try:
180 result = cmd.Execute(copts, cargs) 186 result = cmd.Execute(copts, cargs)
181 except (DownloadError, ManifestInvalidRevisionError, 187 except (DownloadError, ManifestInvalidRevisionError,
@@ -203,7 +209,8 @@ class _Repo(object):
203 result = e.code 209 result = e.code
204 raise 210 raise
205 finally: 211 finally:
206 elapsed = time.time() - start 212 finish = time.time()
213 elapsed = finish - start
207 hours, remainder = divmod(elapsed, 3600) 214 hours, remainder = divmod(elapsed, 3600)
208 minutes, seconds = divmod(remainder, 60) 215 minutes, seconds = divmod(remainder, 60)
209 if gopts.time: 216 if gopts.time:
@@ -213,6 +220,12 @@ class _Repo(object):
213 print('real\t%dh%dm%.3fs' % (hours, minutes, seconds), 220 print('real\t%dh%dm%.3fs' % (hours, minutes, seconds),
214 file=sys.stderr) 221 file=sys.stderr)
215 222
223 cmd.event_log.FinishEvent(cmd_event, finish,
224 result is None or result == 0)
225 if gopts.event_log:
226 cmd.event_log.Write(os.path.abspath(
227 os.path.expanduser(gopts.event_log)))
228
216 return result 229 return result
217 230
218 231