##// END OF EJS Templates
Transparent proxy support...
mpm@selenic.com -
r321:73b8a8a0 default
parent child Browse files
Show More
@@ -188,6 +188,22 b' FILES'
188 (which could be a local path or a remote URI), the format is
188 (which could be a local path or a remote URI), the format is
189 <symbolic name> <repository path> with each mapping on a seperate line
189 <symbolic name> <repository path> with each mapping on a seperate line
190
190
191 NON_TRANSPARENT PROXY SUPPORT
192 -----
193
194 To access a mercurial repository through a proxy,
195 create a file $HOME/.hgrc in the following format:
196
197 [http_proxy]
198 host=myproxy:8080
199 user=<username>
200 passwd=<password>
201 no=<localhost1>,<localhost2>,<localhost3>,...
202
203 "user","passwd" fields are used for authenticating proxies,
204 "no" is a comma-separated list of local host names
205 for which proxy must be bypassed.
206
191 BUGS
207 BUGS
192 ----
208 ----
193 Probably lots, please post them to the mailing list (See Resources below)
209 Probably lots, please post them to the mailing list (See Resources below)
@@ -1228,6 +1228,36 b' 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)
@@ -1235,7 +1265,7 b' class remoterepository:'
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()
General Comments 0
You need to be logged in to leave comments. Login now