evolve: add comptability to read old evolvestate files
authorPulkit Goyal <7895pulkit@gmail.com>
Tue, 30 Jan 2018 15:11:35 +0530
changeset 3498 152daa6967af
parent 3497 dae819761c0e
child 3499 512706514555
evolve: add comptability to read old evolvestate files When a user runs `hg evolve` with old evolve where we used to write evolvestate the old ways i.e. without using cbor, and faces conflicts, the evolve is interrupted. If the user updates evolve before completing the evolve, that can result in traceback as the new evolve cannot read the old evolvestate file. The previous patch added function to read old evolvestate file and this patch uses that when we encounter the above mentioned case.
hgext3rd/evolve/state.py
--- a/hgext3rd/evolve/state.py	Tue Jan 30 15:02:40 2018 +0530
+++ b/hgext3rd/evolve/state.py	Tue Jan 30 15:11:35 2018 +0530
@@ -51,7 +51,12 @@
     def load(self):
         """load the existing evolvestate file into the class object"""
         op = self._read()
-        self.opts.update(op)
+        if isinstance(op, dict):
+            self.opts.update(op)
+        elif self.path == 'evolvestate':
+            # it is the old evolvestate file
+            oldop = _oldevolvestateread(self._repo)
+            self.opts.update(oldop)
 
     def addopts(self, opts):
         """add more key-value pairs to the data stored by the object"""