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

Yuya Nishihara yuya at tcha.org
Wed May 16 07:09:18 EDT 2018


On Tue, 15 May 2018 09:50:36 -0700, Martin von Zweigbergk wrote:
> 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.

Good catch. I'll send a patch shortly.


More information about the Mercurial-devel mailing list