[PATCH evolve-ext] wireproto: chunking and compression is forthwith to be handled by hgweb
Martijn Pieters
mj at zopatista.com
Wed Nov 30 05:50:34 EST 2016
On 29 November 2016 at 23:23, Kostia Balytskyi <ikostia at fb.com> wrote:
>
> This looks good to me, although I would maybe perform a more thorough
check than just catching a TypeError. For example, something like check:
> if “v1compressible” in
wireproto.streamres.__init__.__code__.co_varnames:
> pass this arg
> else:
> don’t pass it
We could just store a test for `proto.groupchunks`:
if util.safehasattr(proto, 'groupchunks'):
streamres = lambda reader:
wireproto.streamres(proto.groupchunks(reader))
else:
streamres = functools.partial(wireproto.streamres,
v1compressible=True)
then use
streamres(reader=finaldata)
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.
> On 11/29/16, 4:10 PM, "Mercurial-devel on behalf of Martijn Pieters" <
mercurial-devel-bounces at mercurial-scm.org on behalf of mj at zopatista.com>
wrote:
>
> # 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://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=
>
> 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
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
>
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=
>
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
--
Martijn Pieters
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.mercurial-scm.org/pipermail/mercurial-devel/attachments/20161130/3e6fcb74/attachment.html>
More information about the Mercurial-devel
mailing list