mercurialmercurial-extension

mercurial : disable all the extensions from the command line


Is there a way for running mercurial without any external extension using a command line switch / environment variable?

For example, in this situation:

$ hg version --debug
Mercurial Distributed SCM (version 4.3.3)
[...]
Enabled extensions:

  hggit             external
  hgremotebranches  external
  mq                internal
  rebase            internal
  shelve            internal

How can I accomplish:

$ hg --disable-all-extensions version --debug
Mercurial Distributed SCM (version 4.3.3)
[...]
Enabled extensions:

  <empty>

I know I can disable individual extensions via --config extensions.name=!, but I need to nuke everything at once.


Solution

  • From hg help environment:

    HGRCPATH
            A list of files or directories to search for configuration files. Item
            separator is ":" on Unix, ";" on Windows. If HGRCPATH is not set,
            platform default search path is used. If empty, only the .hg/hgrc from
            the current repository is read.
    

    So you can do:

    HGRCPATH= hg version --debug
    

    The mercurial developers encourage everyone to use this incantation in scripts to avoid having the meaning of mercurial commands depend on a user's configuration. See http://mozilla-version-control-tools.readthedocs.io/en/latest/hgmozilla/automation.html for more information from Mozilla about automating mercurial.