changeset 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 cb2bac3253fb
children ba9fabaca91b
files README hgext/evolve.py hgext/simple4server.py
diffstat 3 files changed, 28 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/README	Wed Nov 02 18:56:44 2016 +0100
+++ b/README	Wed Nov 30 11:17:55 2016 +0000
@@ -56,6 +56,10 @@
 Changelog
 =========
 
+5.6.0 --
+
+ - compatibility with Mercurial 4.1.
+
 5.5.0 -- 2016-10-30
 
  - The {obsolete} template now yield "obsolete" or "".
--- 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)
--- 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