hgext/evolve.py
changeset 1441 a4abe588d77f
parent 1440 afe46c3b15db
child 1442 6a219f8089f9
--- 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                                         ###