##// 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 232 __del__ = cleanup
233 233
234 234 def _submitbatch(self, req):
235 cmds = []
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))
235 rsp = self._callstream("batch", cmds=wireproto.encodebatchcmds(req))
242 236 available = self._getamount()
243 237 # TODO this response parsing is probably suboptimal for large
244 238 # batches with large responses.
@@ -187,6 +187,16 b' def unescapearg(escaped):'
187 187 .replace(':o', ',')
188 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 200 # mapping of options accepted by getbundle and their types
191 201 #
192 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 237 Returns an iterator of the raw responses from the server.
228 238 """
229 cmds = []
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))
239 rsp = self._callstream("batch", cmds=encodebatchcmds(req))
235 240 chunk = rsp.read(1024)
236 241 work = [chunk]
237 242 while chunk:
General Comments 0
You need to be logged in to leave comments. Login now