The **args being used to pass arbitrary command arguments is limiting
because it makes it harder to control behavior of the function.
We factor most of _callstream() into a new function that doesn't
use **args.
yuja |
hg-reviewers |
The **args being used to pass arbitrary command arguments is limiting
because it makes it harder to control behavior of the function.
We factor most of _callstream() into a new function that doesn't
use **args.
Lint Skipped |
Unit Tests Skipped |
one, work = work.split(';', 1) | one, work = work.split(';', 1) | ||||
yield wireproto.unescapearg(one) | yield wireproto.unescapearg(one) | ||||
toread = min(available, 1024) | toread = min(available, 1024) | ||||
chunk = rsp.read(toread) | chunk = rsp.read(toread) | ||||
available -= toread | available -= toread | ||||
work += chunk | work += chunk | ||||
yield wireproto.unescapearg(work) | yield wireproto.unescapearg(work) | ||||
def _callstream(self, cmd, **args): | def _sendrequest(self, cmd, args): | ||||
args = pycompat.byteskwargs(args) | |||||
if (self.ui.debugflag | if (self.ui.debugflag | ||||
and self.ui.configbool('devel', 'debug.peer-request')): | and self.ui.configbool('devel', 'debug.peer-request')): | ||||
dbg = self.ui.debug | dbg = self.ui.debug | ||||
line = 'devel-peer-request: %s\n' | line = 'devel-peer-request: %s\n' | ||||
dbg(line % cmd) | dbg(line % cmd) | ||||
for key, value in sorted(args.items()): | for key, value in sorted(args.items()): | ||||
if not isinstance(value, dict): | if not isinstance(value, dict): | ||||
dbg(line % ' %s: %d bytes' % (key, len(value))) | dbg(line % ' %s: %d bytes' % (key, len(value))) | ||||
self._pipeo.write("%s %d\n" % (dk, len(dv))) | self._pipeo.write("%s %d\n" % (dk, len(dv))) | ||||
self._pipeo.write(dv) | self._pipeo.write(dv) | ||||
else: | else: | ||||
self._pipeo.write(v) | self._pipeo.write(v) | ||||
self._pipeo.flush() | self._pipeo.flush() | ||||
return self._pipei | return self._pipei | ||||
def _callstream(self, cmd, **args): | |||||
args = pycompat.byteskwargs(args) | |||||
return self._sendrequest(cmd, args) | |||||
def _callcompressable(self, cmd, **args): | def _callcompressable(self, cmd, **args): | ||||
return self._callstream(cmd, **args) | args = pycompat.byteskwargs(args) | ||||
return self._sendrequest(cmd, args) | |||||
def _call(self, cmd, **args): | def _call(self, cmd, **args): | ||||
self._callstream(cmd, **args) | args = pycompat.byteskwargs(args) | ||||
self._sendrequest(cmd, args) | |||||
return self._readframed() | return self._readframed() | ||||
def _callpush(self, cmd, fp, **args): | def _callpush(self, cmd, fp, **args): | ||||
r = self._call(cmd, **args) | r = self._call(cmd, **args) | ||||
if r: | if r: | ||||
return '', r | return '', r | ||||
for d in iter(lambda: fp.read(4096), ''): | for d in iter(lambda: fp.read(4096), ''): | ||||
self._writeframed(d) | self._writeframed(d) |