142 """ |
142 """ |
143 for cap in proto.getprotocaps(): |
143 for cap in proto.getprotocaps(): |
144 if cap.startswith('comp='): |
144 if cap.startswith('comp='): |
145 return cap[5:].split(',') |
145 return cap[5:].split(',') |
146 return ['zlib', 'none'] |
146 return ['zlib', 'none'] |
147 |
|
148 # mapping of options accepted by getbundle and their types |
|
149 # |
|
150 # Meant to be extended by extensions. It is extensions responsibility to ensure |
|
151 # such options are properly processed in exchange.getbundle. |
|
152 # |
|
153 # supported types are: |
|
154 # |
|
155 # :nodes: list of binary nodes |
|
156 # :csv: list of comma-separated values |
|
157 # :scsv: list of comma-separated values return as set |
|
158 # :plain: string with no transformation needed. |
|
159 gboptsmap = {'heads': 'nodes', |
|
160 'bookmarks': 'boolean', |
|
161 'common': 'nodes', |
|
162 'obsmarkers': 'boolean', |
|
163 'phases': 'boolean', |
|
164 'bundlecaps': 'scsv', |
|
165 'listkeys': 'csv', |
|
166 'cg': 'boolean', |
|
167 'cbattempted': 'boolean', |
|
168 'stream': 'boolean', |
|
169 } |
|
170 |
147 |
171 # client side |
148 # client side |
172 |
149 |
173 class wirepeer(repository.legacypeer): |
150 class wirepeer(repository.legacypeer): |
174 """Client-side interface for communicating with a peer repository. |
151 """Client-side interface for communicating with a peer repository. |
273 opts = {} |
250 opts = {} |
274 bundlecaps = kwargs.get('bundlecaps') or set() |
251 bundlecaps = kwargs.get('bundlecaps') or set() |
275 for key, value in kwargs.iteritems(): |
252 for key, value in kwargs.iteritems(): |
276 if value is None: |
253 if value is None: |
277 continue |
254 continue |
278 keytype = gboptsmap.get(key) |
255 keytype = wireprototypes.GETBUNDLE_ARGUMENTS.get(key) |
279 if keytype is None: |
256 if keytype is None: |
280 raise error.ProgrammingError( |
257 raise error.ProgrammingError( |
281 'Unexpectedly None keytype for key %s' % key) |
258 'Unexpectedly None keytype for key %s' % key) |
282 elif keytype == 'nodes': |
259 elif keytype == 'nodes': |
283 value = wireprototypes.encodelist(value) |
260 value = wireprototypes.encodelist(value) |
1002 return None |
979 return None |
1003 |
980 |
1004 @wireprotocommand('getbundle', '*', permission='pull', |
981 @wireprotocommand('getbundle', '*', permission='pull', |
1005 transportpolicy=POLICY_V1_ONLY) |
982 transportpolicy=POLICY_V1_ONLY) |
1006 def getbundle(repo, proto, others): |
983 def getbundle(repo, proto, others): |
1007 opts = options('getbundle', gboptsmap.keys(), others) |
984 opts = options('getbundle', wireprototypes.GETBUNDLE_ARGUMENTS.keys(), |
|
985 others) |
1008 for k, v in opts.iteritems(): |
986 for k, v in opts.iteritems(): |
1009 keytype = gboptsmap[k] |
987 keytype = wireprototypes.GETBUNDLE_ARGUMENTS[k] |
1010 if keytype == 'nodes': |
988 if keytype == 'nodes': |
1011 opts[k] = wireprototypes.decodelist(v) |
989 opts[k] = wireprototypes.decodelist(v) |
1012 elif keytype == 'csv': |
990 elif keytype == 'csv': |
1013 opts[k] = list(v.split(',')) |
991 opts[k] = list(v.split(',')) |
1014 elif keytype == 'scsv': |
992 elif keytype == 'scsv': |