Try hgweb unbundle methods in the order presented by the server.
authorThomas Arendsen Hein <thomas@intevation.de>
Thu, 02 Nov 2006 15:30:45 +0100
changeset 3614 fd7a018b7db7
parent 3613 cbf352b9a3cd
child 3615 1d2fdea875bc
Try hgweb unbundle methods in the order presented by the server. If no common bundle format is found, push is aborted.
mercurial/httprepo.py
--- a/mercurial/httprepo.py	Thu Nov 02 14:58:55 2006 +0100
+++ b/mercurial/httprepo.py	Thu Nov 02 15:30:45 2006 +0100
@@ -350,14 +350,25 @@
         except AttributeError:
             unbundleversions = [""]
 
-        if "HG10GZ" in unbundleversions:
-            header = "HG10GZ"
-            z = zlib.compressobj()
-        else:
-            self.ui.note(_("server has no compression support, "
-                           "sending uncompressed"))
-            header = ""
-            z = nocompress()
+        while unbundleversions:
+            header = unbundleversions[0]
+            if header == "HG10GZ":
+                self.ui.note(_("using zlib compression\n"))
+                z = zlib.compressobj()
+                break
+            elif header == "HG10UN":
+                self.ui.note(_("using no compression\n"))
+                z = nocompress()
+                break
+            elif header == "":
+                self.ui.note(_("old server without compression support,"
+                               " sending uncompressed\n"))
+                z = nocompress()
+                break
+            unbundleversions.pop(0)
+        if not unbundleversions:
+            raise util.Abort(_("The server doesn't accept any bundle format"
+                               " method we know."))
 
         fd, tempname = tempfile.mkstemp(prefix='hg-unbundle-')
         fp = os.fdopen(fd, 'wb+')