[PATCH 1 of 9] atexit: add special-purpose atexit functionality to util

Yuya Nishihara yuya at tcha.org
Tue Apr 11 09:48:59 EDT 2017


On Mon, 10 Apr 2017 11:51:31 -0700, Bryan O'Sullivan wrote:
> # HG changeset patch
> # User Bryan O'Sullivan <bryano at fb.com>
> # Date 1490914899 25200
> #      Thu Mar 30 16:01:39 2017 -0700
> # Node ID fdc0de79d651dccee118d19cb6b04f58d33a2727
> # Parent  e0dc40530c5aa514feb6a09cf79ab6a3aa2ec331
> atexit: add special-purpose atexit functionality to util

> diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
> --- a/mercurial/dispatch.py
> +++ b/mercurial/dispatch.py
> @@ -146,8 +146,28 @@ def dispatch(req):
>              req.ui.log('uiblocked', 'ui blocked ms', **req.ui._blockedtimes)
>          req.ui.log("commandfinish", "%s exited %s after %0.2f seconds\n",
>                     msg, ret or 0, duration)
> +        try:
> +            _runexithandlers(req.ui)
> +        except: # exiting, so no re-raises
> +            ret = ret or 1

Perhaps -1 (= 255) would be better since 1 generally means expected failure.

> +    finally:
> +        if excinfo is not None:
> +            raise excinfo[0], excinfo[1], excinfo[2]

This breaks everything on Python 3. I generally don't want to reject patches
because of Py3 breakage, but this is syntax error and wouldn't be trivially
fixed in flight.

We'll need to extract a helper function from e584c6235500. Pulkit?


More information about the Mercurial-devel mailing list