D3579: state: write the version number in plain text on top of state files
yuya at tcha.org
Tue May 22 07:12:50 EDT 2018
> - def save(self, data):
> + def save(self, version, data):
> """write all the state data stored to .hg/<filename> file
> we use third-party library cbor to serialize data to write in the file.
> + if not isinstance(version, int):
> + raise error.ProgrammingError("version of state file should be"
> + " an integer")
> with self._repo.vfs(self.fname, 'wb', atomictemp=True) as fp:
> + fp.write('%d\n' % iv)
> cbor.dump(self.opts, fp, canonical=True)
> 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:
> + try:
> + version = int(fp.readline())
mercurial/state.py:65: undefined name 'iv'
mercurial/state.py:73: local variable 'version' is assigned to but never used
> + except ValueError:
> + raise error.ProgrammingError("unknown version of state file"
> + " found")
Perhaps this should be a CorruptedState error. We don't know whether the
state file is good until reading it.
More information about the Mercurial-devel