diff mercurial/httppeer.py @ 37411:3e1688711efd

wireproto: turn client capabilities into sets, sorted on the wire Differential Revision: https://phab.mercurial-scm.org/D3169
author Joerg Sonnenberger <joerg@bec.de>
date Fri, 06 Apr 2018 21:50:01 +0200
parents e826fe7a08c7
children 61e405fb6372
line wrap: on
line diff
--- a/mercurial/httppeer.py	Wed Apr 04 13:43:52 2018 -0700
+++ b/mercurial/httppeer.py	Fri Apr 06 21:50:01 2018 +0200
@@ -282,17 +282,17 @@
         # Tell the server we accept application/mercurial-0.2 and multiple
         # compression formats if the server is capable of emitting those
         # payloads.
-        protoparams = []
+        protoparams = set()
 
         mediatypes = set()
         if self._caps is not None:
             mt = self.capable('httpmediatype')
             if mt:
-                protoparams.append('0.1')
+                protoparams.add('0.1')
                 mediatypes = set(mt.split(','))
 
         if '0.2tx' in mediatypes:
-            protoparams.append('0.2')
+            protoparams.add('0.2')
 
         if '0.2tx' in mediatypes and self.capable('compression'):
             # We /could/ compare supported compression formats and prune
@@ -300,10 +300,10 @@
             # For now, send the full list to the server and have it error.
             comps = [e.wireprotosupport().name for e in
                      util.compengines.supportedwireengines(util.CLIENTROLE)]
-            protoparams.append('comp=%s' % ','.join(comps))
+            protoparams.add('comp=%s' % ','.join(comps))
 
         if protoparams:
-            protoheaders = encodevalueinheaders(' '.join(protoparams),
+            protoheaders = encodevalueinheaders(' '.join(sorted(protoparams)),
                                                 'X-HgProto',
                                                 headersize or 1024)
             for header, value in protoheaders: