diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -77,8 +77,16 @@ def _read(self): """reads the evolvestate file and returns a dictionary which contain data in the same format as it was before storing""" - with self._repo.vfs(self.fname, 'rb') as fp: - return cbor.load(fp) + try: + with self._repo.vfs(self.fname, 'rb') as fp: + ret = cbor.load(fp) + if not isinstance(ret, dict): + raise cbor.CBORDecodeError + return ret + except cbor.CBORDecodeError: # cbor raises an Exception + with self._repo.vfs(self.fname, 'rb') as fp: + oldfn = oldstatefilefns[self.fname] + return oldfn(fp) def delete(self): """drop the evolvestate file if exists"""