hgext/largefiles/proto.py
changeset 19004 6614e5e24e66
parent 18922 d2c4d37f7db5
child 19005 1b84047e7d16
--- a/hgext/largefiles/proto.py	Mon Apr 15 23:47:04 2013 +0200
+++ b/hgext/largefiles/proto.py	Tue Apr 16 01:46:39 2013 +0200
@@ -114,6 +114,7 @@
                         _('putlfile failed (unexpected response):'), ret)
 
         def getlfile(self, sha):
+            """returns an iterable with the chunks of the file with sha sha"""
             stream = self._callstream("getlfile", sha=sha)
             length = stream.readline()
             try:
@@ -121,7 +122,12 @@
             except ValueError:
                 self._abort(error.ResponseError(_("unexpected response:"),
                                                 length))
-            return (length, stream)
+
+            # Mercurial doesn't close SSH connections after writing a stream
+            infile = lfutil.limitreader(stream, length)
+            for chunk in util.filechunkiter(infile, 128 * 1024):
+                yield chunk
+            infile.close()
 
         @batchable
         def statlfile(self, sha):