[PATCH 3 of 3 V2] histedit: add histedit.singletransaction config option

Yuya Nishihara yuya at tcha.org
Mon Mar 20 01:53:49 EDT 2017


On Fri, 10 Mar 2017 15:58:05 -0800, Durham Goode wrote:
> # HG changeset patch
> # User Durham Goode <durham at fb.com>
> # Date 1489189949 28800
> #      Fri Mar 10 15:52:29 2017 -0800
> # Node ID 34b22c430d074e57d5293c75349d4651e80dfdce
> # Parent  4046a8f85f7c6b025b986aad9104b73ba2680493
> histedit: add histedit.singletransaction config option

> +By default, histedit will close the transaction after each action. For
> +performance purposes, you can configure histedit to use a single transaction
> +across the entire histedit. WARNING: This setting introduces a significant risk
> +of losing the work you've done in a histedit if the histedit aborts
> +unexpectedly::

This seems scary enough, and the code looks good. Queued, thanks.

> +    try:
> +        # Don't use singletransaction by default since it rolls the entire
> +        # transaction back if an unexpected exception happens (like a
> +        # pretxncommit hook throws, or the user aborts the commit msg editor).
> +        if ui.configbool("histedit", "singletransaction", False):
> +            # Don't use a 'with' for the transaction, since actions may close
> +            # and reopen a transaction. For example, if the action executes an
> +            # external process it may choose to commit the transaction first.
> +            state.tr = repo.transaction('histedit')

I think not using 'with' is good, but have no idea how the transaction can be
reopen.
> +    except error.InterventionRequired:
> +        if state.tr is not None:
> +            state.tr.close()
> +        raise
> +    except Exception:
> +        if state.tr is not None:
> +            state.tr.abort()
> +        raise

Maybe this could be "finally: tr.release()", but I'm not sure which is more
correct.


More information about the Mercurial-devel mailing list