Mercurial > public > mercurial-scm > hg
comparison mercurial/shelve.py @ 46271:b2a8ff736ecf
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
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Thu, 07 Jan 2021 12:58:43 -0800 |
parents | 161313f9c467 |
children | a68d3386138c |
comparison
equal
deleted
inserted
replaced
46270:161313f9c467 | 46271:b2a8ff736ecf |
---|---|
115 | 115 |
116 def stat(self): | 116 def stat(self): |
117 return self.vfs.stat(self.fname) | 117 return self.vfs.stat(self.fname) |
118 | 118 |
119 def opener(self, mode=b'rb'): | 119 def opener(self, mode=b'rb'): |
120 try: | 120 return self.vfs(self.fname, mode) |
121 return self.vfs(self.fname, mode) | |
122 except IOError as err: | |
123 if err.errno != errno.ENOENT: | |
124 raise | |
125 raise error.Abort(_(b"shelved change '%s' not found") % self.name) | |
126 | 121 |
127 def applybundle(self, tr): | 122 def applybundle(self, tr): |
128 fp = self.opener() | 123 fp = self.opener() |
129 try: | 124 try: |
130 targetphase = phases.internal | 125 targetphase = phases.internal |