Show More
@@ -19,12 +19,13 b' to serialize and deserialize data.' | |||||
19 |
|
19 | |||
20 | from __future__ import absolute_import |
|
20 | from __future__ import absolute_import | |
21 |
|
21 | |||
22 | from .thirdparty import cbor |
|
|||
23 |
|
||||
24 | from . import ( |
|
22 | from . import ( | |
25 | error, |
|
23 | error, | |
26 | util, |
|
24 | util, | |
27 | ) |
|
25 | ) | |
|
26 | from .utils import ( | |||
|
27 | cborutil, | |||
|
28 | ) | |||
28 |
|
29 | |||
29 | class cmdstate(object): |
|
30 | class cmdstate(object): | |
30 | """a wrapper class to store the state of commands like `rebase`, `graft`, |
|
31 | """a wrapper class to store the state of commands like `rebase`, `graft`, | |
@@ -62,7 +63,8 b' class cmdstate(object):' | |||||
62 |
|
63 | |||
63 | with self._repo.vfs(self.fname, 'wb', atomictemp=True) as fp: |
|
64 | with self._repo.vfs(self.fname, 'wb', atomictemp=True) as fp: | |
64 | fp.write('%d\n' % version) |
|
65 | fp.write('%d\n' % version) | |
65 | cbor.dump(data, fp, canonical=True) |
|
66 | for chunk in cborutil.streamencode(data): | |
|
67 | fp.write(chunk) | |||
66 |
|
68 | |||
67 | def _read(self): |
|
69 | def _read(self): | |
68 | """reads the state file and returns a dictionary which contain |
|
70 | """reads the state file and returns a dictionary which contain | |
@@ -73,7 +75,8 b' class cmdstate(object):' | |||||
73 | except ValueError: |
|
75 | except ValueError: | |
74 | raise error.CorruptedState("unknown version of state file" |
|
76 | raise error.CorruptedState("unknown version of state file" | |
75 | " found") |
|
77 | " found") | |
76 | return cbor.load(fp) |
|
78 | ||
|
79 | return cborutil.decodeall(fp.read())[0] | |||
77 |
|
80 | |||
78 | def delete(self): |
|
81 | def delete(self): | |
79 | """drop the state file if exists""" |
|
82 | """drop the state file if exists""" |
General Comments 0
You need to be logged in to leave comments.
Login now