mercurial/streamclone.py
changeset 27896 1d29893240cc
parent 27882 319b0bf6ecc9
child 27897 2fdbf22a1b63
equal deleted inserted replaced
27895:2d6a89e79b48 27896:1d29893240cc
   296         handled_bytes = 0
   296         handled_bytes = 0
   297         repo.ui.progress(_('clone'), 0, total=bytecount)
   297         repo.ui.progress(_('clone'), 0, total=bytecount)
   298         start = time.time()
   298         start = time.time()
   299 
   299 
   300         with repo.transaction('clone'):
   300         with repo.transaction('clone'):
   301             for i in xrange(filecount):
   301             if True:
   302                 # XXX doesn't support '\n' or '\r' in filenames
   302                 for i in xrange(filecount):
   303                 l = fp.readline()
   303                     # XXX doesn't support '\n' or '\r' in filenames
   304                 try:
   304                     l = fp.readline()
   305                     name, size = l.split('\0', 1)
   305                     try:
   306                     size = int(size)
   306                         name, size = l.split('\0', 1)
   307                 except (ValueError, TypeError):
   307                         size = int(size)
   308                     raise error.ResponseError(
   308                     except (ValueError, TypeError):
   309                         _('unexpected response from remote server:'), l)
   309                         raise error.ResponseError(
   310                 if repo.ui.debugflag:
   310                             _('unexpected response from remote server:'), l)
   311                     repo.ui.debug('adding %s (%s)\n' %
   311                     if repo.ui.debugflag:
   312                                   (name, util.bytecount(size)))
   312                         repo.ui.debug('adding %s (%s)\n' %
   313                 # for backwards compat, name was partially encoded
   313                                       (name, util.bytecount(size)))
   314                 with repo.svfs(store.decodedir(name), 'w') as ofp:
   314                     # for backwards compat, name was partially encoded
   315                     for chunk in util.filechunkiter(fp, limit=size):
   315                     with repo.svfs(store.decodedir(name), 'w') as ofp:
   316                         handled_bytes += len(chunk)
   316                         for chunk in util.filechunkiter(fp, limit=size):
   317                         repo.ui.progress(_('clone'), handled_bytes,
   317                             handled_bytes += len(chunk)
   318                                          total=bytecount)
   318                             repo.ui.progress(_('clone'), handled_bytes,
   319                         ofp.write(chunk)
   319                                              total=bytecount)
       
   320                             ofp.write(chunk)
   320 
   321 
   321         # Writing straight to files circumvented the inmemory caches
   322         # Writing straight to files circumvented the inmemory caches
   322         repo.invalidate()
   323         repo.invalidate()
   323 
   324 
   324         elapsed = time.time() - start
   325         elapsed = time.time() - start