streamclone: fix error when store files grow while stream cloning stable
authorMads Kiilerich <madski@unity3d.com>
Sun, 13 Mar 2016 02:29:11 +0100
branchstable
changeset 30820 aa440c3d7c5d2baafeb632ee35db4d917ed9cf83
parent 30819 95163ababeb86d6ca889e5e57a0c4eadb77b53d8
child 30834 ed75909c4c670a7d9db4a2bef9817a0d5f0b4d9c
child 30928 7dab4caf11bc717b1319ff10475b078e53f4df6c
push id208
push usergszorc@mozilla.com
push dateSat, 19 Mar 2016 01:42:47 +0000
streamclone: fix error when store files grow while stream cloning Effectively a backout of 9fea6b38a8da, but updated to using 'with'.
mercurial/streamclone.py
tests/test-clone-uncompressed.t
--- a/mercurial/streamclone.py
+++ b/mercurial/streamclone.py
@@ -201,17 +201,18 @@ def generatev1(repo):
     def emitrevlogdata():
         try:
             for name, size in entries:
                 if debugflag:
                     repo.ui.debug('sending %s (%d bytes)\n' % (name, size))
                 # partially encode name over the wire for backwards compat
                 yield '%s\0%d\n' % (store.encodedir(name), size)
                 if size <= 65536:
-                    yield svfs.read(name)
+                    with svfs(name, 'rb') as fp:
+                        yield fp.read(size)
                 else:
                     for chunk in util.filechunkiter(svfs(name), limit=size):
                         yield chunk
         finally:
             svfs.mustaudit = oldaudit
 
     return len(entries), total_bytes, emitrevlogdata()
 
--- a/tests/test-clone-uncompressed.t
+++ b/tests/test-clone-uncompressed.t
@@ -83,15 +83,10 @@ clone while modifying the repo between s
 actually serving file content
 
   $ hg clone -q --uncompressed -U http://localhost:$HGPORT1 clone &
   $ sleep 1
   $ echo >> repo/f1
   $ echo >> repo/f2
   $ hg -R repo ci -m "1"
   $ wait
-  abort: unexpected response from remote server:
-  '*\n' (glob)
   $ hg -R clone id
-  abort: repository clone not found!
-  [255]
-
-the current clone error is a regression from 9fea6b38a8da.
+  000000000000