31 # how much bytes should be read from fncache in one read |
31 # how much bytes should be read from fncache in one read |
32 # It is done to prevent loading large fncache files into memory |
32 # It is done to prevent loading large fncache files into memory |
33 fncache_chunksize = 10 ** 6 |
33 fncache_chunksize = 10 ** 6 |
34 |
34 |
35 |
35 |
36 def _matchtrackedpath(path, matcher): |
36 def _match_tracked_entry(entry, matcher): |
37 """parses a fncache entry and returns whether the entry is tracking a path |
37 """parses a fncache entry and returns whether the entry is tracking a path |
38 matched by matcher or not. |
38 matched by matcher or not. |
39 |
39 |
40 If matcher is None, returns True""" |
40 If matcher is None, returns True""" |
41 |
41 |
42 if matcher is None: |
42 if matcher is None: |
43 return True |
43 return True |
44 path = decodedir(path) |
44 if entry.revlog_type == FILEFLAGS_FILELOG: |
45 if path.startswith(b'data/'): |
45 return matcher(entry.target_id) |
46 return matcher(path[len(b'data/') : -len(b'.i')]) |
46 elif entry.revlog_type == FILEFLAGS_MANIFESTLOG: |
47 elif path.startswith(b'meta/'): |
47 return matcher.visitdir(entry.target_id.rstrip(b'/')) |
48 return matcher.visitdir(path[len(b'meta/') : -len(b'/00manifest.i')]) |
48 raise error.ProgrammingError(b"cannot process entry %r" % entry) |
49 |
|
50 raise error.ProgrammingError(b"cannot decode path %s" % path) |
|
51 |
49 |
52 |
50 |
53 # This avoids a collision between a file named foo and a dir named |
51 # This avoids a collision between a file named foo and a dir named |
54 # foo.i or foo.d |
52 # foo.i or foo.d |
55 def _encodedir(path): |
53 def _encodedir(path): |
774 def datafiles( |
772 def datafiles( |
775 self, matcher=None, undecodable=None |
773 self, matcher=None, undecodable=None |
776 ) -> Generator[BaseStoreEntry, None, None]: |
774 ) -> Generator[BaseStoreEntry, None, None]: |
777 entries = super(encodedstore, self).datafiles(undecodable=undecodable) |
775 entries = super(encodedstore, self).datafiles(undecodable=undecodable) |
778 for entry in entries: |
776 for entry in entries: |
779 if _matchtrackedpath(entry.unencoded_path, matcher): |
777 if _match_tracked_entry(entry, matcher): |
780 yield entry |
778 yield entry |
781 |
779 |
782 def join(self, f): |
780 def join(self, f): |
783 return self.path + b'/' + encodefilename(f) |
781 return self.path + b'/' + encodefilename(f) |
784 |
782 |
994 else: |
992 else: |
995 # unreachable |
993 # unreachable |
996 assert False, revlog |
994 assert False, revlog |
997 for ext, t in sorted(details.items()): |
995 for ext, t in sorted(details.items()): |
998 f = revlog + ext |
996 f = revlog + ext |
999 if not _matchtrackedpath(f, matcher): |
997 entry = RevlogStoreEntry( |
1000 continue |
|
1001 yield RevlogStoreEntry( |
|
1002 unencoded_path=f, |
998 unencoded_path=f, |
1003 revlog_type=rl_type, |
999 revlog_type=rl_type, |
1004 target_id=revlog_target_id, |
1000 target_id=revlog_target_id, |
1005 is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN), |
1001 is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN), |
1006 is_volatile=bool(t & FILEFLAGS_VOLATILE), |
1002 is_volatile=bool(t & FILEFLAGS_VOLATILE), |
1007 ) |
1003 ) |
|
1004 if _match_tracked_entry(entry, matcher): |
|
1005 yield entry |
1008 |
1006 |
1009 def copylist(self): |
1007 def copylist(self): |
1010 d = ( |
1008 d = ( |
1011 b'bookmarks', |
1009 b'bookmarks', |
1012 b'narrowspec', |
1010 b'narrowspec', |