Mercurial > hg > evolve
changeset 1322:901d2f4b21a9
config: allow disabling commands
Now that upstream Mercurial has multiple options for obsolete configuration, we
can allow enabling and disabling of evolve commands.
author | Durham Goode <durham@fb.com> |
---|---|
date | Wed, 15 Oct 2014 15:41:26 -0700 |
parents | 577f5340be6f |
children | 3d9c5f5df6d8 |
files | hgext/evolve.py tests/test-options.t |
diffstat | 2 files changed, 54 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/evolve.py +++ b/hgext/evolve.py @@ -44,6 +44,8 @@ except (ImportError, AttributeError): gboptslist = gboptsmap = None +# Flags for enabling optional parts of evolve +commandopt = 'commands' from mercurial import base85 from mercurial import bookmarks @@ -353,6 +355,17 @@ 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 ### @@ -959,7 +972,11 @@ 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 @@ -2335,8 +2352,12 @@ @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 --- /dev/null +++ b/tests/test-options.t @@ -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 +