[PATCH 1 of 6 evolve-ext-V2] evolve: mechanism to load some commands selectively
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Fri Jun 5 00:32:25 CDT 2015
On 06/04/2015 04:09 PM, Laurent Charignon wrote:
> # HG changeset patch
> # User Laurent Charignon <lcharignon at fb.com>
> # Date 1432164945 25200
> # Wed May 20 16:35:45 2015 -0700
> # Node ID a72a896bfc902806d3847915f29c2ffe1db8c37b
> # Parent 82dd98428b8d85ea0c9acefebcff40ea59902c66
> evolve: mechanism to load some commands selectively
>
> This patch introduces a new config option: experimental.evolutioncommands to
> load evolve's command selectively.
> It is part of a sequence of patches to make evolve's command respect the value
> of experimental.evolution. Once these commands are ready and actually respect
> the flag, they are safe to use and can be enabled with the mechanism developed
> in this patch.
>
> diff --git a/hgext/evolve.py b/hgext/evolve.py
> --- a/hgext/evolve.py
> +++ b/hgext/evolve.py
> @@ -46,9 +46,6 @@
> except (ImportError, AttributeError):
> gboptslist = gboptsmap = None
>
> -# Flags for enabling optional parts of evolve
> -commandopt = 'allnewcommands'
> -
> from mercurial import bookmarks
> from mercurial import cmdutil
> from mercurial import commands
> @@ -366,10 +363,23 @@
> # This must be in the same function as the option configuration above to
> # guarantee it happens after the above configuration, but before the
> # extsetup functions.
> + evolvecommands = ui.configlist('experimental', 'evolutioncommands')
I would probably set a default value of 'all' here (yes this is a change
compared to the 'commands' entry in evolution.
> evolveopts = ui.configlist('experimental', 'evolution')
> - if evolveopts and (commandopt not in evolveopts and
> - 'all' not in evolveopts):
> - cmdtable.clear()
> + if not evolveopts or 'all' in evolveopts:
> + # Evolve is fully loaded, don't disable commands
> + return
> + else:
> + whitelist = set()
> + for cmd in evolvecommands:
> + matchingevolvecommands = [e for e in cmdtable.keys() if cmd in e]
> + if not matchingevolvecommands:
> + raise error.Abort(_('Unknown command'))
- do not capitalize error message
- If we do not specify the command who is unkown, the user will flip his
laptop.
> + elif len(matchingevolvecommands) > 1:
> + raise error.Abort(_('Ambiguous command specification'))
ditto
> + else:
> + whitelist.add(matchingevolvecommands[0])
> + for disabledcmd in set(cmdtable) - whitelist:
You could also start with disabledcmd and remove element of the set as
they match.
--
Pierre-Yves David
More information about the Mercurial-devel
mailing list