Mercurial > hg
comparison mercurial/dispatch.py @ 19229:41e39a0299cb stable
blackbox: fix recording exit codes (issue3938)
Previously the blackbox wrapped runcommand, but this failed to see the error
codes that were created if an exception occurred. I moved that logging to now
wrap _runcatch, so it can observe and log the actual error code (such as when
a user ctrl+c's during a command).
Updated the tests as well. Tested the change by running all the tests with the
blackbox extension enabled and verifying nothing broke (aside from things that
printed what extensions were enabeld).
The progress tests are affected by calls to time.time() so they needed to be
updated to pass.
author | Durham Goode <durham@fb.com> |
---|---|
date | Wed, 22 May 2013 17:31:47 -0700 |
parents | fc081623f4bd |
children | 09573ad59f7b |
comparison
equal
deleted
inserted
replaced
19224:e9b571a8c67f | 19229:41e39a0299cb |
---|---|
60 (inst.args[1], inst.args[0])) | 60 (inst.args[1], inst.args[0])) |
61 else: | 61 else: |
62 ferr.write(_("hg: parse error: %s\n") % inst.args[0]) | 62 ferr.write(_("hg: parse error: %s\n") % inst.args[0]) |
63 return -1 | 63 return -1 |
64 | 64 |
65 return _runcatch(req) | 65 msg = ' '.join(' ' in a and repr(a) or a for a in req.args) |
66 starttime = time.time() | |
67 ret = None | |
68 try: | |
69 ret = _runcatch(req) | |
70 return ret | |
71 finally: | |
72 duration = time.time() - starttime | |
73 req.ui.log("commandfinish", "%s exited %s after %0.2f seconds\n", | |
74 msg, ret or 0, duration) | |
66 | 75 |
67 def _runcatch(req): | 76 def _runcatch(req): |
68 def catchterm(*args): | 77 def catchterm(*args): |
69 raise error.SignalInterrupt | 78 raise error.SignalInterrupt |
70 | 79 |
762 ui.warn(_("warning: --repository ignored\n")) | 771 ui.warn(_("warning: --repository ignored\n")) |
763 | 772 |
764 msg = ' '.join(' ' in a and repr(a) or a for a in fullargs) | 773 msg = ' '.join(' ' in a and repr(a) or a for a in fullargs) |
765 ui.log("command", '%s\n', msg) | 774 ui.log("command", '%s\n', msg) |
766 d = lambda: util.checksignature(func)(ui, *args, **cmdoptions) | 775 d = lambda: util.checksignature(func)(ui, *args, **cmdoptions) |
767 starttime = time.time() | 776 try: |
768 ret = None | 777 return runcommand(lui, repo, cmd, fullargs, ui, options, d, |
769 try: | 778 cmdpats, cmdoptions) |
770 ret = runcommand(lui, repo, cmd, fullargs, ui, options, d, | |
771 cmdpats, cmdoptions) | |
772 return ret | |
773 finally: | 779 finally: |
774 duration = time.time() - starttime | |
775 ui.log("commandfinish", "%s exited %s after %0.2f seconds\n", | |
776 cmd, ret, duration) | |
777 if repo and repo != req.repo: | 780 if repo and repo != req.repo: |
778 repo.close() | 781 repo.close() |
779 | 782 |
780 def lsprofile(ui, func, fp): | 783 def lsprofile(ui, func, fp): |
781 format = ui.config('profiling', 'format', default='text') | 784 format = ui.config('profiling', 'format', default='text') |