changeset 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 77325c92db95
children d30ec2d16c5a deed405e8980
files mercurial/url.py
diffstat 1 files changed, 9 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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