comparison 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
comparison
equal deleted inserted replaced
1980:dfb796786337 1981:736b6c96bbbc
10 from i18n import gettext as _ 10 from i18n import gettext as _
11 demandload(globals(), "os re sys signal shutil imp urllib pdb") 11 demandload(globals(), "os re sys signal shutil imp urllib pdb")
12 demandload(globals(), "fancyopts ui hg util lock revlog templater bundlerepo") 12 demandload(globals(), "fancyopts ui hg util lock revlog templater bundlerepo")
13 demandload(globals(), "fnmatch hgweb mdiff random signal tempfile time") 13 demandload(globals(), "fnmatch hgweb mdiff random signal tempfile time")
14 demandload(globals(), "traceback errno socket version struct atexit sets bz2") 14 demandload(globals(), "traceback errno socket version struct atexit sets bz2")
15 demandload(globals(), "changegroup")
15 16
16 class UnknownCommand(Exception): 17 class UnknownCommand(Exception):
17 """Exception raised if command is not in the command table.""" 18 """Exception raised if command is not in the command table."""
18 class AmbiguousCommand(Exception): 19 class AmbiguousCommand(Exception):
19 """Exception raised if command shortcut matches more than one command.""" 20 """Exception raised if command shortcut matches more than one command."""
304 fh.write("HG10") 305 fh.write("HG10")
305 z = bz2.BZ2Compressor(9) 306 z = bz2.BZ2Compressor(9)
306 else: 307 else:
307 fh.write("HG10UN") 308 fh.write("HG10UN")
308 z = nocompress() 309 z = nocompress()
309 while 1: 310 # parse the changegroup data, otherwise we will block
310 chunk = cg.read(4096) 311 # in case of sshrepo because we don't know the end of the stream
311 if not chunk: 312
312 break 313 # an empty chunkiter is the end of the changegroup
313 fh.write(z.compress(chunk)) 314 empty = False
315 while not empty:
316 empty = True
317 for chunk in changegroup.chunkiter(cg):
318 empty = False
319 fh.write(z.compress(changegroup.genchunk(chunk)))
320 fh.write(z.compress(changegroup.closechunk()))
314 fh.write(z.flush()) 321 fh.write(z.flush())
315 cleanup = None 322 cleanup = None
316 return filename 323 return filename
317 finally: 324 finally:
318 if fh is not None: 325 if fh is not None: