Patchwork D11202: upgrade: avoid a traceback in case of unrecognized revlog

login
register
mail settings
Submitter phabricator
Date July 20, 2021, 6:40 a.m.
Message ID <differential-rev-PHID-DREV-w3tizna4tdkmvzjv3y2g-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/49515/
State Superseded
Headers show

Comments

phabricator - July 20, 2021, 6:40 a.m.
marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Without this, in case of revlog name not matching any know pattern we would get
  a traceback. Raising a clear error seems simpler.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D11202

AFFECTED FILES
  mercurial/upgrade_utils/engine.py

CHANGE DETAILS




To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel

Patch

diff --git a/mercurial/upgrade_utils/engine.py b/mercurial/upgrade_utils/engine.py
--- a/mercurial/upgrade_utils/engine.py
+++ b/mercurial/upgrade_utils/engine.py
@@ -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)