hgext/simple4server.py
changeset 1778 924b76a51d18
parent 1757 86e71a0b3319
--- a/hgext/simple4server.py	Wed Nov 02 18:56:44 2016 +0100
+++ b/hgext/simple4server.py	Wed Nov 30 11:17:55 2016 +0000
@@ -158,6 +158,17 @@
             seennodes |= pendingnodes
         return seenmarkers
 
+# The wireproto.streamres API changed, handling chunking and compression
+# directly. Handle either case.
+if util.safehasattr(wireproto.abstractserverproto, 'groupchunks'):
+    # We need to handle chunking and compression directly
+    def streamres(d, proto):
+        return wireproto.streamres(proto.groupchunks(d))
+else:
+    # Leave chunking and compression to streamres
+    def streamres(d, proto):
+        return wireproto.streamres(reader=d, v1compressible=True)
+
 # from evolve extension: cf35f38d6a10
 def srv_pullobsmarkers(repo, proto, others):
     """serves a binary stream of markers.
@@ -175,7 +186,7 @@
     finaldata.write('%20i' % len(obsdata))
     finaldata.write(obsdata)
     finaldata.seek(0)
-    return wireproto.streamres(proto.groupchunks(finaldata))
+    return streamres(finaldata, proto)
 
 
 # from evolve extension: 3249814dabd1