diff --git a/mercurial/state.py b/mercurial/state.py --- a/mercurial/state.py +++ b/mercurial/state.py @@ -87,3 +87,21 @@ def exists(self): """check whether the evolvestate file exists or not""" return self._repo.vfs.exists(self.fname) + +oldstatefilefns = {} + +def readoldstatefile(path): + """decorator for registering function which can read the old format of state + files. + + Using the state class defined above, all the state files will be using cbor + to serialize data to write to disk. But a user can update hg while in + conflict. This decorator registers function for reading old statefiles in + such cases.""" + def dec(func): + """func here should accept the file object of the state file and + should return a dict of data stored in state file.""" + assert path not in oldstatefilefns + oldstatefilefns[path] = func + return func + return dec