Mercurial: Pulling from behind a proxy
I've been playing around with Mercurial and the mercurial hosting website bitbucket a bit this year and recently wanted to pull from a repository from behind a proxy server.
With a bit of help from the mercurial mailing list and the documentation this is how I was able to pull the repository for the Hambread project I've been doing a bit of work on:
hg --config http_proxy.host=ipOfYourProxyServer:portOfYourProxyServer --config http_proxy.user=user --config http_proxy.passwd=password pull http://bitbucket.org/markhneedham/hambread
After that command a 'hg update' updates your local repository with all the changes that have just been pulled.
What I found strange was that you needed to define the '– config' part of the command three times as far as I can tell in order to pass each of the different properties related to the proxy.
I tried just defining it once and just setting the properties individually but that just produced errors.
I'm sure you knew this, but you could add those configurations to your hgrc file as well.
Suresh
15 May 09 at 2:22 pm
Actually I didn't! Would you just put the –config bits into that file then?
Mark Needham
15 May 09 at 4:37 pm
The problem with adding that to your hgrc file is that those settings will be in place for every repo that you want to access. This might not be exactly what you want.
If it is, then hgrc is indeed where it belongs!
OJ
20 May 09 at 12:04 pm
It's a convention in the modern Unix world that any utility creating HTTP connections should obey the "http_proxy" environment variable (and the related "no_proxy" variable).
I don't know which HTTP library Mercurial uses, but all the major libraries support the "http_proxy" variable so it probably works just fine.
@OJ:
I haven't tried it, but I assume that these settings work in a per-repository hgrc (.hg/hgrc). I'd expect to vary my proxy usage more by host or by network connection, though, rather
than by repository.
Rob Hunter
25 May 09 at 5:21 pm
Confirmed that setting http_proxy environment variable works as suggested by Rob
Marcus
5 Jan 10 at 8:36 pm