Avoid float rounding errors when checking http protocol version.
authorThomas Arendsen Hein <thomas@intevation.de>
Thu, 19 Apr 2007 17:52:42 +0200
changeset 4356 aed9e6dceb85
parent 4354 c3c53eb44611
child 4357 3f1b0c0fb4fd
child 4369 bf8319ee3428
Avoid float rounding errors when checking http protocol version.
mercurial/httprepo.py
--- a/mercurial/httprepo.py	Mon Apr 16 12:27:49 2007 -0500
+++ b/mercurial/httprepo.py	Thu Apr 19 17:52:42 2007 +0200
@@ -280,11 +280,12 @@
 
         if proto.startswith('application/mercurial-'):
             try:
-                version = float(proto[22:])
+                version = proto.split('-', 1)[1]
+                version_info = tuple([int(n) for n in version.split('.')])
             except ValueError:
                 raise hg.RepoError(_("'%s' sent a broken Content-type "
                                      "header (%s)") % (self._url, proto))
-            if version > 0.1:
+            if version_info > (0, 1):
                 raise hg.RepoError(_("'%s' uses newer protocol %s") %
                                    (self._url, version))