# HG changeset patch # User Martin von Zweigbergk # Date 2021-01-07 20:58:43 # Node ID b2a8ff736ecf35314e731873bb4e430fdf7704cc # Parent 161313f9c4675bdb4d7073da532db46fd595ddb1 shelve: trust caller of shelvedfile.opener() to check that the file exists The only place we call `shelvedfile.opener()` is when we're about to apply a bundle. The file should always exist. If it doesn't, the `.hg/` directory is corrupt and we don't provide any guarantees about supporting corrupt repos (besides, telling the user that the shelve doesn't exist when `hg shelve --list` lists it is not very helpful). Differential Revision: https://phab.mercurial-scm.org/D9698 diff --git a/mercurial/shelve.py b/mercurial/shelve.py --- a/mercurial/shelve.py +++ b/mercurial/shelve.py @@ -117,12 +117,7 @@ class shelvedfile(object): return self.vfs.stat(self.fname) def opener(self, mode=b'rb'): - try: - return self.vfs(self.fname, mode) - except IOError as err: - if err.errno != errno.ENOENT: - raise - raise error.Abort(_(b"shelved change '%s' not found") % self.name) + return self.vfs(self.fname, mode) def applybundle(self, tr): fp = self.opener() diff --git a/tests/test-shelve2.t b/tests/test-shelve2.t --- a/tests/test-shelve2.t +++ b/tests/test-shelve2.t @@ -756,7 +756,7 @@ Test corrupt shelves (in .hg/shelved/, n junk1 (* ago) (glob) $ hg unshelve unshelving change 'junk1' - abort: shelved change 'junk1' not found + abort: $ENOENT$: '$TESTTMP/corrupt-shelves/.hg/shelved/junk1.hg' [255] $ hg shelve -d junk1 $ find .hg/shelve* | sort