Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/state.py @ 38166:dce718404ce6
state: raise CorruptedState error isntead of ProgrammingError
There are old state files which don't have a version number in top of them and
hence we have to read them to check whether they are good or not.
ProgrammingError is not apt for this case. Thanks to Yuya for suggesting
CorruptedState error.
Differential Revision: https://phab.mercurial-scm.org/D3644
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Wed, 23 May 2018 03:13:04 +0530 |
parents | b7e5c53a779e |
children | 6f67bfe4b82f |
comparison
equal
deleted
inserted
replaced
38165:2b8cb0ab231c | 38166:dce718404ce6 |
---|---|
70 data in the same format as it was before storing""" | 70 data in the same format as it was before storing""" |
71 with self._repo.vfs(self.fname, 'rb') as fp: | 71 with self._repo.vfs(self.fname, 'rb') as fp: |
72 try: | 72 try: |
73 int(fp.readline()) | 73 int(fp.readline()) |
74 except ValueError: | 74 except ValueError: |
75 raise error.ProgrammingError("unknown version of state file" | 75 raise error.CorruptedState("unknown version of state file" |
76 " found") | 76 " found") |
77 return cbor.load(fp) | 77 return cbor.load(fp) |
78 | 78 |
79 def delete(self): | 79 def delete(self): |
80 """drop the state file if exists""" | 80 """drop the state file if exists""" |
81 util.unlinkpath(self._repo.vfs.join(self.fname), ignoremissing=True) | 81 util.unlinkpath(self._repo.vfs.join(self.fname), ignoremissing=True) |