store: use StoreEntry API instead of parsing filename in narrow
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 15 May 2023 08:59:56 +0200
changeset 50484 17a822d7943e
parent 50483 60e613f6a229
child 50485 5805b8b25426
store: use StoreEntry API instead of parsing filename in narrow This is more explicit and more robust.
hgext/narrow/narrowcommands.py
--- a/hgext/narrow/narrowcommands.py	Mon May 15 08:59:38 2023 +0200
+++ b/hgext/narrow/narrowcommands.py	Mon May 15 08:59:56 2023 +0200
@@ -31,6 +31,7 @@
     repoview,
     requirements,
     sparse,
+    store,
     util,
     wireprototypes,
 )
@@ -289,14 +290,14 @@
 
         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: