diff --git a/mercurial/store.py b/mercurial/store.py --- a/mercurial/store.py +++ b/mercurial/store.py @@ -8,6 +8,7 @@ from __future__ import absolute_import import errno +import functools import hashlib import os import stat @@ -463,7 +464,21 @@ # skip nonexistent file self.entries = set() return - self.entries = set(decodedir(fp.read()).splitlines()) + + self.entries = set() + chunksize = (10 ** 6) # 1 MB + chunk = b'' + for c in iter(functools.partial(fp.read, chunksize), b''): + chunk += c + try: + p = chunk.rindex(b'\n') + self.entries |= set(decodedir(chunk[:p + 1]).splitlines()) + chunk = chunk[p + 1:] + except ValueError: + # substring '\n' not found, maybe the entry is bigger than the + # chunksize, so let's keep iterating + pass + self._checkentries(fp) fp.close()