Mercurial > public > mercurial-scm > hg
comparison mercurial/wireproto.py @ 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 | c50655b9c856 |
children | d8e7b0781ad7 |
comparison
equal
deleted
inserted
replaced
25402:0c2ded041d10 | 25403:30ab130af221 |
---|---|
201 # | 201 # |
202 # supported types are: | 202 # supported types are: |
203 # | 203 # |
204 # :nodes: list of binary nodes | 204 # :nodes: list of binary nodes |
205 # :csv: list of comma-separated values | 205 # :csv: list of comma-separated values |
206 # :scsv: list of comma-separated values return as set | |
206 # :plain: string with no transformation needed. | 207 # :plain: string with no transformation needed. |
207 gboptsmap = {'heads': 'nodes', | 208 gboptsmap = {'heads': 'nodes', |
208 'common': 'nodes', | 209 'common': 'nodes', |
209 'obsmarkers': 'boolean', | 210 'obsmarkers': 'boolean', |
210 'bundlecaps': 'csv', | 211 'bundlecaps': 'scsv', |
211 'listkeys': 'csv', | 212 'listkeys': 'csv', |
212 'cg': 'boolean'} | 213 'cg': 'boolean'} |
213 | 214 |
214 # client side | 215 # client side |
215 | 216 |
358 keytype = gboptsmap.get(key) | 359 keytype = gboptsmap.get(key) |
359 if keytype is None: | 360 if keytype is None: |
360 assert False, 'unexpected' | 361 assert False, 'unexpected' |
361 elif keytype == 'nodes': | 362 elif keytype == 'nodes': |
362 value = encodelist(value) | 363 value = encodelist(value) |
363 elif keytype == 'csv': | 364 elif keytype in ('csv', 'scsv'): |
364 value = ','.join(value) | 365 value = ','.join(value) |
365 elif keytype == 'boolean': | 366 elif keytype == 'boolean': |
366 value = '%i' % bool(value) | 367 value = '%i' % bool(value) |
367 elif keytype != 'plain': | 368 elif keytype != 'plain': |
368 raise KeyError('unknown getbundle option type %s' | 369 raise KeyError('unknown getbundle option type %s' |
663 for k, v in opts.iteritems(): | 664 for k, v in opts.iteritems(): |
664 keytype = gboptsmap[k] | 665 keytype = gboptsmap[k] |
665 if keytype == 'nodes': | 666 if keytype == 'nodes': |
666 opts[k] = decodelist(v) | 667 opts[k] = decodelist(v) |
667 elif keytype == 'csv': | 668 elif keytype == 'csv': |
669 opts[k] = list(v.split(',')) | |
670 elif keytype == 'scsv': | |
668 opts[k] = set(v.split(',')) | 671 opts[k] = set(v.split(',')) |
669 elif keytype == 'boolean': | 672 elif keytype == 'boolean': |
670 opts[k] = bool(v) | 673 opts[k] = bool(v) |
671 elif keytype != 'plain': | 674 elif keytype != 'plain': |
672 raise KeyError('unknown getbundle option type %s' | 675 raise KeyError('unknown getbundle option type %s' |