3

Where to install mercurial extensions so you do not have to specify their path in .hgrc?

The documentation says that you can put them in mercurial path, but that's not clear what it is.

I want to install some extensions so they are available to mercurial to any user form that machine, without having to modify each user .hgrc file.

Note: I am interested about a solution for Ubuntu, Debian and Centos, if this matters.

Details: One of the extensions that I do want to deploy is the https://bitbucket.org/facebook/remotefilelog which was made by Facebook but suprisnly they missing the publish it on PyPi.

sorin
  • 161,544
  • 178
  • 535
  • 806

1 Answers1

3

First, if you want to install extensions globally, your best choice may be to do this in the global hgrc file rather than having users do it locally. If you enable an extension in /etc/mercurial/hgrc, then it will be enabled for all users.

You can also enable them in <install-root>/etc/mercurial/hgrc, where <install-root> is the parent directory of the directory where the Mercurial executable is installed. E.g., if Mercurial is executed via /opt/local/bin/hg, then <install-root> is /opt/local. However, this is more fragile, since (by design) symbolic links aren't followed. For example, if a user links Mercurial to their ~/bin/hg, then ~/etc/mercurial/hgrc would be consulted instead for them.

If you simply want to make extensions available to user, but not enable them by default, then they have to go in the Python site-packages directory, same as the normal extensions. This would be your global Python installation, assuming Mercurial uses that; however, you can use virtualenv to have a Mercurial-specific Python installation, where you can install extensions and other stuff without polluting the main Python installation. The normal setup.py script of an extension should properly deal with either case (e.g., the setup.py of the evolve extension will put evolve.py in the site-packages/hgext directory).

Reimer Behrends
  • 8,600
  • 15
  • 19
  • If you use the virtualenv approach, you can just install evolve inside the virtual environment. Otherwise, you should always be able to specify the extension via an absolute path, i.e. something like `evolve=/path/to/evolve.py`. – Reimer Behrends Jul 23 '15 at 13:07
  • You can install it in the virtual environment simply by doing `/path/to/virtualenv/bin/python setup.py install`, at which point just using `evolve=` in your `~/.hgrc` will work. Without a virtual environment, if you want to make the extension easily accessible, but not enabled by default, you'll need to install it in the site-packages directory of the Python installation that Mercurial is using also. – Reimer Behrends Jul 23 '15 at 18:00
  • You are correct: I had a broken install. Your answer works. (I will delete my comment shortly since they are unlikely to be of use for others.) – mforbes Jul 24 '15 at 02:33