comparison mercurial/httprepo.py @ 4365:aed9e6dceb85

Avoid float rounding errors when checking http protocol version.
author Thomas Arendsen Hein <thomas@intevation.de>
date Thu, 19 Apr 2007 17:52:42 +0200
parents fffacca46f09
children bf8319ee3428
comparison
equal deleted inserted replaced
4355:c3c53eb44611 4365:aed9e6dceb85
278 raise hg.RepoError(_("'%s' does not appear to be an hg repository") % 278 raise hg.RepoError(_("'%s' does not appear to be an hg repository") %
279 self._url) 279 self._url)
280 280
281 if proto.startswith('application/mercurial-'): 281 if proto.startswith('application/mercurial-'):
282 try: 282 try:
283 version = float(proto[22:]) 283 version = proto.split('-', 1)[1]
284 version_info = tuple([int(n) for n in version.split('.')])
284 except ValueError: 285 except ValueError:
285 raise hg.RepoError(_("'%s' sent a broken Content-type " 286 raise hg.RepoError(_("'%s' sent a broken Content-type "
286 "header (%s)") % (self._url, proto)) 287 "header (%s)") % (self._url, proto))
287 if version > 0.1: 288 if version_info > (0, 1):
288 raise hg.RepoError(_("'%s' uses newer protocol %s") % 289 raise hg.RepoError(_("'%s' uses newer protocol %s") %
289 (self._url, version)) 290 (self._url, version))
290 291
291 return resp 292 return resp
292 293