Comments
Patch
@@ -42,6 +42,8 @@ try:
except (ImportError, AttributeError):
gboptslist = gboptsmap = None
+# Flags for enabling optional parts of evolve
+commandopt = 'commands'
from mercurial import base85
from mercurial import bookmarks
@@ -337,6 +339,17 @@ def _configureoptions(ui, repo):
evolveopts = ['all']
ui.setconfig('experimental', 'evolution', evolveopts)
+@eh.uisetup
+def _configurecmdoptions(ui):
+ # Unregister evolve commands if the command capability is not specified.
+ #
+ # 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.
+ evolveopts = ui.configlist('experimental', 'evolution')
+ if evolveopts and (commandopt not in evolveopts and
+ 'all' not in evolveopts):
+ cmdtable.clear()
#####################################################################
### experimental behavior ###
@@ -943,7 +956,11 @@ def _deprecatealias(oldalias, newalias):
This function is loosely based on the extensions.wrapcommand function.
'''
- aliases, entry = cmdutil.findcmd(newalias, cmdtable)
+ try:
+ aliases, entry = cmdutil.findcmd(newalias, cmdtable)
+ except error.UnknownCommand:
+ # Commands may be disabled
+ return
for alias, e in cmdtable.iteritems():
if e is entry:
break
@@ -2273,8 +2290,12 @@ def graftwrapper(orig, ui, repo, *revs,
@eh.extsetup
def oldevolveextsetup(ui):
for cmd in ['kill', 'uncommit', 'touch', 'fold']:
- entry = extensions.wrapcommand(cmdtable, cmd,
- warnobserrors)
+ try:
+ entry = extensions.wrapcommand(cmdtable, cmd,
+ warnobserrors)
+ except error.UnknownCommand:
+ # Commands may be disabled
+ continue
entry = cmdutil.findcmd('commit', commands.table)[1]
entry[1].append(('o', 'obsolete', [],
new file mode 100644
@@ -0,0 +1,30 @@
+ $ cat >> $HGRCPATH <<EOF
+ > [ui]
+ > logtemplate={rev}:{node|short}[{bookmarks}] ({obsolete}/{phase}) {desc|firstline}\n
+ > [extensions]
+ > EOF
+ $ echo "evolve=$(echo $(dirname $TESTDIR))/hgext/evolve.py" >> $HGRCPATH
+
+ $ mkcommit() {
+ > echo "$1" > "$1"
+ > hg add "$1"
+ > hg ci -m "add $1"
+ > }
+
+ $ hg init repo
+ $ cd repo
+ $ mkcommit a
+ $ mkcommit b
+
+test disabling commands
+
+ $ cat >> .hg/hgrc <<EOF
+ > [experimental]
+ > evolution=createmarkers
+ > allowunstable
+ > exchange
+ > EOF
+ $ hg prune | head -n 2
+ hg: unknown command 'prune'
+ Mercurial Distributed SCM
+