state: add __setitem__() for cmdstate class
authorPulkit Goyal <7895pulkit@gmail.com>
Mon, 19 Mar 2018 13:11:55 +0530
changeset 3572 7934e9751d69
parent 3571 34330381b76b
child 3573 d53277cdc1e7
state: add __setitem__() for cmdstate class Adding __setitem__() will help us in setting the value of variables stored in state files using `state[key] = value` in our code which is very convenient.
hgext3rd/evolve/state.py
--- a/hgext3rd/evolve/state.py	Mon Mar 19 12:58:31 2018 +0530
+++ b/hgext3rd/evolve/state.py	Mon Mar 19 13:11:55 2018 +0530
@@ -48,6 +48,10 @@
     def __getitem__(self, key):
         return self.opts[key]
 
+    def __setitem__(self, key, value):
+        updates = {key: value}
+        self.opts.update(updates)
+
     def load(self):
         """load the existing evolvestate file into the class object"""
         op = self._read()