mercurial/commands.py
changeset 1981 736b6c96bbbc
parent 1980 dfb796786337
child 1993 fb6ca9801d04
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: