# HG changeset patch # User Renato Cunha # Date 1315525224 10800 # Node ID 02734d2baa79e0a08cc5fe20a1a59a31710348cf # Parent 77325c92db951e6bcc8a866fb1139178b968d5a2 url: Remove the proxy env variables only when needed (issue2451) This is an attempt to fix issue 2451 and its duplicates (2599 and 2949, AFAIK). Its main idea is that it is only necessary to clean the proxy environment variables *when* http_proxy is set in the config file (since it takes precedence over the environment variables). Otherwise, hg shouldn't bother with them, since they will most likely be used to reach the server. diff -r 77325c92db95 -r 02734d2baa79 mercurial/url.py --- a/mercurial/url.py Sat Sep 10 13:23:41 2011 +0100 +++ b/mercurial/url.py Thu Sep 08 20:40:24 2011 -0300 @@ -93,13 +93,15 @@ proxies = {} # urllib2 takes proxy values from the environment and those - # will take precedence if found, so drop them - for env in ["HTTP_PROXY", "http_proxy", "no_proxy"]: - try: - if env in os.environ: - del os.environ[env] - except OSError: - pass + # will take precedence if found. So, if there's a config entry + # defining a proxy, drop the environment ones + if ui.config("http_proxy", "host"): + for env in ["HTTP_PROXY", "http_proxy", "no_proxy"]: + try: + if env in os.environ: + del os.environ[env] + except OSError: + pass urllib2.ProxyHandler.__init__(self, proxies) self.ui = ui