comparison mercurial/url.py @ 15077:02734d2baa79 stable

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.
author Renato Cunha <renatoc@gmail.com>
date Thu, 08 Sep 2011 20:40:24 -0300
parents 0593e8f81c71
children d30ec2d16c5a
comparison
equal deleted inserted replaced
15075:77325c92db95 15077:02734d2baa79
91 (proxy.host, proxy.port)) 91 (proxy.host, proxy.port))
92 else: 92 else:
93 proxies = {} 93 proxies = {}
94 94
95 # urllib2 takes proxy values from the environment and those 95 # urllib2 takes proxy values from the environment and those
96 # will take precedence if found, so drop them 96 # will take precedence if found. So, if there's a config entry
97 for env in ["HTTP_PROXY", "http_proxy", "no_proxy"]: 97 # defining a proxy, drop the environment ones
98 try: 98 if ui.config("http_proxy", "host"):
99 if env in os.environ: 99 for env in ["HTTP_PROXY", "http_proxy", "no_proxy"]:
100 del os.environ[env] 100 try:
101 except OSError: 101 if env in os.environ:
102 pass 102 del os.environ[env]
103 except OSError:
104 pass
103 105
104 urllib2.ProxyHandler.__init__(self, proxies) 106 urllib2.ProxyHandler.__init__(self, proxies)
105 self.ui = ui 107 self.ui = ui
106 108
107 def proxy_open(self, req, proxy, type_): 109 def proxy_open(self, req, proxy, type_):