Patchwork D9698: shelve: trust caller of shelvedfile.opener() to check that the file exists

login
register
mail settings
Submitter phabricator
Date Jan. 8, 2021, 8:37 p.m.
Message ID <differential-rev-PHID-DREV-uswl45rwxngon6ogfxgh-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/48009/
State Superseded
Headers show

Comments

phabricator - Jan. 8, 2021, 8:37 p.m.
martinvonz created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  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).

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/shelve.py

CHANGE DETAILS




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

Patch

diff --git a/mercurial/shelve.py b/mercurial/shelve.py
--- a/mercurial/shelve.py
+++ b/mercurial/shelve.py
@@ -117,12 +117,7 @@ 
         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()