comparison mercurial/dispatch.py @ 18670:ddc7268da176

blackbox: log the commands that are run Uses ui.log to log which commands are run, their exit code, the time taken, and any unhandled exceptions thrown. Example log lines: 2013/02/09 08:35:19 durham> add foo 2013/02/09 08:35:19 durham> add exited 0 after 0.02 seconds Updates the progress tests because they use a mocked time.time() which these changes affect.
author Durham Goode <durham@fb.com>
date Sat, 09 Feb 2013 09:04:14 -0800
parents e71c2ff93167
children 4f485bd68f1d
comparison
equal deleted inserted replaced
18669:18242716a014 18670:ddc7268da176
245 _("** http://mercurial.selenic.com/wiki/BugTracker\n")) 245 _("** http://mercurial.selenic.com/wiki/BugTracker\n"))
246 warning += ((_("** Python %s\n") % sys.version.replace('\n', '')) + 246 warning += ((_("** Python %s\n") % sys.version.replace('\n', '')) +
247 (_("** Mercurial Distributed SCM (version %s)\n") % myver) + 247 (_("** Mercurial Distributed SCM (version %s)\n") % myver) +
248 (_("** Extensions loaded: %s\n") % 248 (_("** Extensions loaded: %s\n") %
249 ", ".join([x[0] for x in extensions.extensions()]))) 249 ", ".join([x[0] for x in extensions.extensions()])))
250 ui.log("commandexception", "%s\n%s\n", warning, traceback.format_exc())
250 ui.warn(warning) 251 ui.warn(warning)
251 raise 252 raise
252 253
253 return -1 254 return -1
254 255
736 ui.warn(_("warning: --repository ignored\n")) 737 ui.warn(_("warning: --repository ignored\n"))
737 738
738 msg = ' '.join(' ' in a and repr(a) or a for a in fullargs) 739 msg = ' '.join(' ' in a and repr(a) or a for a in fullargs)
739 ui.log("command", msg + "\n") 740 ui.log("command", msg + "\n")
740 d = lambda: util.checksignature(func)(ui, *args, **cmdoptions) 741 d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
741 try: 742 starttime = time.time()
742 return runcommand(lui, repo, cmd, fullargs, ui, options, d, 743 ret = None
743 cmdpats, cmdoptions) 744 try:
745 ret = runcommand(lui, repo, cmd, fullargs, ui, options, d,
746 cmdpats, cmdoptions)
747 return ret
744 finally: 748 finally:
749 duration = time.time() - starttime
750 ui.log("commandfinish", _("%s exited %s after %0.2f seconds\n"),
751 cmd, ret, duration)
745 if repo and repo != req.repo: 752 if repo and repo != req.repo:
746 repo.close() 753 repo.close()
747 754
748 def lsprofile(ui, func, fp): 755 def lsprofile(ui, func, fp):
749 format = ui.config('profiling', 'format', default='text') 756 format = ui.config('profiling', 'format', default='text')