Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/hg.py @ 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 | b18ce742566a |
children | ce81bdd91d06 |
comparison
equal
deleted
inserted
replaced
320:292e10b5831a | 321:73b8a8a059ec |
---|---|
1226 | 1226 |
1227 class remoterepository: | 1227 class remoterepository: |
1228 def __init__(self, ui, path): | 1228 def __init__(self, ui, path): |
1229 self.url = path | 1229 self.url = path |
1230 self.ui = ui | 1230 self.ui = ui |
1231 no_list = [ "localhost", "127.0.0.1" ] | |
1232 host = ui.config("http_proxy", "host") | |
1233 user = ui.config("http_proxy", "user") | |
1234 passwd = ui.config("http_proxy", "passwd") | |
1235 no = ui.config("http_proxy", "no") | |
1236 if no: | |
1237 no_list = no_list + no.split(",") | |
1238 | |
1239 no_proxy = 0 | |
1240 for h in no_list: | |
1241 if (path.startswith("http://" + h + "/") or | |
1242 path.startswith("http://" + h + ":") or | |
1243 path == "http://" + h): | |
1244 no_proxy = 1 | |
1245 | |
1246 # Note: urllib2 takes proxy values from the environment and those will | |
1247 # take precedence | |
1248 | |
1249 proxy_handler = urllib2.BaseHandler() | |
1250 if host and not no_proxy: | |
1251 proxy_handler = urllib2.ProxyHandler({"http" : "http://" + host}) | |
1252 | |
1253 authinfo = None | |
1254 if user and passwd: | |
1255 passmgr = urllib2.HTTPPasswordMgrWithDefaultRealm() | |
1256 passmgr.add_password(None, host, user, passwd) | |
1257 authinfo = urllib2.ProxyBasicAuthHandler(passmgr) | |
1258 | |
1259 opener = urllib2.build_opener(proxy_handler, authinfo) | |
1260 urllib2.install_opener(opener) | |
1231 | 1261 |
1232 def do_cmd(self, cmd, **args): | 1262 def do_cmd(self, cmd, **args): |
1233 self.ui.debug("sending %s command\n" % cmd) | 1263 self.ui.debug("sending %s command\n" % cmd) |
1234 q = {"cmd": cmd} | 1264 q = {"cmd": cmd} |
1235 q.update(args) | 1265 q.update(args) |
1236 qs = urllib.urlencode(q) | 1266 qs = urllib.urlencode(q) |
1237 cu = "%s?%s" % (self.url, qs) | 1267 cu = "%s?%s" % (self.url, qs) |
1238 return urllib.urlopen(cu) | 1268 return urllib2.urlopen(cu) |
1239 | 1269 |
1240 def heads(self): | 1270 def heads(self): |
1241 d = self.do_cmd("heads").read() | 1271 d = self.do_cmd("heads").read() |
1242 try: | 1272 try: |
1243 return map(bin, d[:-1].split(" ")) | 1273 return map(bin, d[:-1].split(" ")) |