##// END OF EJS Templates
typing: make the localrepo classes known to pytype...
Matt Harbison -
r52788:ee7e106b default
parent child Browse files
Show More
@@ -14,6 +14,7 import random
14 14 import re
15 15 import sys
16 16 import time
17 import typing
17 18 import weakref
18 19
19 20 from concurrent import futures
@@ -255,8 +256,7 moderncaps = {
255 256 legacycaps = moderncaps.union({b'changegroupsubset'})
256 257
257 258
258 @interfaceutil.implementer(repository.ipeercommandexecutor)
259 class localcommandexecutor:
259 class LocalCommandExecutor:
260 260 def __init__(self, peer):
261 261 self._peer = peer
262 262 self._sent = False
@@ -301,12 +301,20 class localcommandexecutor:
301 301 self._closed = True
302 302
303 303
304 @interfaceutil.implementer(repository.ipeercommands)
305 class localpeer(repository.peer):
304 localcommandexecutor = interfaceutil.implementer(
305 repository.ipeercommandexecutor
306 )(LocalCommandExecutor)
307
308 if typing.TYPE_CHECKING:
309 # Help pytype by hiding the interface stuff that confuses it.
310 localcommandexecutor = LocalCommandExecutor
311
312
313 class LocalPeer(repository.peer):
306 314 '''peer for a local repo; reflects only the most recent API'''
307 315
308 316 def __init__(self, repo, caps=None, path=None, remotehidden=False):
309 super(localpeer, self).__init__(
317 super(LocalPeer, self).__init__(
310 318 repo.ui, path=path, remotehidden=remotehidden
311 319 )
312 320
@@ -456,13 +464,19 class localpeer(repository.peer):
456 464 # End of peer interface.
457 465
458 466
459 @interfaceutil.implementer(repository.ipeerlegacycommands)
460 class locallegacypeer(localpeer):
467 localpeer = interfaceutil.implementer(repository.ipeercommands)(LocalPeer)
468
469 if typing.TYPE_CHECKING:
470 # Help pytype by hiding the interface stuff that confuses it.
471 localpeer = LocalPeer
472
473
474 class LocalLegacyPeer(localpeer):
461 475 """peer extension which implements legacy methods too; used for tests with
462 476 restricted capabilities"""
463 477
464 478 def __init__(self, repo, path=None, remotehidden=False):
465 super(locallegacypeer, self).__init__(
479 super(LocalLegacyPeer, self).__init__(
466 480 repo, caps=legacycaps, path=path, remotehidden=remotehidden
467 481 )
468 482
@@ -489,6 +503,14 class locallegacypeer(localpeer):
489 503 # End of baselegacywirecommands interface.
490 504
491 505
506 locallegacypeer = interfaceutil.implementer(repository.ipeerlegacycommands)(
507 LocalLegacyPeer
508 )
509
510 if typing.TYPE_CHECKING:
511 # Help pytype by hiding the interface stuff that confuses it.
512 locallegacypeer = LocalLegacyPeer
513
492 514 # Functions receiving (ui, features) that extensions can register to impact
493 515 # the ability to load repositories with custom requirements. Only
494 516 # functions defined in loaded extensions are called.
@@ -1241,8 +1263,7 def makemain(**kwargs):
1241 1263 return localrepository
1242 1264
1243 1265
1244 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1245 class revlogfilestorage:
1266 class RevlogFileStorage:
1246 1267 """File storage when using revlogs."""
1247 1268
1248 1269 def file(self, path):
@@ -1257,8 +1278,16 class revlogfilestorage:
1257 1278 return filelog.filelog(self.svfs, path, try_split=try_split)
1258 1279
1259 1280
1260 @interfaceutil.implementer(repository.ilocalrepositoryfilestorage)
1261 class revlognarrowfilestorage:
1281 revlogfilestorage = interfaceutil.implementer(
1282 repository.ilocalrepositoryfilestorage
1283 )(RevlogFileStorage)
1284
1285 if typing.TYPE_CHECKING:
1286 # Help pytype by hiding the interface stuff that confuses it.
1287 revlogfilestorage = RevlogFileStorage
1288
1289
1290 class RevlogNarrowFileStorage:
1262 1291 """File storage when using revlogs and narrow files."""
1263 1292
1264 1293 def file(self, path):
@@ -1274,6 +1303,15 class revlognarrowfilestorage:
1274 1303 )
1275 1304
1276 1305
1306 revlognarrowfilestorage = interfaceutil.implementer(
1307 repository.ilocalrepositoryfilestorage
1308 )(RevlogNarrowFileStorage)
1309
1310 if typing.TYPE_CHECKING:
1311 # Help pytype by hiding the interface stuff that confuses it.
1312 revlognarrowfilestorage = RevlogNarrowFileStorage
1313
1314
1277 1315 def makefilestorage(requirements, features, **kwargs):
1278 1316 """Produce a type conforming to ``ilocalrepositoryfilestorage``."""
1279 1317 features.add(repository.REPO_FEATURE_REVLOG_FILE_STORAGE)
@@ -1295,9 +1333,16 REPO_INTERFACES = [
1295 1333 (repository.ilocalrepositoryfilestorage, lambda: makefilestorage),
1296 1334 ]
1297 1335
1298
1299 @interfaceutil.implementer(repository.ilocalrepositorymain)
1300 class localrepository:
1336 _localrepo_base_classes = object
1337
1338 if typing.TYPE_CHECKING:
1339 _localrepo_base_classes = [
1340 repository.ilocalrepositorymain,
1341 repository.ilocalrepositoryfilestorage,
1342 ]
1343
1344
1345 class LocalRepository(_localrepo_base_classes):
1301 1346 """Main class for representing local repositories.
1302 1347
1303 1348 All local repositories are instances of this class.
@@ -3598,6 +3643,15 class localrepository:
3598 3643 self._sidedata_computers[kind][category] = (keys, computer, flags)
3599 3644
3600 3645
3646 localrepository = interfaceutil.implementer(repository.ilocalrepositorymain)(
3647 LocalRepository
3648 )
3649
3650 if typing.TYPE_CHECKING:
3651 # Help pytype by hiding the interface stuff that confuses it.
3652 localrepository = LocalRepository
3653
3654
3601 3655 def undoname(fn: bytes) -> bytes:
3602 3656 base, name = os.path.split(fn)
3603 3657 assert name.startswith(b'journal')
General Comments 0
You need to be logged in to leave comments. Login now