store: also group files by revlog in fncache version of datafiles
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 15 May 2023 08:58:49 +0200
changeset 50480 d4f54aded22e
parent 50479 5217e36356bb
child 50481 b08243dbc2e3
store: also group files by revlog in fncache version of datafiles One more step.
mercurial/store.py
--- a/mercurial/store.py	Mon May 15 08:58:33 2023 +0200
+++ b/mercurial/store.py	Mon May 15 08:58:49 2023 +0200
@@ -934,23 +934,23 @@
     def datafiles(
         self, matcher=None, undecodable=None
     ) -> Generator[BaseStoreEntry, None, None]:
-        for f in sorted(self.fncache):
-            if not _matchtrackedpath(f, matcher):
-                continue
-            ef = self.encode(f)
-            t = revlog_type(f)
-            if t is None:
-                # Note: this should not be in the fncache then…
-                #
-                # However the fncache might contains such file added by
-                # previous version of Mercurial.
-                continue
-            yield RevlogStoreEntry(
-                unencoded_path=f,
-                revlog_type=FILEFLAGS_FILELOG,
-                is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN),
-                is_volatile=bool(t & FILEFLAGS_VOLATILE),
-            )
+        files = ((f, revlog_type(f)) for f in self.fncache)
+        # Note: all files in fncache should be revlog related, However the
+        # fncache might contains such file added by previous version of
+        # Mercurial.
+        files = (f for f in files if f[1] is not None)
+        by_revlog = _gather_revlog(files)
+        for revlog, details in by_revlog:
+            for ext, t in sorted(details.items()):
+                f = revlog + ext
+                if not _matchtrackedpath(f, matcher):
+                    continue
+                yield RevlogStoreEntry(
+                    unencoded_path=f,
+                    revlog_type=FILEFLAGS_FILELOG,
+                    is_revlog_main=bool(t & FILEFLAGS_REVLOG_MAIN),
+                    is_volatile=bool(t & FILEFLAGS_VOLATILE),
+                )
 
     def copylist(self):
         d = (