pulkit updated this revision to Diff 7300. REPOSITORY rHG Mercurial
CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D2593?vs=6759&id=7300 REVISION DETAIL https://phab.mercurial-scm.org/D2593 AFFECTED FILES mercurial/state.py CHANGE DETAILS diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -83,8 +83,17 @@ def _read(self): """reads the state 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) or + ret.get('magicheader') != 'HGStateFile'): + 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 state file if exists""" To: pulkit, #hg-reviewers Cc: martinvonz, indygreg, durin42, mercurial-devel _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel