Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/httprepo.py @ 4134:9dc64c8414ca
Merge with crew-stable
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Sun, 04 Mar 2007 09:03:21 -0300 |
parents | 9210fba03d16 0d94e4a3ddb4 |
children | 0d51eb296fb9 |
comparison
equal
deleted
inserted
replaced
4126:b9dcee25be8e | 4134:9dc64c8414ca |
---|---|
124 | 124 |
125 class httprepository(remoterepository): | 125 class httprepository(remoterepository): |
126 def __init__(self, ui, path): | 126 def __init__(self, ui, path): |
127 self.path = path | 127 self.path = path |
128 self.caps = None | 128 self.caps = None |
129 self.handler = None | |
129 scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path) | 130 scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path) |
130 if query or frag: | 131 if query or frag: |
131 raise util.Abort(_('unsupported URL component: "%s"') % | 132 raise util.Abort(_('unsupported URL component: "%s"') % |
132 (query or frag)) | 133 (query or frag)) |
133 if not urlpath: urlpath = '/' | 134 if not urlpath: urlpath = '/' |
138 urlpath, '', '')) | 139 urlpath, '', '')) |
139 self.ui = ui | 140 self.ui = ui |
140 | 141 |
141 proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy') | 142 proxyurl = ui.config("http_proxy", "host") or os.getenv('http_proxy') |
142 # XXX proxyauthinfo = None | 143 # XXX proxyauthinfo = None |
143 handlers = [httphandler()] | 144 self.handler = httphandler() |
145 handlers = [self.handler] | |
144 | 146 |
145 if proxyurl: | 147 if proxyurl: |
146 # proxy can be proper url or host[:port] | 148 # proxy can be proper url or host[:port] |
147 if not (proxyurl.startswith('http:') or | 149 if not (proxyurl.startswith('http:') or |
148 proxyurl.startswith('https:')): | 150 proxyurl.startswith('https:')): |
196 opener = urllib2.build_opener(*handlers) | 198 opener = urllib2.build_opener(*handlers) |
197 | 199 |
198 # 1.0 here is the _protocol_ version | 200 # 1.0 here is the _protocol_ version |
199 opener.addheaders = [('User-agent', 'mercurial/proto-1.0')] | 201 opener.addheaders = [('User-agent', 'mercurial/proto-1.0')] |
200 urllib2.install_opener(opener) | 202 urllib2.install_opener(opener) |
203 | |
204 def __del__(self): | |
205 if self.handler: | |
206 self.handler.close_all() | |
207 self.handler = None | |
201 | 208 |
202 def url(self): | 209 def url(self): |
203 return self.path | 210 return self.path |
204 | 211 |
205 # look up capabilities only when needed | 212 # look up capabilities only when needed |