mercurial/httprepo.py
changeset 4016 a195f11ed1a2
parent 3893 6b4127c7d52a
parent 4012 d1e31d7f7d44
child 4029 9210fba03d16
equal deleted inserted replaced
4007:20da40cc1c73 4016:a195f11ed1a2
   254             proto = resp.getheader('content-type')
   254             proto = resp.getheader('content-type')
   255         except AttributeError:
   255         except AttributeError:
   256             proto = resp.headers['content-type']
   256             proto = resp.headers['content-type']
   257 
   257 
   258         # accept old "text/plain" and "application/hg-changegroup" for now
   258         # accept old "text/plain" and "application/hg-changegroup" for now
   259         if not proto.startswith('application/mercurial') and \
   259         if not proto.startswith('application/mercurial-') and \
   260                not proto.startswith('text/plain') and \
   260                not proto.startswith('text/plain') and \
   261                not proto.startswith('application/hg-changegroup'):
   261                not proto.startswith('application/hg-changegroup'):
   262             raise hg.RepoError(_("'%s' does not appear to be an hg repository") %
   262             raise hg.RepoError(_("'%s' does not appear to be an hg repository") %
   263                                self._url)
   263                                self._url)
   264 
   264 
   265         if proto.startswith('application/mercurial'):
   265         if proto.startswith('application/mercurial-'):
   266             version = proto[22:]
   266             try:
   267             if float(version) > 0.1:
   267                 version = float(proto[22:])
       
   268             except ValueError:
       
   269                 raise hg.RepoError(_("'%s' sent a broken Content-type "
       
   270                                      "header (%s)") % (self._url, proto))
       
   271             if version > 0.1:
   268                 raise hg.RepoError(_("'%s' uses newer protocol %s") %
   272                 raise hg.RepoError(_("'%s' uses newer protocol %s") %
   269                                    (self._url, version))
   273                                    (self._url, version))
   270 
   274 
   271         return resp
   275         return resp
   272 
   276