Mercurial > public > mercurial-scm > evolve
diff hgext/evolve.py @ 1441:a4abe588d77f
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.
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Wed, 20 May 2015 16:35:45 -0700 |
parents | afe46c3b15db |
children | 6a219f8089f9 |
line wrap: on
line diff
--- a/hgext/evolve.py Mon Jun 22 17:46:32 2015 -0700 +++ b/hgext/evolve.py Wed May 20 16:35:45 2015 -0700 @@ -403,10 +403,22 @@ # 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') evolveopts = ui.configlist('experimental', 'evolution') if evolveopts and (commandopt not in evolveopts and 'all' not in evolveopts): - cmdtable.clear() + # We build whitelist containing the commands we want to enable + 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: %s') % cmd) + elif len(matchingevolvecommands) > 1: + raise error.Abort(_('ambiguous command specification: %s') % cmd) + else: + whitelist.add(matchingevolvecommands[0]) + for disabledcmd in set(cmdtable) - whitelist: + del cmdtable[disabledcmd] ##################################################################### ### experimental behavior ###