Patchwork D3572: state: don't have a dict like interface for cmdstate class

login
register
mail settings
Submitter phabricator
Date May 21, 2018, 5:40 p.m.
Message ID <43dc8519df098ee5ce4a100ddf656e0d@localhost.localdomain>
Download mbox | patch
Permalink /patch/31779/
State Not Applicable
Headers show

Comments

phabricator - May 21, 2018, 5:40 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG36a5a1239a15: state: don&#039;t have a dict like interface for cmdstate class (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D3572?vs=8732&id=8851

REVISION DETAIL
  https://phab.mercurial-scm.org/D3572

AFFECTED FILES
  mercurial/state.py

CHANGE DETAILS




To: pulkit, #hg-reviewers, martinvonz
Cc: martinvonz, mercurial-devel

Patch

diff --git a/mercurial/state.py b/mercurial/state.py
--- a/mercurial/state.py
+++ b/mercurial/state.py
@@ -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.