<div dir="ltr">On 29 November 2016 at 23:23, Kostia Balytskyi <<a href="mailto:ikostia@fb.com">ikostia@fb.com</a>> wrote:<br>><br>> This looks good to me, although I would maybe perform a more thorough check than just catching a TypeError. For example, something like check:<br>>     if “v1compressible” in wireproto.streamres.__init__.__code__.co_varnames:<br>>         pass this arg<br>>     else:<br>>         don’t pass it<br><br><br>We could just store a test for `proto.groupchunks`:<div><br></div><div>    if util.safehasattr(proto, 'groupchunks'):</div><div>        streamres = lambda reader: wireproto.streamres(proto.groupchunks(reader))</div><div>    else:</div><div>        streamres = functools.partial(wireproto.streamres, v1compressible=True)<br><br>then use</div><div><br></div><div>    streamres(reader=finaldata)<br><div><br></div><div>That avoids a) checking for a mercurial version-specific attribute on each send, and b) making it slightly more readable for future maintainers. I'll send a V2.</div><div><br><br>> On 11/29/16, 4:10 PM, "Mercurial-devel on behalf of Martijn Pieters" <<a href="mailto:mercurial-devel-bounces@mercurial-scm.org">mercurial-devel-bounces@mercurial-scm.org</a> on behalf of <a href="mailto:mj@zopatista.com">mj@zopatista.com</a>> wrote:<br>><br>>     # HG changeset patch<br>>     # User Martijn Pieters <<a href="mailto:mjpieters@fb.com">mjpieters@fb.com</a>><br>>     # Date 1480435818 0<br>>     #      Tue Nov 29 16:10:18 2016 +0000<br>>     # Node ID 28a092ed406e930894c59eb88d645221abddc307<br>>     # Parent  cb2bac3253fbd52894ffcb4719a148fe6a3da38b<br>>     wireproto: chunking and compression is forthwith to be handled by hgweb<br>><br>>     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.<br>><br>>     See <a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_repo_hg_rev_2add671bf55b&d=DgIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=Pp-gQYFgs4tKlSFPF5kfCw&m=itsfqjECZoIFxlvcK1F6-xHmasBtG5DrNpHJ5crQ8Qk&s=L9z5Oyy5EDFtbdleAKmWKcYdz4ScmzGLZznUUuk5k_8&e=">https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_repo_hg_rev_2add671bf55b&d=DgIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=Pp-gQYFgs4tKlSFPF5kfCw&m=itsfqjECZoIFxlvcK1F6-xHmasBtG5DrNpHJ5crQ8Qk&s=L9z5Oyy5EDFtbdleAKmWKcYdz4ScmzGLZznUUuk5k_8&e=</a><br>><br>>     diff --git a/hgext/evolve.py b/hgext/evolve.py<br>>     --- a/hgext/evolve.py<br>>     +++ b/hgext/evolve.py<br>>     @@ -3848,7 +3848,12 @@<br>>          finaldata.write('%20i' % len(obsdata))<br>>          finaldata.write(obsdata)<br>>          finaldata.seek(0)<br>>     -    return wireproto.streamres(proto.groupchunks(finaldata))<br>>     +    try:<br>>     +        return wireproto.streamres(reader=finaldata, v1compressible=True)<br>>     +    except TypeError:<br>>     +        # older mercurial version, expected to do our own compression<br>>     +        return wireproto.streamres(proto.groupchunks(finaldata))<br>>     +<br>><br>>      def _obsrelsethashtreefm0(repo):<br>>          return _obsrelsethashtree(repo, obsolete._fm0encodeonemarker)<br>>     diff --git a/hgext/simple4server.py b/hgext/simple4server.py<br>>     --- a/hgext/simple4server.py<br>>     +++ b/hgext/simple4server.py<br>>     @@ -175,7 +175,11 @@<br>>          finaldata.write('%20i' % len(obsdata))<br>>          finaldata.write(obsdata)<br>>          finaldata.seek(0)<br>>     -    return wireproto.streamres(proto.groupchunks(finaldata))<br>>     +    try:<br>>     +        return wireproto.streamres(reader=finaldata, v1compressible=True)<br>>     +    except TypeError:<br>>     +        # older mercurial version, expected to do our own compression<br>>     +        return wireproto.streamres(proto.groupchunks(finaldata))<br>><br>><br>>      # from evolve extension: 3249814dabd1<br>>     _______________________________________________<br>>     Mercurial-devel mailing list<br>>     <a href="mailto:Mercurial-devel@mercurial-scm.org">Mercurial-devel@mercurial-scm.org</a><br>>     <a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_mailman_listinfo_mercurial-2Ddevel&d=DgIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=Pp-gQYFgs4tKlSFPF5kfCw&m=itsfqjECZoIFxlvcK1F6-xHmasBtG5DrNpHJ5crQ8Qk&s=Ja50nSg2ysFrAQC62ZhOs8UsS5w1-omMglM6HYBbfjg&e=">https://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_mailman_listinfo_mercurial-2Ddevel&d=DgIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=Pp-gQYFgs4tKlSFPF5kfCw&m=itsfqjECZoIFxlvcK1F6-xHmasBtG5DrNpHJ5crQ8Qk&s=Ja50nSg2ysFrAQC62ZhOs8UsS5w1-omMglM6HYBbfjg&e=</a><br>><br>><br>> _______________________________________________<br>> Mercurial-devel mailing list<br>> <a href="mailto:Mercurial-devel@mercurial-scm.org">Mercurial-devel@mercurial-scm.org</a><br>> <a href="https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel">https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel</a><br><br><br><br><br>--<br>Martijn Pieters</div></div></div>