Mercurial > hg
changeset 321:73b8a8a059ec
Transparent proxy support
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Transparent proxy support
Originally from "Michael S. Tsirkin" <mst@mellanox.co.il>
manifest hash: 74cf7456ef35ff8d4c007544f0d1a57c69d3c929
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)
iD8DBQFCrSIUywK+sNU5EO8RAje1AJ41ALW8soF78Mo3UTraV1QQvJoFSQCgrqvc
I9ohlI4hzdjOD+wSwRGlERQ=
=Ugfi
-----END PGP SIGNATURE-----
author | mpm@selenic.com |
---|---|
date | Sun, 12 Jun 2005 22:05:08 -0800 |
parents | 292e10b5831a |
children | a0acae914e95 |
files | doc/hg.1.txt mercurial/hg.py |
diffstat | 2 files changed, 47 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/hg.1.txt Sun Jun 12 20:39:08 2005 -0800 +++ b/doc/hg.1.txt Sun Jun 12 22:05:08 2005 -0800 @@ -188,6 +188,22 @@ (which could be a local path or a remote URI), the format is <symbolic name> <repository path> with each mapping on a seperate line +NON_TRANSPARENT PROXY SUPPORT +----- + + To access a mercurial repository through a proxy, + create a file $HOME/.hgrc in the following format: + +[http_proxy] +host=myproxy:8080 +user=<username> +passwd=<password> +no=<localhost1>,<localhost2>,<localhost3>,... + + "user","passwd" fields are used for authenticating proxies, + "no" is a comma-separated list of local host names + for which proxy must be bypassed. + BUGS ---- Probably lots, please post them to the mailing list (See Resources below)
--- a/mercurial/hg.py Sun Jun 12 20:39:08 2005 -0800 +++ b/mercurial/hg.py Sun Jun 12 22:05:08 2005 -0800 @@ -1228,6 +1228,36 @@ def __init__(self, ui, path): self.url = path self.ui = ui + no_list = [ "localhost", "127.0.0.1" ] + host = ui.config("http_proxy", "host") + user = ui.config("http_proxy", "user") + passwd = ui.config("http_proxy", "passwd") + no = ui.config("http_proxy", "no") + if no: + no_list = no_list + no.split(",") + + no_proxy = 0 + for h in no_list: + if (path.startswith("http://" + h + "/") or + path.startswith("http://" + h + ":") or + path == "http://" + h): + no_proxy = 1 + + # Note: urllib2 takes proxy values from the environment and those will + # take precedence + + proxy_handler = urllib2.BaseHandler() + if host and not no_proxy: + proxy_handler = urllib2.ProxyHandler({"http" : "http://" + host}) + + authinfo = None + if user and passwd: + passmgr = urllib2.HTTPPasswordMgrWithDefaultRealm() + passmgr.add_password(None, host, user, passwd) + authinfo = urllib2.ProxyBasicAuthHandler(passmgr) + + opener = urllib2.build_opener(proxy_handler, authinfo) + urllib2.install_opener(opener) def do_cmd(self, cmd, **args): self.ui.debug("sending %s command\n" % cmd) @@ -1235,7 +1265,7 @@ q.update(args) qs = urllib.urlencode(q) cu = "%s?%s" % (self.url, qs) - return urllib.urlopen(cu) + return urllib2.urlopen(cu) def heads(self): d = self.do_cmd("heads").read()