changeset 50512:1c0244a8cdaf

store: change `_walk` return to `(filename, (type, size))` If we are to group file per revlog, having the filename as the "main key" will be useful. This change will make the following changes clearer.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 15 May 2023 08:58:16 +0200
parents 4cbdfab6f812
children 5217e36356bb
files mercurial/store.py
diffstat 1 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/store.py	Mon May 15 08:58:01 2023 +0200
+++ b/mercurial/store.py	Mon May 15 08:58:16 2023 +0200
@@ -564,9 +564,10 @@
                     rl_type = is_revlog(f, kind, st)
                     if rl_type is not None:
                         n = util.pconvert(fp[striplen:])
-                        l.append((rl_type, decodedir(n), st.st_size))
+                        l.append((decodedir(n), (rl_type, st.st_size)))
                     elif kind == stat.S_IFDIR and recurse:
                         visit.append(fp)
+
         l.sort()
         return l
 
@@ -591,7 +592,7 @@
         be a list and the filenames that can't be decoded are added
         to it instead. This is very rarely needed."""
         files = self._walk(b'data', True) + self._walk(b'meta', True)
-        for (t, u, s) in files:
+        for u, (t, s) in files:
             if t is not None:
                 yield RevlogStoreEntry(
                     unencoded_path=u,
@@ -603,8 +604,11 @@
 
     def topfiles(self) -> Generator[BaseStoreEntry, None, None]:
         # yield manifest before changelog
-        files = reversed(self._walk(b'', False))
-        for (t, u, s) in files:
+        files = self._walk(b'', False)
+        # key is (type, path) (keeping ordering so we get 00changelog.i last)
+        type_key = lambda x: (x[1][0], x[0])
+        files = sorted(files, reverse=True, key=type_key)
+        for u, (t, s) in files:
             if u.startswith(b'00changelog'):
                 yield RevlogStoreEntry(
                     unencoded_path=u,