Mercurial > public > mercurial-scm > hg-stable
diff mercurial/commands.py @ 1981:736b6c96bbbc
make incoming work via ssh (issue139); move chunk code into separate module.
Incoming ssh needs to detect the end of the changegroup, otherwise it would
block trying to read from the ssh pipe. This is done by parsing the
changegroup chunks.
bundlerepo.getchunk() already is identical to
localrepo.addchangegroup.getchunk(), which is followed by getgroup which
looks much like what you can re-use in bundlerepository.__init__() and in
write_bundle(). bundlerevlog.__init__.genchunk() looks very similar, too,
as do some while loops in localrepo.py.
Applied patch from Benoit Boissinot to move duplicate/related code
to mercurial/changegroup.py and use this to fix incoming ssh.
author | Thomas Arendsen Hein <thomas@intevation.de> |
---|---|
date | Tue, 21 Mar 2006 11:47:21 +0100 |
parents | dfb796786337 |
children | fb6ca9801d04 |
line wrap: on
line diff
--- a/mercurial/commands.py Tue Mar 21 06:03:33 2006 +0100 +++ b/mercurial/commands.py Tue Mar 21 11:47:21 2006 +0100 @@ -12,6 +12,7 @@ demandload(globals(), "fancyopts ui hg util lock revlog templater bundlerepo") demandload(globals(), "fnmatch hgweb mdiff random signal tempfile time") demandload(globals(), "traceback errno socket version struct atexit sets bz2") +demandload(globals(), "changegroup") class UnknownCommand(Exception): """Exception raised if command is not in the command table.""" @@ -306,11 +307,17 @@ else: fh.write("HG10UN") z = nocompress() - while 1: - chunk = cg.read(4096) - if not chunk: - break - fh.write(z.compress(chunk)) + # parse the changegroup data, otherwise we will block + # in case of sshrepo because we don't know the end of the stream + + # an empty chunkiter is the end of the changegroup + empty = False + while not empty: + empty = True + for chunk in changegroup.chunkiter(cg): + empty = False + fh.write(z.compress(changegroup.genchunk(chunk))) + fh.write(z.compress(changegroup.closechunk())) fh.write(z.flush()) cleanup = None return filename