changeset 38137:36a5a1239a15

state: don't have a dict like interface for cmdstate class This patch changes the cmdstate class to stop having a dict like interface and delete the __nonzero__ function. After this patch, the save fuction takes a dict to store the data and read function returns a dict of the data stored. Differential Revision: https://phab.mercurial-scm.org/D3572
author Pulkit Goyal <7895pulkit@gmail.com>
date Wed, 28 Mar 2018 16:31:16 +0530
parents a2f83661f721
children 18c6d8b565bf
files mercurial/state.py
diffstat 1 files changed, 4 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/state.py	Wed Feb 21 17:20:22 2018 +0530
+++ b/mercurial/state.py	Wed Mar 28 16:31:16 2018 +0530
@@ -46,31 +46,12 @@
         """
         self._repo = repo
         self.fname = fname
-        if not opts:
-            self.opts = {}
-        else:
-            self.opts = opts
-
-    def __nonzero__(self):
-        return self.exists()
-
-    def __getitem__(self, key):
-        return self.opts[key]
 
-    def __setitem__(self, key, value):
-        updates = {key: value}
-        self.opts.update(updates)
+    def read(self):
+        """read the existing state file and return a dict of data stored"""
+        return self._read()
 
-    def load(self):
-        """load the existing state file into the class object"""
-        op = self._read()
-        self.opts.update(op)
-
-    def addopts(self, opts):
-        """add more key-value pairs to the data stored by the object"""
-        self.opts.update(opts)
-
-    def save(self):
+    def save(self, 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.