# HG changeset patch # User Pierre-Yves David # Date 1684133896 -7200 # Node ID 1c0244a8cdaf82aa4693e092675fddaec630f559 # Parent 4cbdfab6f81240647a2708f3bd91f354d33c351e 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. diff -r 4cbdfab6f812 -r 1c0244a8cdaf mercurial/store.py --- 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,