diff hgext/evolve.py @ 1778:924b76a51d18

wireproto: chunking and compression is forthwith to be handled by hgweb Various functions disappeared in the process. Use the new streamres API but fall back to the old way if the keyword arguments are not accepted. See https://www.mercurial-scm.org/repo/hg/rev/2add671bf55b
author Martijn Pieters <mjpieters@fb.com>
date Wed, 30 Nov 2016 11:17:55 +0000
parents 727c7211c810
children ba9fabaca91b
line wrap: on
line diff
--- a/hgext/evolve.py	Wed Nov 02 18:56:44 2016 +0100
+++ b/hgext/evolve.py	Wed Nov 30 11:17:55 2016 +0000
@@ -3837,6 +3837,17 @@
 def local_pullobsmarkers(self, heads=None, common=None):
     return _getobsmarkersstream(self._repo, heads=heads, common=common)
 
+# 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):
+        wireproto.streamres(proto.groupchunks(d))
+else:
+    # Leave chunking and compression to streamres
+    def streamres(d, proto):
+        wireproto.streamres(reader=d, v1compressible=True)
+
 def srv_pullobsmarkers(repo, proto, others):
     opts = wireproto.options('', ['heads', 'common'], others)
     for k, v in opts.iteritems():
@@ -3848,7 +3859,7 @@
     finaldata.write('%20i' % len(obsdata))
     finaldata.write(obsdata)
     finaldata.seek(0)
-    return wireproto.streamres(proto.groupchunks(finaldata))
+    return streamres(finaldata, proto)
 
 def _obsrelsethashtreefm0(repo):
     return _obsrelsethashtree(repo, obsolete._fm0encodeonemarker)