Mark Needham

Thoughts on Software Development

Mercurial: Pulling from behind a proxy

with 7 comments

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.

Written by Mark Needham

May 13th, 2009 at 7:49 am

Posted in Version Control

Tagged with ,

  • Suresh

    I’m sure you knew this, but you could add those configurations to your hgrc file as well.

  • http://www.markhneedham.com Mark Needham

    Actually I didn’t! Would you just put the –config bits into that file then?

  • http://buffered.io/ OJ

    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!

  • http://twitter.com/rjhunter Rob Hunter

    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.

  • Marcus

    Confirmed that setting http_proxy environment variable works as suggested by Rob

  • http://www.gridpulse.com Bogdan

    Thank, it works great.
    If you’re in a Windows domain you have to specify the domain part of the user also – like –config http_proxy.user=DOMAIN\UserName

  • http://twitter.com/ralgozino Ramiro Algozino

    Thanks!