##// END OF EJS Templates
wireproto: consolidate code for obtaining "cmds" argument value...
Gregory Szorc -
r29733:bb04f96d default
parent child Browse files
Show More
@@ -232,13 +232,7 b' class sshpeer(wireproto.wirepeer):'
232 __del__ = cleanup
232 __del__ = cleanup
233
233
234 def _submitbatch(self, req):
234 def _submitbatch(self, req):
235 cmds = []
235 rsp = self._callstream("batch", cmds=wireproto.encodebatchcmds(req))
236 for op, argsdict in req:
237 args = ','.join('%s=%s' % (wireproto.escapearg(k),
238 wireproto.escapearg(v))
239 for k, v in argsdict.iteritems())
240 cmds.append('%s %s' % (op, args))
241 rsp = self._callstream("batch", cmds=';'.join(cmds))
242 available = self._getamount()
236 available = self._getamount()
243 # TODO this response parsing is probably suboptimal for large
237 # TODO this response parsing is probably suboptimal for large
244 # batches with large responses.
238 # batches with large responses.
@@ -187,6 +187,16 b' def unescapearg(escaped):'
187 .replace(':o', ',')
187 .replace(':o', ',')
188 .replace(':c', ':'))
188 .replace(':c', ':'))
189
189
190 def encodebatchcmds(req):
191 """Return a ``cmds`` argument value for the ``batch`` command."""
192 cmds = []
193 for op, argsdict in req:
194 args = ','.join('%s=%s' % (escapearg(k), escapearg(v))
195 for k, v in argsdict.iteritems())
196 cmds.append('%s %s' % (op, args))
197
198 return ';'.join(cmds)
199
190 # mapping of options accepted by getbundle and their types
200 # mapping of options accepted by getbundle and their types
191 #
201 #
192 # Meant to be extended by extensions. It is extensions responsibility to ensure
202 # Meant to be extended by extensions. It is extensions responsibility to ensure
@@ -226,12 +236,7 b' class wirepeer(peer.peerrepository):'
226
236
227 Returns an iterator of the raw responses from the server.
237 Returns an iterator of the raw responses from the server.
228 """
238 """
229 cmds = []
239 rsp = self._callstream("batch", cmds=encodebatchcmds(req))
230 for op, argsdict in req:
231 args = ','.join('%s=%s' % (escapearg(k), escapearg(v))
232 for k, v in argsdict.iteritems())
233 cmds.append('%s %s' % (op, args))
234 rsp = self._callstream("batch", cmds=';'.join(cmds))
235 chunk = rsp.read(1024)
240 chunk = rsp.read(1024)
236 work = [chunk]
241 work = [chunk]
237 while chunk:
242 while chunk:
General Comments 0
You need to be logged in to leave comments. Login now