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

Martijn Pieters mj at zopatista.com
Tue Nov 29 16:10:45 UTC 2016


# HG changeset patch
# User Martijn Pieters <mjpieters at fb.com>
# Date 1480435818 0
#      Tue Nov 29 16:10:18 2016 +0000
# Node ID 28a092ed406e930894c59eb88d645221abddc307
# 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
@@ -3848,7 +3848,12 @@
     finaldata.write('%20i' % len(obsdata))
     finaldata.write(obsdata)
     finaldata.seek(0)
-    return wireproto.streamres(proto.groupchunks(finaldata))
+    try:
+        return wireproto.streamres(reader=finaldata, v1compressible=True)
+    except TypeError:
+        # older mercurial version, expected to do our own compression
+        return wireproto.streamres(proto.groupchunks(finaldata))
+
 
 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
@@ -175,7 +175,11 @@
     finaldata.write('%20i' % len(obsdata))
     finaldata.write(obsdata)
     finaldata.seek(0)
-    return wireproto.streamres(proto.groupchunks(finaldata))
+    try:
+        return wireproto.streamres(reader=finaldata, v1compressible=True)
+    except TypeError:
+        # older mercurial version, expected to do our own compression
+        return wireproto.streamres(proto.groupchunks(finaldata))
 
 
 # from evolve extension: 3249814dabd1


More information about the Mercurial-devel mailing list