diff hgext/largefiles/localstore.py @ 30180:736f92c44656

largefiles: always use filechunkiter when iterating files Before, we would sometimes use the default iterator over large files. That iterator is line based and would add extra buffering and use odd chunk sizes which could give some overhead. copyandhash can't just apply a filechunkiter as it sometimes is passed a genuine generator when downloading remotely.
author Mads Kiilerich <madski@unity3d.com>
date Wed, 12 Oct 2016 12:22:18 +0200
parents ecbbf4d56ee8
children 2372284d9457
line wrap: on
line diff
--- a/hgext/largefiles/localstore.py	Fri Oct 14 23:33:00 2016 +0900
+++ b/hgext/largefiles/localstore.py	Wed Oct 12 12:22:18 2016 +0200
@@ -10,6 +10,7 @@
 from __future__ import absolute_import
 
 from mercurial.i18n import _
+from mercurial import util
 
 from . import (
     basestore,
@@ -42,7 +43,8 @@
             raise basestore.StoreError(filename, hash, self.url,
                 _("can't get file locally"))
         with open(path, 'rb') as fd:
-            return lfutil.copyandhash(fd, tmpfile)
+            return lfutil.copyandhash(
+                util.filechunkiter(fd), tmpfile)
 
     def _verifyfiles(self, contents, filestocheck):
         failed = False