Mercurial > public > mercurial-scm > hg
comparison mercurial/state.py @ 38145:6f67bfe4b82f
state: removing remaining instances of opts class variable
The cmdstate class used to have a class variable opts which used to be a dict
which stored all the data for the state. Recent cleanups removed the use of that
variable. There were couple of instances left which are removed by this patch.
Differential Revision: https://phab.mercurial-scm.org/D3653
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Fri, 25 May 2018 01:46:06 +0530 |
parents | dce718404ce6 |
children | 5bfab9400daf |
comparison
equal
deleted
inserted
replaced
38144:bd7a3fa71a72 | 38145:6f67bfe4b82f |
---|---|
38 | 38 |
39 Uses cbor to serialize and deserialize data while writing and reading from | 39 Uses cbor to serialize and deserialize data while writing and reading from |
40 disk. | 40 disk. |
41 """ | 41 """ |
42 | 42 |
43 def __init__(self, repo, fname, opts=None): | 43 def __init__(self, repo, fname): |
44 """ repo is the repo object | 44 """ repo is the repo object |
45 fname is the file name in which data should be stored in .hg directory | 45 fname is the file name in which data should be stored in .hg directory |
46 opts is a dictionary of data of the statefile | |
47 """ | 46 """ |
48 self._repo = repo | 47 self._repo = repo |
49 self.fname = fname | 48 self.fname = fname |
50 | 49 |
51 def read(self): | 50 def read(self): |
61 raise error.ProgrammingError("version of state file should be" | 60 raise error.ProgrammingError("version of state file should be" |
62 " an integer") | 61 " an integer") |
63 | 62 |
64 with self._repo.vfs(self.fname, 'wb', atomictemp=True) as fp: | 63 with self._repo.vfs(self.fname, 'wb', atomictemp=True) as fp: |
65 fp.write('%d\n' % version) | 64 fp.write('%d\n' % version) |
66 cbor.dump(self.opts, fp, canonical=True) | 65 cbor.dump(data, fp, canonical=True) |
67 | 66 |
68 def _read(self): | 67 def _read(self): |
69 """reads the state file and returns a dictionary which contain | 68 """reads the state file and returns a dictionary which contain |
70 data in the same format as it was before storing""" | 69 data in the same format as it was before storing""" |
71 with self._repo.vfs(self.fname, 'rb') as fp: | 70 with self._repo.vfs(self.fname, 'rb') as fp: |