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

login
register
mail settings
Submitter Martijn Pieters
Date Nov. 30, 2016, 11:26 a.m.
Message ID <5bfbd771d6348b10edab.1480505194@mjpieters-mbp>
Download mbox | patch
Permalink /patch/17798/
State Accepted
Headers show

Comments

Martijn Pieters - Nov. 30, 2016, 11:26 a.m.
# HG changeset patch
# User Martijn Pieters <mjpieters@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
Kostia Balytskyi - Nov. 30, 2016, 12:32 p.m.
This looks good to me.

On 11/30/16, 11:26 AM, "Mercurial-devel on behalf of Martijn Pieters" <mercurial-devel-bounces@mercurial-scm.org on behalf of mj@zopatista.com> wrote:

    # HG changeset patch
    # User Martijn Pieters <mjpieters@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://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_repo_hg_rev_2add671bf55b&d=DgIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=Pp-gQYFgs4tKlSFPF5kfCw&m=eh7UoQJLleKIlXLG7SxQZ0wZ7Anq0z7vSMVdUR1zfx0&s=_sho53Fr0LJ0WryHbP2N8y4mPGKLmSEAPheNoV5ad54&e= 
    
    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
    _______________________________________________
    Mercurial-devel mailing list
    Mercurial-devel@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=eh7UoQJLleKIlXLG7SxQZ0wZ7Anq0z7vSMVdUR1zfx0&s=yT9FG-ApJKXTq23h612kHxLfohTTYnkwwFOcWvd7jys&e=
Pierre-Yves David - Dec. 17, 2016, 7:57 a.m.
This is pushed, thanks.

On 11/30/2016 01:32 PM, Kostia Balytskyi wrote:
> This looks good to me.
>
> On 11/30/16, 11:26 AM, "Mercurial-devel on behalf of Martijn Pieters" <mercurial-devel-bounces@mercurial-scm.org on behalf of mj@zopatista.com> wrote:
>
>     # HG changeset patch
>     # User Martijn Pieters <mjpieters@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://urldefense.proofpoint.com/v2/url?u=https-3A__www.mercurial-2Dscm.org_repo_hg_rev_2add671bf55b&d=DgIGaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=Pp-gQYFgs4tKlSFPF5kfCw&m=eh7UoQJLleKIlXLG7SxQZ0wZ7Anq0z7vSMVdUR1zfx0&s=_sho53Fr0LJ0WryHbP2N8y4mPGKLmSEAPheNoV5ad54&e=
>
>     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
>     _______________________________________________
>     Mercurial-devel mailing list
>     Mercurial-devel@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=eh7UoQJLleKIlXLG7SxQZ0wZ7Anq0z7vSMVdUR1zfx0&s=yT9FG-ApJKXTq23h612kHxLfohTTYnkwwFOcWvd7jys&e=
>
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

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