180 |
180 |
181 # batched call argument encoding |
181 # batched call argument encoding |
182 |
182 |
183 def escapearg(plain): |
183 def escapearg(plain): |
184 return (plain |
184 return (plain |
185 .replace(':', '::') |
185 .replace(':', ':c') |
186 .replace(',', ':,') |
186 .replace(',', ':o') |
187 .replace(';', ':;') |
187 .replace(';', ':s') |
188 .replace('=', ':=')) |
188 .replace('=', ':e')) |
189 |
189 |
190 def unescapearg(escaped): |
190 def unescapearg(escaped): |
191 return (escaped |
191 return (escaped |
192 .replace(':=', '=') |
192 .replace(':e', '=') |
193 .replace(':;', ';') |
193 .replace(':s', ';') |
194 .replace(':,', ',') |
194 .replace(':o', ',') |
195 .replace('::', ':')) |
195 .replace(':c', ':')) |
196 |
196 |
197 # mapping of options accepted by getbundle and their types |
197 # mapping of options accepted by getbundle and their types |
198 # |
198 # |
199 # Meant to be extended by extensions. It is extensions responsibility to ensure |
199 # Meant to be extended by extensions. It is extensions responsibility to ensure |
200 # such options are properly processed in exchange.getbundle. |
200 # such options are properly processed in exchange.getbundle. |
219 def batch(self): |
219 def batch(self): |
220 return remotebatch(self) |
220 return remotebatch(self) |
221 def _submitbatch(self, req): |
221 def _submitbatch(self, req): |
222 cmds = [] |
222 cmds = [] |
223 for op, argsdict in req: |
223 for op, argsdict in req: |
224 args = ','.join('%s=%s' % p for p in argsdict.iteritems()) |
224 args = ','.join('%s=%s' % (escapearg(k), escapearg(v)) |
|
225 for k, v in argsdict.iteritems()) |
225 cmds.append('%s %s' % (op, args)) |
226 cmds.append('%s %s' % (op, args)) |
226 rsp = self._call("batch", cmds=';'.join(cmds)) |
227 rsp = self._call("batch", cmds=';'.join(cmds)) |
227 return rsp.split(';') |
228 return [unescapearg(r) for r in rsp.split(';')] |
228 def _submitone(self, op, args): |
229 def _submitone(self, op, args): |
229 return self._call(op, **args) |
230 return self._call(op, **args) |
230 |
231 |
231 @batchable |
232 @batchable |
232 def lookup(self, key): |
233 def lookup(self, key): |