# HG changeset patch # User Martin von Zweigbergk # Date 1610176117 28800 # Node ID c062874a35dbc1a68e2f28f14857f509f8f7b197 # Parent 61f8fc12e16735d7a6d55ed0dcadabdc1dc073a1 shelve: don't crash on file with unexpected extension in .hg/shelved/ We assumed that the files in the `.hg/shelved/` directory have an extension. That's a valid assumption except that users may put garbage in the directory. This patch fixes the crash by simply not assuming that the result of splittin a string at '.' yields an extension. We don't use the extension since the previous patch anyway. Differential Revision: https://phab.mercurial-scm.org/D9720 diff -r 61f8fc12e167 -r c062874a35db mercurial/shelve.py --- a/mercurial/shelve.py Mon Jan 11 09:26:48 2021 -0800 +++ b/mercurial/shelve.py Fri Jan 08 23:08:37 2021 -0800 @@ -625,7 +625,7 @@ info = [] seen = set() for (filename, _type) in names: - name, ext = filename.rsplit(b'.', 1) + name = filename.rsplit(b'.', 1)[0] if name in seen: continue seen.add(name) diff -r 61f8fc12e167 -r c062874a35db tests/test-shelve2.t --- a/tests/test-shelve2.t Mon Jan 11 09:26:48 2021 -0800 +++ b/tests/test-shelve2.t Fri Jan 08 23:08:37 2021 -0800 @@ -779,10 +779,10 @@ # A file with an unexpected extension $ touch .hg/shelved/junk3 - $ hg shelve -l 2>&1 | grep ValueError - ValueError: * (glob) - $ hg unshelve 2>&1 | grep ValueError - ValueError: * (glob) + $ hg shelve -l + $ hg unshelve + abort: no shelved changes to apply! + [20] $ hg shelve -d junk3 abort: shelved change 'junk3' not found [10]