changeset 50494:b4953fad744e

store: do the revlog matching on entry directly This is the last blocker to safely merge the revlog files in a single entry.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 15 May 2023 09:02:43 +0200
parents 816e8bc6e066
children ed8cda1c18e1
files mercurial/store.py
diffstat 1 files changed, 10 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/store.py	Mon May 15 09:02:26 2023 +0200
+++ b/mercurial/store.py	Mon May 15 09:02:43 2023 +0200
@@ -33,7 +33,7 @@
 fncache_chunksize = 10 ** 6
 
 
-def _matchtrackedpath(path, matcher):
+def _match_tracked_entry(entry, matcher):
     """parses a fncache entry and returns whether the entry is tracking a path
     matched by matcher or not.
 
@@ -41,13 +41,11 @@
 
     if matcher is None:
         return True
-    path = decodedir(path)
-    if path.startswith(b'data/'):
-        return matcher(path[len(b'data/') : -len(b'.i')])
-    elif path.startswith(b'meta/'):
-        return matcher.visitdir(path[len(b'meta/') : -len(b'/00manifest.i')])
-
-    raise error.ProgrammingError(b"cannot decode path %s" % path)
+    if entry.revlog_type == FILEFLAGS_FILELOG:
+        return matcher(entry.target_id)
+    elif entry.revlog_type == FILEFLAGS_MANIFESTLOG:
+        return matcher.visitdir(entry.target_id.rstrip(b'/'))
+    raise error.ProgrammingError(b"cannot process entry %r" % entry)
 
 
 # This avoids a collision between a file named foo and a dir named
@@ -776,7 +774,7 @@
     ) -> Generator[BaseStoreEntry, None, None]:
         entries = super(encodedstore, self).datafiles(undecodable=undecodable)
         for entry in entries:
-            if _matchtrackedpath(entry.unencoded_path, matcher):
+            if _match_tracked_entry(entry, matcher):
                 yield entry
 
     def join(self, f):
@@ -996,15 +994,15 @@
                 assert False, revlog
             for ext, t in sorted(details.items()):
                 f = revlog + ext
-                if not _matchtrackedpath(f, matcher):
-                    continue
-                yield RevlogStoreEntry(
+                entry = RevlogStoreEntry(
                     unencoded_path=f,
                     revlog_type=rl_type,
                     target_id=revlog_target_id,
                     is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN),
                     is_volatile=bool(t & FILEFLAGS_VOLATILE),
                 )
+                if _match_tracked_entry(entry, matcher):
+                    yield entry
 
     def copylist(self):
         d = (