comparison mercurial/httprepo.py @ 2442:c660691fb45d

http: query server for capabilities
author Vadim Gelfer <vadim.gelfer@gmail.com>
date Thu, 15 Jun 2006 17:07:30 -0700
parents e8c4f3d3df8c
children 1b2bbb2b4911
comparison
equal deleted inserted replaced
2441:801dfe0aa53a 2442:c660691fb45d
69 return userpass + '@' + hostport 69 return userpass + '@' + hostport
70 return hostport 70 return hostport
71 71
72 class httprepository(remoterepository): 72 class httprepository(remoterepository):
73 def __init__(self, ui, path): 73 def __init__(self, ui, path):
74 self.capabilities = () 74 self.caps = None
75 scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path) 75 scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path)
76 if query or frag: 76 if query or frag:
77 raise util.Abort(_('unsupported URL component: "%s"') % 77 raise util.Abort(_('unsupported URL component: "%s"') %
78 (query or frag)) 78 (query or frag))
79 if not urlpath: urlpath = '/' 79 if not urlpath: urlpath = '/'
143 143
144 # 1.0 here is the _protocol_ version 144 # 1.0 here is the _protocol_ version
145 opener.addheaders = [('User-agent', 'mercurial/proto-1.0')] 145 opener.addheaders = [('User-agent', 'mercurial/proto-1.0')]
146 urllib2.install_opener(opener) 146 urllib2.install_opener(opener)
147 147
148 # look up capabilities only when needed
149
150 def get_caps(self):
151 if self.caps is None:
152 try:
153 self.caps = self.do_read('capabilities').split()
154 except hg.RepoError:
155 self.caps = ()
156 return self.caps
157
158 capabilities = property(get_caps)
159
148 def dev(self): 160 def dev(self):
149 return -1 161 return -1
150 162
151 def lock(self): 163 def lock(self):
152 raise util.Abort(_('operation not supported over http')) 164 raise util.Abort(_('operation not supported over http'))