# HG changeset patch # User Renato Cunha # Date 2011-09-08 23:40:24 # 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 --git a/mercurial/url.py b/mercurial/url.py --- a/mercurial/url.py +++ b/mercurial/url.py @@ -93,13 +93,15 @@ class proxyhandler(urllib2.ProxyHandler) 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