Disable extensions from the Mercurial command line

When working with Mercurial, sometimes you need to access the same repository from multiple hg installations.

For example, currently I’m working on a project on OSX, and need to access the same repo from within a Vagrant environment. In this case, my .hgrc includes

[extensions]
histedit=
...

The HistEdit extension is not available by default in the version of hg in Vagrant, so every (scripted) action that uses Mercurial spews something like:


$ hg branch
*** failed to import extension histedit: No module named histedit
default

One solution is to use a custom hgrc, but an easier solution if you can use it is to use the command line to disable the extension:


$ hg --config extensions.histedit=! branch
default

In this case, setting the extension path to ! disables it entirely.