# HG changeset patch # User Pierre-Yves David # Date 2023-05-15 06:59:56 # Node ID 17a822d7943ed273c0556da1b64f7e064a85f03e # Parent 60e613f6a2299b44eecf38cd983bed414cd7d079 store: use StoreEntry API instead of parsing filename in narrow This is more explicit and more robust. diff --git a/hgext/narrow/narrowcommands.py b/hgext/narrow/narrowcommands.py --- a/hgext/narrow/narrowcommands.py +++ b/hgext/narrow/narrowcommands.py @@ -31,6 +31,7 @@ from mercurial import ( repoview, requirements, sparse, + store, util, wireprototypes, ) @@ -289,14 +290,14 @@ def _narrow( todelete = [] for entry in repo.store.datafiles(): - f = entry.unencoded_path - if f.startswith(b'data/'): - file = f[5:-2] - if not newmatch(file): + if not entry.is_revlog: + continue + if entry.revlog_type == store.FILEFLAGS_FILELOG: + if not newmatch(entry.target_id): for file_ in entry.files(): todelete.append(file_.unencoded_path) - elif f.startswith(b'meta/'): - dir = f[5:-13] + elif entry.revlog_type == store.FILEFLAGS_MANIFESTLOG: + dir = entry.target_id dirs = sorted(pathutil.dirs({dir})) + [dir] include = True for d in dirs: