Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/sshpeer.py @ 29745:bb04f96df51c
wireproto: consolidate code for obtaining "cmds" argument value
Both wireproto.py and sshpeer.py had code for producing the value to
the "cmds" argument used by the "batch" command. This patch extracts
that code to a standalone function and uses it.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 06 Aug 2016 13:46:28 -0700 |
parents | 0dbd788a2dfd |
children | 764f4581d1f3 |
comparison
equal
deleted
inserted
replaced
29744:0806fa2a39d8 | 29745:bb04f96df51c |
---|---|
230 self.pipee.close() | 230 self.pipee.close() |
231 | 231 |
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. |
245 toread = min(available, 1024) | 239 toread = min(available, 1024) |
246 work = rsp.read(toread) | 240 work = rsp.read(toread) |