Mercurial > public > mercurial-scm > hg-stable
diff mercurial/wireprotoserver.py @ 37414:2d965bfeb8f6
wireproto: allow direct stream processing for unbundle
Introduce a new option server.streamunbundle which starts a transaction
immediately to apply a bundle instead of writing it to a temporary file
first. This side steps the need for a large tmp directory at the cost of
preventing concurrent pushes. This is a reasonable trade-off for many
setups as concurrent pushes for the main branch at least are disallowed
anyway. The option defaults to off to preserve existing behavior.
Change the wireproto interface to provide a generator for reading the
payload and make callers responsible for consuming all data.
Differential Revision: https://phab.mercurial-scm.org/D2470
author | Joerg Sonnenberger <joerg@bec.de> |
---|---|
date | Tue, 27 Feb 2018 02:37:31 +0100 |
parents | afcfdf53e4b5 |
children | 0b7475ea38cf |
line wrap: on
line diff
--- a/mercurial/wireprotoserver.py Fri Apr 06 22:22:19 2018 +0200 +++ b/mercurial/wireprotoserver.py Tue Feb 27 02:37:31 2018 +0100 @@ -106,15 +106,14 @@ self._protocaps = set(value.split(' ')) return self._protocaps - def forwardpayload(self, fp): + def getpayload(self): # Existing clients *always* send Content-Length. length = int(self._req.headers[b'Content-Length']) # If httppostargs is used, we need to read Content-Length # minus the amount that was consumed by args. length -= int(self._req.headers.get(b'X-HgArgs-Post', 0)) - for s in util.filechunkiter(self._req.bodyfh, limit=length): - fp.write(s) + return util.filechunkiter(self._req.bodyfh, limit=length) @contextlib.contextmanager def mayberedirectstdio(self): @@ -610,7 +609,7 @@ # Protocol capabilities are currently not implemented for HTTP V2. return set() - def forwardpayload(self, fp): + def getpayload(self): raise NotImplementedError @contextlib.contextmanager @@ -783,7 +782,7 @@ def getprotocaps(self): return self._protocaps - def forwardpayload(self, fpout): + def getpayload(self): # We initially send an empty response. This tells the client it is # OK to start sending data. If a client sees any other response, it # interprets it as an error. @@ -796,7 +795,7 @@ # 0\n count = int(self._fin.readline()) while count: - fpout.write(self._fin.read(count)) + yield self._fin.read(count) count = int(self._fin.readline()) @contextlib.contextmanager