[PATCH 1 of 8] commit: get rid of ui.backupconfig

Martin von Zweigbergk martinvonz at google.com
Thu Mar 16 20:19:15 EDT 2017


On Thu, Mar 16, 2017 at 2:56 PM, Jun Wu <quark at fb.com> wrote:
> # HG changeset patch
> # User Jun Wu <quark at fb.com>
> # Date 1489698920 25200
> #      Thu Mar 16 14:15:20 2017 -0700
> # Node ID def9b72933ce717a48e3cc8fa4934bd3459b9479
> # Parent  5c9cda37d7f6b181ab604c8d5a7592b5553f886b
> # Available At https://bitbucket.org/quark-zju/hg-draft
> #              hg pull https://bitbucket.org/quark-zju/hg-draft -r def9b72933ce
> commit: get rid of ui.backupconfig

Queuing this series with some small changes mentioned below. Thanks. I
will not have time to run tests on all commits before I leave for
home, but I'll push anyway, and will update later tonight if tests
fail.

>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -1703,23 +1703,19 @@ def _docommit(ui, repo, *pats, **opts):
>      else:
>          def commitfunc(ui, repo, message, match, opts):
> -            backup = ui.backupconfig('phases', 'new-commit')
> +            configoverride = {}

The name confused me for a while because it's the same as the method
on ui, but it's not even a function here. I renamed them throughout
the series to "overrides" (plural and no "config" prefix), which seems
more consistent with the rest of the series and with how we usually
pluralize dict-type variables.

> +            if opts.get('secret'):
> +                configoverride[('phases', 'new-commit')] = 'secret'
> +
>              baseui = repo.baseui
> -            basebackup = baseui.backupconfig('phases', 'new-commit')
> -            try:
> -                if opts.get('secret'):
> -                    ui.setconfig('phases', 'new-commit', 'secret', 'commit')
> -                    # Propagate to subrepos
> -                    baseui.setconfig('phases', 'new-commit', 'secret', 'commit')
> -
> -                editform = cmdutil.mergeeditform(repo[None], 'commit.normal')
> -                editor = cmdutil.getcommiteditor(editform=editform, **opts)
> -                return repo.commit(message, opts.get('user'), opts.get('date'),
> -                                   match,
> -                                   editor=editor,
> -                                   extra=extra)
> -            finally:
> -                ui.restoreconfig(backup)
> -                repo.baseui.restoreconfig(basebackup)
> -
> +            with baseui.configoverride(configoverride, 'commit'):
> +                with ui.configoverride(configoverride, 'commit'):
> +                    editform = cmdutil.mergeeditform(repo[None],
> +                                                     'commit.normal')
> +                    editor = cmdutil.getcommiteditor(editform=editform, **opts)
> +                    return repo.commit(message, opts.get('user'),

I wrapped after the first argument too (yes, I know it was
inconsistent before too).

> +                                       opts.get('date'),
> +                                       match,
> +                                       editor=editor,
> +                                       extra=extra)
>
>          node = cmdutil.commit(ui, repo, commitfunc, pats, opts)
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list