Details
Details
- Reviewers
- dlax - indygreg 
- Group Reviewers
- hg-reviewers 
- Commits
- rHG127d46468a45: state: add a pytype annotation
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
- Lint Skipped 
- Unit
- Unit Tests Skipped 
| dlax | |
| indygreg | 
| hg-reviewers | 
| Lint Skipped | 
| Unit Tests Skipped | 
| Path | Packages | |||
|---|---|---|---|---|
| M | mercurial/state.py (10 lines) | 
| Commit | Parents | Author | Summary | Date | 
|---|---|---|---|---|
| 507ca2f63e0f | 83ae76f889d5 | Augie Fackler | Nov 13 2019, 10:22 PM | 
| Status | Author | Revision | |
|---|---|---|---|
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Changes Planned | mharbison72 | ||
| Needs Revision | durin42 | ||
| Needs Revision | durin42 | ||
| Abandoned | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Abandoned | durin42 | ||
| Changes Planned | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | ||
| Closed | durin42 | 
| from .i18n import _ | from .i18n import _ | ||||
| from . import ( | from . import ( | ||||
| error, | error, | ||||
| util, | util, | ||||
| ) | ) | ||||
| from .utils import cborutil | from .utils import cborutil | ||||
| if not globals(): | |||||
| from typing import ( | |||||
| Any, | |||||
| Dict, | |||||
| ) | |||||
| for t in (Any, Dict): | |||||
| assert t | |||||
| class cmdstate(object): | class cmdstate(object): | ||||
| """a wrapper class to store the state of commands like `rebase`, `graft`, | """a wrapper class to store the state of commands like `rebase`, `graft`, | ||||
| `histedit`, `shelve` etc. Extensions can also use this to write state files. | `histedit`, `shelve` etc. Extensions can also use this to write state files. | ||||
| All the data for the state is stored in the form of key-value pairs in a | All the data for the state is stored in the form of key-value pairs in a | ||||
| dictionary. | dictionary. | ||||
| The class object can write all the data to a file in .hg/ directory and | The class object can write all the data to a file in .hg/ directory and | ||||
| can populate the object data reading that file. | can populate the object data reading that file. | ||||
| Uses cbor to serialize and deserialize data while writing and reading from | Uses cbor to serialize and deserialize data while writing and reading from | ||||
| disk. | disk. | ||||
| """ | """ | ||||
| def __init__(self, repo, fname): | def __init__(self, repo, fname): | ||||
| """ repo is the repo object | """ repo is the repo object | ||||
| fname is the file name in which data should be stored in .hg directory | fname is the file name in which data should be stored in .hg directory | ||||
| """ | """ | ||||
| self._repo = repo | self._repo = repo | ||||
| self.fname = fname | self.fname = fname | ||||
| def read(self): | def read(self): | ||||
| # type: () -> Dict[bytes, Any] | |||||
| """read the existing state file and return a dict of data stored""" | """read the existing state file and return a dict of data stored""" | ||||
| return self._read() | return self._read() | ||||
| def save(self, version, data): | def save(self, version, data): | ||||
| """write all the state data stored to .hg/<filename> file | """write all the state data stored to .hg/<filename> file | ||||
| we use third-party library cbor to serialize data to write in the file. | we use third-party library cbor to serialize data to write in the file. | ||||
| """ | """ | ||||