Mark Needham

Thoughts on Software Development

Mercurial: Pulling from behind a proxy

with 6 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.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • HackerNews
  • StumbleUpon
  • Twitter

Written by Mark Needham

May 13th, 2009 at 7:49 am

Posted in Version Control

Tagged with ,

6 Responses to 'Mercurial: Pulling from behind a proxy'

Subscribe to comments with RSS or TrackBack to 'Mercurial: Pulling from behind a proxy'.

  1. 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

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

    Mark Needham

    15 May 09 at 4:37 pm

  3. 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

  4. 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

  5. Confirmed that setting http_proxy environment variable works as suggested by Rob

    Marcus

    5 Jan 10 at 8:36 pm

  6. 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

    Bogdan

    16 Apr 10 at 8:24 am

Leave a Reply