Show More
@@ -8,6 +8,7 b'' | |||
|
8 | 8 | from __future__ import absolute_import |
|
9 | 9 | |
|
10 | 10 | import errno |
|
11 | import functools | |
|
11 | 12 | import hashlib |
|
12 | 13 | import os |
|
13 | 14 | import stat |
@@ -23,6 +24,9 b' from . import (' | |||
|
23 | 24 | ) |
|
24 | 25 | |
|
25 | 26 | parsers = policy.importmod(r'parsers') |
|
27 | # how much bytes should be read from fncache in one read | |
|
28 | # It is done to prevent loading large fncache files into memory | |
|
29 | fncache_chunksize = 10 ** 6 | |
|
26 | 30 | |
|
27 | 31 | def _matchtrackedpath(path, matcher): |
|
28 | 32 | """parses a fncache entry and returns whether the entry is tracking a path |
@@ -463,7 +467,20 b' class fncache(object):' | |||
|
463 | 467 | # skip nonexistent file |
|
464 | 468 | self.entries = set() |
|
465 | 469 | return |
|
466 | self.entries = set(decodedir(fp.read()).splitlines()) | |
|
470 | ||
|
471 | self.entries = set() | |
|
472 | chunk = b'' | |
|
473 | for c in iter(functools.partial(fp.read, fncache_chunksize), b''): | |
|
474 | chunk += c | |
|
475 | try: | |
|
476 | p = chunk.rindex(b'\n') | |
|
477 | self.entries.update(decodedir(chunk[:p + 1]).splitlines()) | |
|
478 | chunk = chunk[p + 1:] | |
|
479 | except ValueError: | |
|
480 | # substring '\n' not found, maybe the entry is bigger than the | |
|
481 | # chunksize, so let's keep iterating | |
|
482 | pass | |
|
483 | ||
|
467 | 484 | self._checkentries(fp) |
|
468 | 485 | fp.close() |
|
469 | 486 |
@@ -1,5 +1,19 b'' | |||
|
1 | 1 | #require repofncache |
|
2 | 2 | |
|
3 | An extension which will set fncache chunksize to 1 byte to make sure that logic | |
|
4 | does not break | |
|
5 | ||
|
6 | $ cat > chunksize.py <<EOF | |
|
7 | > from __future__ import absolute_import | |
|
8 | > from mercurial import store | |
|
9 | > store.fncache_chunksize = 1 | |
|
10 | > EOF | |
|
11 | ||
|
12 | $ cat >> $HGRCPATH <<EOF | |
|
13 | > [extensions] | |
|
14 | > chunksize = $TESTTMP/chunksize.py | |
|
15 | > EOF | |
|
16 | ||
|
3 | 17 |
|
|
4 | 18 | |
|
5 | 19 | $ hg init repo1 |
General Comments 0
You need to be logged in to leave comments.
Login now