Patchwork [01,of,10] largefiles: don't store whole file in memory for 'cat'

login
register
mail settings
Submitter Mads Kiilerich
Date April 15, 2013, 7:23 p.m.
Message ID <eac1beec2678ed2f4f9a.1366053834@mk-desktop>
Download mbox | patch
Permalink /patch/1318/
State Accepted
Commit 5f9019e6d451aed829bbae55f56ed317aa5c9e17
Headers show

Comments

Mads Kiilerich - April 15, 2013, 7:23 p.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1365982909 -7200
#      Mon Apr 15 01:41:49 2013 +0200
# Node ID eac1beec2678ed2f4f9a4c4c5890353a1522f48d
# Parent  27e8dfc2c33868b49c9e6b2c2d8279ce92558592
largefiles: don't store whole file in memory for 'cat'

Patch

diff --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py
+++ b/hgext/largefiles/lfcommands.py
@@ -542,7 +542,8 @@ 
     path = lfutil.usercachepath(repo.ui, hash)
     fpout = cmdutil.makefileobj(repo, filename)
     fpin = open(path, "rb")
-    fpout.write(fpin.read())
+    for chunk in lfutil.blockstream(fpin):
+        fpout.write(chunk)
     fpout.close()
     fpin.close()
     return 0