[PATCH V2 evolve-ext] wireproto: chunking and compression is forthwith to be handled by hgweb

Martijn Pieters mj at zopatista.com
Wed Nov 30 11:26:34 UTC 2016


# HG changeset patch
# User Martijn Pieters <mjpieters at fb.com>
# Date 1480504675 0
#      Wed Nov 30 11:17:55 2016 +0000
# Node ID 5bfbd771d6348b10edabfbd2c61f412bb66c87ae
# Parent  cb2bac3253fbd52894ffcb4719a148fe6a3da38b
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

diff --git a/hgext/evolve.py b/hgext/evolve.py
--- a/hgext/evolve.py
+++ b/hgext/evolve.py
@@ -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)
diff --git a/hgext/simple4server.py b/hgext/simple4server.py
--- a/hgext/simple4server.py
+++ b/hgext/simple4server.py
@@ -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


More information about the Mercurial-devel mailing list