upgrade: avoid a traceback in case of unrecognized revlog
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 19 Jul 2021 22:19:36 +0200
changeset 47660 aa2296893168
parent 47659 f030c7d22032
child 47661 b2082426f03a
upgrade: avoid a traceback in case of unrecognized revlog Without this, in case of revlog name not matching any know pattern we would get a traceback. Raising a clear error seems simpler. Differential Revision: https://phab.mercurial-scm.org/D11202
mercurial/upgrade_utils/engine.py
--- a/mercurial/upgrade_utils/engine.py	Mon Jul 19 22:39:08 2021 +0200
+++ b/mercurial/upgrade_utils/engine.py	Mon Jul 19 22:19:36 2021 +0200
@@ -64,7 +64,12 @@
         )
     else:
         # drop the extension and the `data/` prefix
-        path = path.rsplit(b'.', 1)[0].split(b'/', 1)[1]
+        path_part = path.rsplit(b'.', 1)[0].split(b'/', 1)
+        if len(path_part) < 2:
+            msg = _('cannot recognize revlog from filename: %s')
+            msg %= path
+            raise error.Abort(msg)
+        path = path_part[1]
         return filelog.filelog(repo.svfs, path)