##// END OF EJS Templates
typing: lock in new pytype gains from making revlog related classes typeable...
Matt Harbison -
r52719:0338fb20 default
parent child Browse files
Show More
@@ -62,7 +62,7 b' def debugremotefilelog(ui, path, **opts)'
62 62 queue.append(p2)
63 63
64 64
65 def buildtemprevlog(repo, file):
65 def buildtemprevlog(repo, file) -> filelog.FileLog:
66 66 # get filename key
67 67 filekey = hex(hashutil.sha1(file).digest())
68 68 filedir = os.path.join(repo.path, b'store/data', filekey)
@@ -8,6 +8,10 b''
8 8
9 9 import collections
10 10
11 from typing import (
12 Iterator,
13 )
14
11 15 from mercurial.node import bin
12 16 from mercurial.i18n import _
13 17 from mercurial import (
@@ -296,7 +300,7 b' class remotefilelog:'
296 300 deltamode=None,
297 301 sidedata_helpers=None,
298 302 debug_info=None,
299 ):
303 ) -> Iterator[revlog.RevLogRevisionDelta]:
300 304 # we don't use any of these parameters here
301 305 del nodesorder, revisiondata, assumehaveparentrevisions, deltaprevious
302 306 del deltamode
@@ -8,6 +8,11 b''
8 8
9 9 import typing
10 10
11 from typing import (
12 Iterable,
13 Iterator,
14 )
15
11 16 from .i18n import _
12 17 from .node import nullrev
13 18 from . import (
@@ -26,6 +31,10 b' from .revlogutils import ('
26 31
27 32
28 33 class FileLog:
34 _revlog: revlog.revlog
35 nullid: bytes
36 _fix_issue6528: bool
37
29 38 def __init__(self, opener, path, try_split=False):
30 39 self._revlog = revlog.revlog(
31 40 opener,
@@ -43,7 +52,7 b' class FileLog:'
43 52 opts = opener.options
44 53 self._fix_issue6528 = opts.get(b'issue6528.fix-incoming', True)
45 54
46 def get_revlog(self):
55 def get_revlog(self) -> revlog.revlog:
47 56 """return an actual revlog instance if any
48 57
49 58 This exist because a lot of code leverage the fact the underlying
@@ -52,10 +61,10 b' class FileLog:'
52 61 """
53 62 return self._revlog
54 63
55 def __len__(self):
64 def __len__(self) -> int:
56 65 return len(self._revlog)
57 66
58 def __iter__(self):
67 def __iter__(self) -> Iterator[int]:
59 68 return self._revlog.__iter__()
60 69
61 70 def hasnode(self, node):
@@ -234,7 +243,7 b' class FileLog:'
234 243 """
235 244 return not storageutil.filedataequivalent(self, node, text)
236 245
237 def verifyintegrity(self, state):
246 def verifyintegrity(self, state) -> Iterable[revlog.RevLogProblem]:
238 247 return self._revlog.verifyintegrity(state)
239 248
240 249 def storageinfo(
@@ -850,6 +850,12 b' def _splittopdir(f: bytes) -> Tuple[byte'
850 850
851 851
852 852 class TreeManifest:
853 _dir: bytes
854 _dirs: Dict[bytes, 'TreeManifest']
855 _dirty: bool
856 _files: Dict[bytes, bytes]
857 _flags: Dict[bytes, bytes]
858
853 859 def __init__(self, nodeconstants, dir: bytes = b'', text: bytes = b''):
854 860 self._dir = dir
855 861 self.nodeconstants = nodeconstants
@@ -858,13 +864,13 b' class TreeManifest:'
858 864 self._loadfunc = _noop
859 865 self._copyfunc = _noop
860 866 self._dirty = False
861 self._dirs: Dict[bytes, 'TreeManifest'] = {}
867 self._dirs = {}
862 868 self._lazydirs: Dict[
863 869 bytes,
864 870 Tuple[bytes, Callable[[bytes, bytes], 'TreeManifest'], bool],
865 871 ] = {}
866 872 # Using _lazymanifest here is a little slower than plain old dicts
867 self._files: Dict[bytes, bytes] = {}
873 self._files = {}
868 874 self._flags = {}
869 875 if text:
870 876
@@ -2172,6 +2178,8 b' if typing.TYPE_CHECKING:'
2172 2178
2173 2179
2174 2180 class MemManifestCtx:
2181 _manifestdict: ManifestDict
2182
2175 2183 def __init__(self, manifestlog):
2176 2184 self._manifestlog = manifestlog
2177 2185 self._manifestdict = manifestdict(manifestlog.nodeconstants.nodelen)
@@ -2213,6 +2221,8 b' class ManifestCtx:'
2213 2221 contents, its parent revs, and its linkrev.
2214 2222 """
2215 2223
2224 _data: Optional[ManifestDict]
2225
2216 2226 def __init__(self, manifestlog, node):
2217 2227 self._manifestlog = manifestlog
2218 2228 self._data = None
@@ -2375,6 +2385,8 b' if typing.TYPE_CHECKING:'
2375 2385
2376 2386
2377 2387 class MemTreeManifestCtx:
2388 _treemanifest: TreeManifest
2389
2378 2390 def __init__(self, manifestlog, dir=b''):
2379 2391 self._manifestlog = manifestlog
2380 2392 self._dir = dir
@@ -2417,6 +2429,8 b' if typing.TYPE_CHECKING:'
2417 2429
2418 2430
2419 2431 class TreeManifestCtx:
2432 _data: Optional[TreeManifest]
2433
2420 2434 def __init__(self, manifestlog, dir, node):
2421 2435 self._manifestlog = manifestlog
2422 2436 self._dir = dir
@@ -2699,6 +2713,9 b' class excludeddir(treemanifest):'
2699 2713 whose contents are unknown.
2700 2714 """
2701 2715
2716 _files: Dict[bytes, bytes]
2717 _flags: Dict[bytes, bytes]
2718
2702 2719 def __init__(self, nodeconstants, dir, node):
2703 2720 super(excludeddir, self).__init__(nodeconstants, dir)
2704 2721 self._node = node
@@ -25,6 +25,8 b' import weakref'
25 25 import zlib
26 26
27 27 from typing import (
28 Iterable,
29 Iterator,
28 30 Optional,
29 31 Tuple,
30 32 )
@@ -1826,7 +1828,7 b' class revlog:'
1826 1828 def __len__(self):
1827 1829 return len(self.index)
1828 1830
1829 def __iter__(self):
1831 def __iter__(self) -> Iterator[int]:
1830 1832 return iter(range(len(self)))
1831 1833
1832 1834 def revs(self, start=0, stop=None):
@@ -3902,7 +3904,7 b' class revlog:'
3902 3904 else:
3903 3905 rewrite.v2_censor(self, tr, censor_nodes, tombstone)
3904 3906
3905 def verifyintegrity(self, state):
3907 def verifyintegrity(self, state) -> Iterable[RevLogProblem]:
3906 3908 """Verifies the integrity of the revlog.
3907 3909
3908 3910 Yields ``revlogproblem`` instances describing problems that are
@@ -160,6 +160,8 b' class statichttprepository('
160 160 ):
161 161 supported = localrepo.localrepository._basesupported
162 162
163 manifestlog: manifest.ManifestLog
164
163 165 def __init__(self, ui, path):
164 166 self._url = path
165 167 self.ui = ui
@@ -817,7 +817,7 b' class basicstore:'
817 817 concurrencychecker=concurrencychecker,
818 818 )
819 819
820 def manifestlog(self, repo, storenarrowmatch):
820 def manifestlog(self, repo, storenarrowmatch) -> manifest.ManifestLog:
821 821 rootstore = manifest.manifestrevlog(repo.nodeconstants, self.vfs)
822 822 return manifest.manifestlog(self.vfs, repo, rootstore, storenarrowmatch)
823 823
@@ -204,6 +204,9 b' class unionchangelog(unionrevlog, change'
204 204
205 205
206 206 class unionmanifest(unionrevlog, manifest.manifestrevlog):
207 repotiprev: int
208 revlog2: manifest.ManifestRevlog
209
207 210 def __init__(self, nodeconstants, opener, opener2, linkmapper):
208 211 # XXX manifestrevlog is not actually a revlog , so mixing it with
209 212 # bundlerevlog is not a good idea.
@@ -215,6 +218,10 b' class unionmanifest(unionrevlog, manifes'
215 218
216 219
217 220 class unionfilelog(filelog.filelog):
221 _revlog: unionrevlog
222 repotiprev: int
223 revlog2: revlog.revlog
224
218 225 def __init__(self, opener, path, opener2, linkmapper, repo):
219 226 filelog.filelog.__init__(self, opener, path)
220 227 filelog2 = filelog.filelog(opener2, path)
General Comments 0
You need to be logged in to leave comments. Login now