Authenticating proxy support in mercurial
Thomas Arendsen Hein
thomas at intevation.de
Sat Jun 18 20:58:25 UTC 2005
* Thomas Arendsen Hein <thomas at intevation.de> [20050618 20:51]:
> * Michael S. Tsirkin <mst at mellanox.co.il> [20050609 16:13]:
> > + # urllib2 takes proxy values from the environment and the only
> > + # way to turn proxy access off that I found is this.
> > + os.environ["default_proxy"] = ""
> > + os.environ["http_proxy"] = ""
> > + os.environ["HTTP_PROXY"] = ""
>
> Seems this was a good idea ... urllib2 doesn't obey my $no_proxy
> environment variable, this is what breaks tests/test-pull for me.
>
> Maybe the $no_proxy variable can be translated for urllib2.
Done that, patch attached, pullable from
http://hg.intevation.org/mercurial-tah/
Thomas
--
Email: thomas at intevation.de
http://intevation.de/~thomas/
-------------- next part --------------
# HG changeset patch
# User Thomas Arendsen Hein <thomas at intevation.de>
# Node ID 9294dce4b633fedca293b22858431b9acfc61245
# Parent 25afb21d97ba5fd6dabb7dee41b0a4e08bbf2bea
Allow override of HTTP_PROXY, http_proxy and no_proxy; make no_proxy work.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Allow override of HTTP_PROXY, http_proxy and no_proxy; make no_proxy work.
manifest hash: cfddccef1e8acaa8b06e652e5bbc274d31f0df1d
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFCtIp/W7P1GVgWeRoRAgNRAJ4//Ptbq9Cba7S2L5ltvP92gcijZQCeKuU/
S/togHQXp34v2ypVH+8wyP4=
=jpn2
-----END PGP SIGNATURE-----
diff -r 25afb21d97ba -r 9294dce4b633 mercurial/hg.py
--- a/mercurial/hg.py Sat Jun 18 15:32:41 2005
+++ b/mercurial/hg.py Sat Jun 18 20:56:31 2005
@@ -1331,9 +1331,13 @@
self.ui = ui
no_list = [ "localhost", "127.0.0.1" ]
host = ui.config("http_proxy", "host")
+ if host is None:
+ host = os.environ.get("http_proxy")
user = ui.config("http_proxy", "user")
passwd = ui.config("http_proxy", "passwd")
no = ui.config("http_proxy", "no")
+ if no is None:
+ no = os.environ.get("no_proxy")
if no:
no_list = no_list + no.split(",")
@@ -1346,6 +1350,9 @@
# Note: urllib2 takes proxy values from the environment and those will
# take precedence
+ for env in ["HTTP_PROXY", "http_proxy", "no_proxy"]:
+ if os.environ.has_key(env):
+ del os.environ[env]
proxy_handler = urllib2.BaseHandler()
if host and not no_proxy:
More information about the Mercurial
mailing list