[PATCH 1 of 5 shelve-ext] shelve: move temporary commit creation to a separate function

Yuya Nishihara yuya at tcha.org
Sat Nov 19 23:10:03 EST 2016


On Sun, 20 Nov 2016 00:42:53 +0000, Kostia Balytskyi wrote:
> On 11/19/16, 10:02 AM, "Yuya Nishihara" <youjah at gmail.com on behalf of yuya at tcha.org> wrote:
> 
>     On Sun, 13 Nov 2016 03:39:34 -0800, Kostia Balytskyi wrote:
>     > # HG changeset patch
>     > # User Kostia Balytskyi <ikostia at fb.com>
>     > # Date 1479036952 28800
>     > #      Sun Nov 13 03:35:52 2016 -0800
>     > # Node ID 45dbc9a803375958310bced301227b02802372b0
>     > # Parent  2188194ca1ee86953855e0d2fb9396ec18636ed9
>     > shelve: move temporary commit creation to a separate function
>     
>     Looks all good. Queued them, thanks.
>     
>     > +def _commitworkingcopychanges(ui, repo, opts, tmpwctx):
>     > +    """Temporarily commit working copy changes before moving unshelve commit"""
>     > +    # Store pending changes in a commit and remember added in case a shelve
>     > +    # contains unknown files that are part of the pending change
>     > +    s = repo.status()
>     > +    addedbefore = frozenset(s.added)
>     > +    if not (s.modified or s.added or s.removed or s.deleted):
>     > +        return tmpwctx, addedbefore
>     > +    ui.status(_("temporarily committing pending changes "
>     > +                "(restore with 'hg unshelve --abort')\n"))
>     > +    commitfunc = getcommitfunc(extra=None, interactive=False,
>     > +                               editor=False)
>     > +    tempopts = {}
>     > +    tempopts['message'] = "pending changes temporary commit"
>     > +    tempopts['date'] = opts.get('date')
>     > +    ui.quiet = True
>     > +    node = cmdutil.commit(ui, repo, commitfunc, [], tempopts)
>     > +    tmpwctx = repo[node]
>     > +    return tmpwctx, addedbefore
>     
>     This and the next unbalanced ui.quiet hack can be a source of future bugs.
>     I hope they'll be fixed by a follow-up patch.

> Can you explain please? I was trying to keep the ui.quiet behavior unchanged in this refactoring series.

You've split set/restore of ui.quiet to separate functions. It's unclear that
we have to care about the state of ui.quiet when adding some code to
_dounshelve(). So IMO, each function should restore ui.quiet at the end.


More information about the Mercurial-devel mailing list