upgrade: actually use StoreEntry API to create revlog
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 15 May 2023 09:01:53 +0200
changeset 50491 5f636e0fec4a
parent 50490 0935b9db21b6
child 50492 3473d18c029a
upgrade: actually use StoreEntry API to create revlog Lets make use of the semanctic of the object we are passed.
mercurial/upgrade_utils/engine.py
--- a/mercurial/upgrade_utils/engine.py	Mon May 15 09:01:36 2023 +0200
+++ b/mercurial/upgrade_utils/engine.py	Mon May 15 09:01:53 2023 +0200
@@ -52,26 +52,15 @@
 
     An instance of the appropriate class is returned.
     """
-    rl_type = entry.revlog_type
-    path = entry.unencoded_path
-    if rl_type & store.FILEFLAGS_CHANGELOG:
+    if entry.revlog_type == store.FILEFLAGS_CHANGELOG:
         return changelog.changelog(repo.svfs)
-    elif rl_type & store.FILEFLAGS_MANIFESTLOG:
-        mandir = b''
-        if b'/' in path:
-            mandir = path.rsplit(b'/', 1)[0]
+    elif entry.revlog_type == store.FILEFLAGS_MANIFESTLOG:
+        mandir = entry.target_id.rstrip(b'/')
         return manifest.manifestrevlog(
             repo.nodeconstants, repo.svfs, tree=mandir
         )
     else:
-        # drop the extension and the `data/` prefix
-        path_part = path.rsplit(b'.', 1)[0].split(b'/', 1)
-        if len(path_part) < 2:
-            msg = _(b'cannot recognize revlog from filename: %s')
-            msg %= path
-            raise error.Abort(msg)
-        path = path_part[1]
-        return filelog.filelog(repo.svfs, path)
+        return filelog.filelog(repo.svfs, entry.target_id)
 
 
 def _copyrevlog(tr, destrepo, oldrl, entry):