[PATCH] dispatch: unify handling of None returned by a command function

Martin von Zweigbergk martinvonz at google.com
Tue May 15 12:50:36 EDT 2018


On Sat, May 12, 2018 at 6:09 AM Yuya Nishihara <yuya at tcha.org> wrote:

> # HG changeset patch
> # User Yuya Nishihara <yuya at tcha.org>
> # Date 1526106789 -32400
> #      Sat May 12 15:33:09 2018 +0900
> # Node ID f5d41abf680b6830b21de4aca1c81532eda36d90
> # Parent  e9c5888025293fc06bc7865e54a11de6b17d12bc
> dispatch: unify handling of None returned by a command function
>
> A command function may return None in place of 0 just for convenience, but
> dispatch() doesn't need to inherit that property. This patch makes it be
> friendly to callers.
>
> diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
> --- a/mercurial/dispatch.py
> +++ b/mercurial/dispatch.py
> @@ -208,9 +208,9 @@ def dispatch(req):
>
>      msg = _formatargs(req.args)
>      starttime = util.timer()
> -    ret = None
> +    ret = -1
>

I think this means that the "ret or 0" on line 242 will no longer ever
evaluate to 0. That code is about blackbox logs, so I think the effect is
that if some command raises an unhandled exception (maybe assertions, for
example), it will instead say "<command> exited -1 after <number> seconds".
That seems like an improvement, since the command failed. However, the
actual error code in this case seems to be 1, so we should probably fix
that.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20180515/6aecda4b/attachment.html>


More information about the Mercurial-devel mailing list