[PATCH 1 of 3 main] wireprotocol: distinct list and set in getbundle argument

Pierre-Yves David pierre-yves.david at ens-lyon.org
Mon Jun 1 12:34:39 CDT 2015


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1433179720 25200
#      Mon Jun 01 10:28:40 2015 -0700
# Node ID b2f643a640da8176791eebb449c9be85b29aeb72
# Parent  52569d4c494e4e1b57a3fa1873a3a9f133bce8a7
wireprotocol: distinct list and set in getbundle argument

The 'bundlecaps' argument is expected to be a set, but 'listkeys' is expected to
be a list were ordering matters. We introduce a new 'scvs' argument type for the
'set' version and move 'cvs' to the 'list' version.

'test-ssh.t' is changed because this introduced an instability in the order we
were producing listkeys parts.

diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
--- a/mercurial/wireproto.py
+++ b/mercurial/wireproto.py
@@ -201,15 +201,16 @@ def unescapearg(escaped):
 #
 # supported types are:
 #
 # :nodes: list of binary nodes
 # :csv:   list of comma-separated values
+# :scsv:  list of comma-separated values return as set
 # :plain: string with no transformation needed.
 gboptsmap = {'heads':  'nodes',
              'common': 'nodes',
              'obsmarkers': 'boolean',
-             'bundlecaps': 'csv',
+             'bundlecaps': 'scsv',
              'listkeys': 'csv',
              'cg': 'boolean'}
 
 # client side
 
@@ -358,11 +359,11 @@ class wirepeer(peer.peerrepository):
             keytype = gboptsmap.get(key)
             if keytype is None:
                 assert False, 'unexpected'
             elif keytype == 'nodes':
                 value = encodelist(value)
-            elif keytype == 'csv':
+            elif keytype in ('csv', 'scsv'):
                 value = ','.join(value)
             elif keytype == 'boolean':
                 value = '%i' % bool(value)
             elif keytype != 'plain':
                 raise KeyError('unknown getbundle option type %s'
@@ -663,10 +664,12 @@ def getbundle(repo, proto, others):
     for k, v in opts.iteritems():
         keytype = gboptsmap[k]
         if keytype == 'nodes':
             opts[k] = decodelist(v)
         elif keytype == 'csv':
+            opts[k] = list(v.split(','))
+        elif keytype == 'scsv':
             opts[k] = set(v.split(','))
         elif keytype == 'boolean':
             opts[k] = bool(v)
         elif keytype != 'plain':
             raise KeyError('unknown getbundle option type %s'
diff --git a/tests/test-ssh.t b/tests/test-ssh.t
--- a/tests/test-ssh.t
+++ b/tests/test-ssh.t
@@ -464,12 +464,12 @@ debug output
   all remote heads known locally
   no changes found
   sending getbundle command
   bundle2-input-bundle: with-transaction
   bundle2-input-part: "listkeys" (params: 1 mandatory) supported
+  bundle2-input-part: "listkeys" (params: 1 mandatory) supported
   bundle2-input-part: total payload size 45
-  bundle2-input-part: "listkeys" (params: 1 mandatory) supported
   bundle2-input-bundle: 1 parts total
   checking for updated bookmarks
   preparing listkeys for "phases"
   sending listkeys command
   received listkey for "phases": 15 bytes


More information about the Mercurial-devel mailing list