changeset 25403:30ab130af221

wireprotocol: distinguish list and set in getbundle argument The 'bundlecaps' argument is expected to be a set, but 'listkeys' is expected to be a list where ordering matters. We introduce a new 'scsv' argument type for the 'set' version and move 'csv' to the 'list' version. 'test-ssh.t' is changed because this introduced an instability in the order we were producing listkeys parts.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Mon, 01 Jun 2015 10:28:40 -0700
parents 0c2ded041d10
children ff955e7b1085
files mercurial/wireproto.py tests/test-ssh.t
diffstat 2 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/wireproto.py	Mon May 25 17:14:11 2015 -0700
+++ b/mercurial/wireproto.py	Mon Jun 01 10:28:40 2015 -0700
@@ -203,11 +203,12 @@
 #
 # :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'}
 
@@ -360,7 +361,7 @@
                 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)
@@ -665,6 +666,8 @@
         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)
--- a/tests/test-ssh.t	Mon May 25 17:14:11 2015 -0700
+++ b/tests/test-ssh.t	Mon Jun 01 10:28:40 2015 -0700
@@ -466,8 +466,8 @@
   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"