Mercurial > hg-stable
changeset 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 | cdef35b38026 |
children | 7356e6b1f5b8 |
files | hgext/largefiles/lfutil.py hgext/largefiles/localstore.py hgext/largefiles/remotestore.py |
diffstat | 3 files changed, 6 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/largefiles/lfutil.py Fri Oct 14 23:33:00 2016 +0900 +++ b/hgext/largefiles/lfutil.py Wed Oct 12 12:22:18 2016 +0200 @@ -231,7 +231,8 @@ # don't use atomic writes in the working copy. with open(path, 'rb') as srcfd: with wvfs(filename, 'wb') as destfd: - gothash = copyandhash(srcfd, destfd) + gothash = copyandhash( + util.filechunkiter(srcfd), destfd) if gothash != hash: repo.ui.warn(_('%s: data corruption in %s with hash %s\n') % (filename, path, gothash))
--- 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
--- a/hgext/largefiles/remotestore.py Fri Oct 14 23:33:00 2016 +0900 +++ b/hgext/largefiles/remotestore.py Wed Oct 12 12:22:18 2016 +0200 @@ -118,7 +118,7 @@ raise NotImplementedError('abstract method') def _get(self, hash): - '''Get file with the given hash from the remote store.''' + '''Get a iterator for content with the given hash.''' raise NotImplementedError('abstract method') def _stat(self, hashes):