Show More
@@ -0,0 +1,40 b'' | |||
|
1 | # interfaceutil.py - Utilities for declaring interfaces. | |
|
2 | # | |
|
3 | # Copyright 2018 Gregory Szorc <gregory.szorc@gmail.com> | |
|
4 | # | |
|
5 | # This software may be used and distributed according to the terms of the | |
|
6 | # GNU General Public License version 2 or any later version. | |
|
7 | ||
|
8 | # zope.interface imposes a run-time cost due to module import overhead and | |
|
9 | # bookkeeping for declaring interfaces. So, we use stubs for various | |
|
10 | # zope.interface primitives unless instructed otherwise. | |
|
11 | ||
|
12 | from __future__ import absolute_import | |
|
13 | ||
|
14 | from .. import ( | |
|
15 | encoding, | |
|
16 | ) | |
|
17 | ||
|
18 | if encoding.environ.get('HGREALINTERFACES'): | |
|
19 | from ..thirdparty.zope import ( | |
|
20 | interface as zi, | |
|
21 | ) | |
|
22 | ||
|
23 | Attribute = zi.Attribute | |
|
24 | Interface = zi.Interface | |
|
25 | implementer = zi.implementer | |
|
26 | else: | |
|
27 | class Attribute(object): | |
|
28 | def __init__(self, __name__, __doc__=''): | |
|
29 | pass | |
|
30 | ||
|
31 | class Interface(object): | |
|
32 | def __init__(self, name, bases=(), attrs=None, __doc__=None, | |
|
33 | __module__=None): | |
|
34 | pass | |
|
35 | ||
|
36 | def implementer(*ifaces): | |
|
37 | def wrapper(cls): | |
|
38 | return cls | |
|
39 | ||
|
40 | return wrapper |
@@ -7,16 +7,16 b'' | |||
|
7 | 7 | |
|
8 | 8 | from __future__ import absolute_import |
|
9 | 9 | |
|
10 | from .thirdparty.zope import ( | |
|
11 | interface as zi, | |
|
12 | ) | |
|
13 | 10 | from . import ( |
|
14 | 11 | error, |
|
15 | 12 | repository, |
|
16 | 13 | revlog, |
|
17 | 14 | ) |
|
15 | from .utils import ( | |
|
16 | interfaceutil, | |
|
17 | ) | |
|
18 | 18 | |
|
19 |
@ |
|
|
19 | @interfaceutil.implementer(repository.ifilestorage) | |
|
20 | 20 | class filelog(object): |
|
21 | 21 | def __init__(self, opener, path): |
|
22 | 22 | self._revlog = revlog.revlog(opener, |
@@ -20,9 +20,6 b' from .i18n import _' | |||
|
20 | 20 | from .thirdparty import ( |
|
21 | 21 | cbor, |
|
22 | 22 | ) |
|
23 | from .thirdparty.zope import ( | |
|
24 | interface as zi, | |
|
25 | ) | |
|
26 | 23 | from . import ( |
|
27 | 24 | bundle2, |
|
28 | 25 | error, |
@@ -38,6 +35,9 b' from . import (' | |||
|
38 | 35 | wireprotov2peer, |
|
39 | 36 | wireprotov2server, |
|
40 | 37 | ) |
|
38 | from .utils import ( | |
|
39 | interfaceutil, | |
|
40 | ) | |
|
41 | 41 | |
|
42 | 42 | httplib = util.httplib |
|
43 | 43 | urlerr = util.urlerr |
@@ -582,7 +582,7 b' class queuedcommandfuture(pycompat.futur' | |||
|
582 | 582 | # will resolve to Future.result. |
|
583 | 583 | return self.result(timeout) |
|
584 | 584 | |
|
585 |
@ |
|
|
585 | @interfaceutil.implementer(repository.ipeercommandexecutor) | |
|
586 | 586 | class httpv2executor(object): |
|
587 | 587 | def __init__(self, ui, opener, requestbuilder, apiurl, descriptor): |
|
588 | 588 | self._ui = ui |
@@ -731,8 +731,9 b' class httpv2executor(object):' | |||
|
731 | 731 | pass |
|
732 | 732 | |
|
733 | 733 | # TODO implement interface for version 2 peers |
|
734 |
@ |
|
|
735 |
repository.ipeer |
|
|
734 | @interfaceutil.implementer(repository.ipeerconnection, | |
|
735 | repository.ipeercapabilities, | |
|
736 | repository.ipeerrequests) | |
|
736 | 737 | class httpv2peer(object): |
|
737 | 738 | def __init__(self, ui, repourl, apipath, opener, requestbuilder, |
|
738 | 739 | apidescriptor): |
@@ -21,9 +21,6 b' from .node import (' | |||
|
21 | 21 | nullid, |
|
22 | 22 | short, |
|
23 | 23 | ) |
|
24 | from .thirdparty.zope import ( | |
|
25 | interface as zi, | |
|
26 | ) | |
|
27 | 24 | from . import ( |
|
28 | 25 | bookmarks, |
|
29 | 26 | branchmap, |
@@ -68,6 +65,7 b' from . import (' | |||
|
68 | 65 | vfs as vfsmod, |
|
69 | 66 | ) |
|
70 | 67 | from .utils import ( |
|
68 | interfaceutil, | |
|
71 | 69 | procutil, |
|
72 | 70 | stringutil, |
|
73 | 71 | ) |
@@ -153,7 +151,7 b" moderncaps = {'lookup', 'branchmap', 'pu" | |||
|
153 | 151 | 'unbundle'} |
|
154 | 152 | legacycaps = moderncaps.union({'changegroupsubset'}) |
|
155 | 153 | |
|
156 |
@ |
|
|
154 | @interfaceutil.implementer(repository.ipeercommandexecutor) | |
|
157 | 155 | class localcommandexecutor(object): |
|
158 | 156 | def __init__(self, peer): |
|
159 | 157 | self._peer = peer |
@@ -196,7 +194,7 b' class localcommandexecutor(object):' | |||
|
196 | 194 | def close(self): |
|
197 | 195 | self._closed = True |
|
198 | 196 | |
|
199 |
@ |
|
|
197 | @interfaceutil.implementer(repository.ipeercommands) | |
|
200 | 198 | class localpeer(repository.peer): |
|
201 | 199 | '''peer for a local repo; reflects only the most recent API''' |
|
202 | 200 | |
@@ -324,7 +322,7 b' class localpeer(repository.peer):' | |||
|
324 | 322 | |
|
325 | 323 | # End of peer interface. |
|
326 | 324 | |
|
327 |
@ |
|
|
325 | @interfaceutil.implementer(repository.ipeerlegacycommands) | |
|
328 | 326 | class locallegacypeer(localpeer): |
|
329 | 327 | '''peer extension which implements legacy methods too; used for tests with |
|
330 | 328 | restricted capabilities''' |
@@ -365,7 +363,7 b" REVLOGV2_REQUIREMENT = 'exp-revlogv2.0'" | |||
|
365 | 363 | # set to reflect that the extension knows how to handle that requirements. |
|
366 | 364 | featuresetupfuncs = set() |
|
367 | 365 | |
|
368 |
@ |
|
|
366 | @interfaceutil.implementer(repository.completelocalrepository) | |
|
369 | 367 | class localrepository(object): |
|
370 | 368 | |
|
371 | 369 | # obsolete experimental requirements: |
@@ -8,14 +8,14 b'' | |||
|
8 | 8 | from __future__ import absolute_import |
|
9 | 9 | |
|
10 | 10 | from .i18n import _ |
|
11 | from .thirdparty.zope import ( | |
|
12 | interface as zi, | |
|
13 | ) | |
|
14 | 11 | from . import ( |
|
15 | 12 | error, |
|
16 | 13 | ) |
|
14 | from .utils import ( | |
|
15 | interfaceutil, | |
|
16 | ) | |
|
17 | 17 | |
|
18 |
class ipeerconnection( |
|
|
18 | class ipeerconnection(interfaceutil.Interface): | |
|
19 | 19 | """Represents a "connection" to a repository. |
|
20 | 20 | |
|
21 | 21 | This is the base interface for representing a connection to a repository. |
@@ -24,7 +24,7 b' class ipeerconnection(zi.Interface):' | |||
|
24 | 24 | This is not a complete interface definition and should not be used |
|
25 | 25 | outside of this module. |
|
26 | 26 | """ |
|
27 |
ui = |
|
|
27 | ui = interfaceutil.Attribute("""ui.ui instance""") | |
|
28 | 28 | |
|
29 | 29 | def url(): |
|
30 | 30 | """Returns a URL string representing this peer. |
@@ -61,7 +61,7 b' class ipeerconnection(zi.Interface):' | |||
|
61 | 61 | associated with the peer should be cleaned up. |
|
62 | 62 | """ |
|
63 | 63 | |
|
64 |
class ipeercapabilities( |
|
|
64 | class ipeercapabilities(interfaceutil.Interface): | |
|
65 | 65 | """Peer sub-interface related to capabilities.""" |
|
66 | 66 | |
|
67 | 67 | def capable(name): |
@@ -81,7 +81,7 b' class ipeercapabilities(zi.Interface):' | |||
|
81 | 81 | Raises a ``CapabilityError`` if the capability isn't present. |
|
82 | 82 | """ |
|
83 | 83 | |
|
84 |
class ipeercommands( |
|
|
84 | class ipeercommands(interfaceutil.Interface): | |
|
85 | 85 | """Client-side interface for communicating over the wire protocol. |
|
86 | 86 | |
|
87 | 87 | This interface is used as a gateway to the Mercurial wire protocol. |
@@ -170,7 +170,7 b' class ipeercommands(zi.Interface):' | |||
|
170 | 170 | Returns the integer number of heads added to the peer. |
|
171 | 171 | """ |
|
172 | 172 | |
|
173 |
class ipeerlegacycommands( |
|
|
173 | class ipeerlegacycommands(interfaceutil.Interface): | |
|
174 | 174 | """Interface for implementing support for legacy wire protocol commands. |
|
175 | 175 | |
|
176 | 176 | Wire protocol commands transition to legacy status when they are no longer |
@@ -202,7 +202,7 b' class ipeerlegacycommands(zi.Interface):' | |||
|
202 | 202 | def changegroupsubset(bases, heads, source): |
|
203 | 203 | pass |
|
204 | 204 | |
|
205 |
class ipeercommandexecutor( |
|
|
205 | class ipeercommandexecutor(interfaceutil.Interface): | |
|
206 | 206 | """Represents a mechanism to execute remote commands. |
|
207 | 207 | |
|
208 | 208 | This is the primary interface for requesting that wire protocol commands |
@@ -259,7 +259,7 b' class ipeercommandexecutor(zi.Interface)' | |||
|
259 | 259 | This method may call ``sendcommands()`` if there are buffered commands. |
|
260 | 260 | """ |
|
261 | 261 | |
|
262 |
class ipeerrequests( |
|
|
262 | class ipeerrequests(interfaceutil.Interface): | |
|
263 | 263 | """Interface for executing commands on a peer.""" |
|
264 | 264 | |
|
265 | 265 | def commandexecutor(): |
@@ -290,7 +290,7 b' class ipeerbase(ipeerconnection, ipeerca' | |||
|
290 | 290 | All peer instances must conform to this interface. |
|
291 | 291 | """ |
|
292 | 292 | |
|
293 |
@ |
|
|
293 | @interfaceutil.implementer(ipeerbase) | |
|
294 | 294 | class peer(object): |
|
295 | 295 | """Base class for peer repositories.""" |
|
296 | 296 | |
@@ -314,7 +314,7 b' class peer(object):' | |||
|
314 | 314 | _('cannot %s; remote repository does not support the %r ' |
|
315 | 315 | 'capability') % (purpose, name)) |
|
316 | 316 | |
|
317 |
class ifilerevisionssequence( |
|
|
317 | class ifilerevisionssequence(interfaceutil.Interface): | |
|
318 | 318 | """Contains index data for all revisions of a file. |
|
319 | 319 | |
|
320 | 320 | Types implementing this behave like lists of tuples. The index |
@@ -365,7 +365,7 b' class ifilerevisionssequence(zi.Interfac' | |||
|
365 | 365 | def insert(self, i, entry): |
|
366 | 366 | """Add an item to the index at specific revision.""" |
|
367 | 367 | |
|
368 |
class ifileindex( |
|
|
368 | class ifileindex(interfaceutil.Interface): | |
|
369 | 369 | """Storage interface for index data of a single file. |
|
370 | 370 | |
|
371 | 371 | File storage data is divided into index metadata and data storage. |
@@ -377,7 +377,7 b' class ifileindex(zi.Interface):' | |||
|
377 | 377 | * DAG data (storing and querying the relationship between nodes). |
|
378 | 378 | * Metadata to facilitate storage. |
|
379 | 379 | """ |
|
380 |
index = |
|
|
380 | index = interfaceutil.Attribute( | |
|
381 | 381 | """An ``ifilerevisionssequence`` instance.""") |
|
382 | 382 | |
|
383 | 383 | def __len__(): |
@@ -470,7 +470,7 b' class ifileindex(zi.Interface):' | |||
|
470 | 470 | def candelta(baserev, rev): |
|
471 | 471 | """"Whether a delta can be generated between two revisions.""" |
|
472 | 472 | |
|
473 |
class ifiledata( |
|
|
473 | class ifiledata(interfaceutil.Interface): | |
|
474 | 474 | """Storage interface for data storage of a specific file. |
|
475 | 475 | |
|
476 | 476 | This complements ``ifileindex`` and provides an interface for accessing |
@@ -536,7 +536,7 b' class ifiledata(zi.Interface):' | |||
|
536 | 536 | revision data. |
|
537 | 537 | """ |
|
538 | 538 | |
|
539 |
class ifilemutation( |
|
|
539 | class ifilemutation(interfaceutil.Interface): | |
|
540 | 540 | """Storage interface for mutation events of a tracked file.""" |
|
541 | 541 | |
|
542 | 542 | def add(filedata, meta, transaction, linkrev, p1, p2): |
@@ -608,13 +608,13 b' class ifilemutation(zi.Interface):' | |||
|
608 | 608 | class ifilestorage(ifileindex, ifiledata, ifilemutation): |
|
609 | 609 | """Complete storage interface for a single tracked file.""" |
|
610 | 610 | |
|
611 |
version = |
|
|
611 | version = interfaceutil.Attribute( | |
|
612 | 612 | """Version number of storage. |
|
613 | 613 | |
|
614 | 614 | TODO this feels revlog centric and could likely be removed. |
|
615 | 615 | """) |
|
616 | 616 | |
|
617 |
storedeltachains = |
|
|
617 | storedeltachains = interfaceutil.Attribute( | |
|
618 | 618 | """Whether the store stores deltas. |
|
619 | 619 | |
|
620 | 620 | TODO deltachains are revlog centric. This can probably removed |
@@ -622,7 +622,7 b' class ifilestorage(ifileindex, ifiledata' | |||
|
622 | 622 | data. |
|
623 | 623 | """) |
|
624 | 624 | |
|
625 |
_generaldelta = |
|
|
625 | _generaldelta = interfaceutil.Attribute( | |
|
626 | 626 | """Whether deltas can be against any parent revision. |
|
627 | 627 | |
|
628 | 628 | TODO this is used by changegroup code and it could probably be |
@@ -642,59 +642,59 b' class ifilestorage(ifileindex, ifiledata' | |||
|
642 | 642 | TODO this is used by verify and it should not be part of the interface. |
|
643 | 643 | """ |
|
644 | 644 | |
|
645 |
class completelocalrepository( |
|
|
645 | class completelocalrepository(interfaceutil.Interface): | |
|
646 | 646 | """Monolithic interface for local repositories. |
|
647 | 647 | |
|
648 | 648 | This currently captures the reality of things - not how things should be. |
|
649 | 649 | """ |
|
650 | 650 | |
|
651 |
supportedformats = |
|
|
651 | supportedformats = interfaceutil.Attribute( | |
|
652 | 652 | """Set of requirements that apply to stream clone. |
|
653 | 653 | |
|
654 | 654 | This is actually a class attribute and is shared among all instances. |
|
655 | 655 | """) |
|
656 | 656 | |
|
657 |
openerreqs = |
|
|
657 | openerreqs = interfaceutil.Attribute( | |
|
658 | 658 | """Set of requirements that are passed to the opener. |
|
659 | 659 | |
|
660 | 660 | This is actually a class attribute and is shared among all instances. |
|
661 | 661 | """) |
|
662 | 662 | |
|
663 |
supported = |
|
|
663 | supported = interfaceutil.Attribute( | |
|
664 | 664 | """Set of requirements that this repo is capable of opening.""") |
|
665 | 665 | |
|
666 |
requirements = |
|
|
666 | requirements = interfaceutil.Attribute( | |
|
667 | 667 | """Set of requirements this repo uses.""") |
|
668 | 668 | |
|
669 |
filtername = |
|
|
669 | filtername = interfaceutil.Attribute( | |
|
670 | 670 | """Name of the repoview that is active on this repo.""") |
|
671 | 671 | |
|
672 |
wvfs = |
|
|
672 | wvfs = interfaceutil.Attribute( | |
|
673 | 673 | """VFS used to access the working directory.""") |
|
674 | 674 | |
|
675 |
vfs = |
|
|
675 | vfs = interfaceutil.Attribute( | |
|
676 | 676 | """VFS rooted at the .hg directory. |
|
677 | 677 | |
|
678 | 678 | Used to access repository data not in the store. |
|
679 | 679 | """) |
|
680 | 680 | |
|
681 |
svfs = |
|
|
681 | svfs = interfaceutil.Attribute( | |
|
682 | 682 | """VFS rooted at the store. |
|
683 | 683 | |
|
684 | 684 | Used to access repository data in the store. Typically .hg/store. |
|
685 | 685 | But can point elsewhere if the store is shared. |
|
686 | 686 | """) |
|
687 | 687 | |
|
688 |
root = |
|
|
688 | root = interfaceutil.Attribute( | |
|
689 | 689 | """Path to the root of the working directory.""") |
|
690 | 690 | |
|
691 |
path = |
|
|
691 | path = interfaceutil.Attribute( | |
|
692 | 692 | """Path to the .hg directory.""") |
|
693 | 693 | |
|
694 |
origroot = |
|
|
694 | origroot = interfaceutil.Attribute( | |
|
695 | 695 | """The filesystem path that was used to construct the repo.""") |
|
696 | 696 | |
|
697 |
auditor = |
|
|
697 | auditor = interfaceutil.Attribute( | |
|
698 | 698 | """A pathauditor for the working directory. |
|
699 | 699 | |
|
700 | 700 | This checks if a path refers to a nested repository. |
@@ -702,40 +702,40 b' class completelocalrepository(zi.Interfa' | |||
|
702 | 702 | Operates on the filesystem. |
|
703 | 703 | """) |
|
704 | 704 | |
|
705 |
nofsauditor = |
|
|
705 | nofsauditor = interfaceutil.Attribute( | |
|
706 | 706 | """A pathauditor for the working directory. |
|
707 | 707 | |
|
708 | 708 | This is like ``auditor`` except it doesn't do filesystem checks. |
|
709 | 709 | """) |
|
710 | 710 | |
|
711 |
baseui = |
|
|
711 | baseui = interfaceutil.Attribute( | |
|
712 | 712 | """Original ui instance passed into constructor.""") |
|
713 | 713 | |
|
714 |
ui = |
|
|
714 | ui = interfaceutil.Attribute( | |
|
715 | 715 | """Main ui instance for this instance.""") |
|
716 | 716 | |
|
717 |
sharedpath = |
|
|
717 | sharedpath = interfaceutil.Attribute( | |
|
718 | 718 | """Path to the .hg directory of the repo this repo was shared from.""") |
|
719 | 719 | |
|
720 |
store = |
|
|
720 | store = interfaceutil.Attribute( | |
|
721 | 721 | """A store instance.""") |
|
722 | 722 | |
|
723 |
spath = |
|
|
723 | spath = interfaceutil.Attribute( | |
|
724 | 724 | """Path to the store.""") |
|
725 | 725 | |
|
726 |
sjoin = |
|
|
726 | sjoin = interfaceutil.Attribute( | |
|
727 | 727 | """Alias to self.store.join.""") |
|
728 | 728 | |
|
729 |
cachevfs = |
|
|
729 | cachevfs = interfaceutil.Attribute( | |
|
730 | 730 | """A VFS used to access the cache directory. |
|
731 | 731 | |
|
732 | 732 | Typically .hg/cache. |
|
733 | 733 | """) |
|
734 | 734 | |
|
735 |
filteredrevcache = |
|
|
735 | filteredrevcache = interfaceutil.Attribute( | |
|
736 | 736 | """Holds sets of revisions to be filtered.""") |
|
737 | 737 | |
|
738 |
names = |
|
|
738 | names = interfaceutil.Attribute( | |
|
739 | 739 | """A ``namespaces`` instance.""") |
|
740 | 740 | |
|
741 | 741 | def close(): |
@@ -750,19 +750,19 b' class completelocalrepository(zi.Interfa' | |||
|
750 | 750 | def filtered(name, visibilityexceptions=None): |
|
751 | 751 | """Obtain a named view of this repository.""" |
|
752 | 752 | |
|
753 |
obsstore = |
|
|
753 | obsstore = interfaceutil.Attribute( | |
|
754 | 754 | """A store of obsolescence data.""") |
|
755 | 755 | |
|
756 |
changelog = |
|
|
756 | changelog = interfaceutil.Attribute( | |
|
757 | 757 | """A handle on the changelog revlog.""") |
|
758 | 758 | |
|
759 |
manifestlog = |
|
|
759 | manifestlog = interfaceutil.Attribute( | |
|
760 | 760 | """A handle on the root manifest revlog.""") |
|
761 | 761 | |
|
762 |
dirstate = |
|
|
762 | dirstate = interfaceutil.Attribute( | |
|
763 | 763 | """Working directory state.""") |
|
764 | 764 | |
|
765 |
narrowpats = |
|
|
765 | narrowpats = interfaceutil.Attribute( | |
|
766 | 766 | """Matcher patterns for this repository's narrowspec.""") |
|
767 | 767 | |
|
768 | 768 | def narrowmatch(): |
@@ -978,7 +978,7 b' class completelocalrepository(zi.Interfa' | |||
|
978 | 978 | def checkpush(pushop): |
|
979 | 979 | pass |
|
980 | 980 | |
|
981 |
prepushoutgoinghooks = |
|
|
981 | prepushoutgoinghooks = interfaceutil.Attribute( | |
|
982 | 982 | """util.hooks instance.""") |
|
983 | 983 | |
|
984 | 984 | def pushkey(namespace, key, old, new): |
@@ -15,9 +15,6 b' from .i18n import _' | |||
|
15 | 15 | from .thirdparty import ( |
|
16 | 16 | cbor, |
|
17 | 17 | ) |
|
18 | from .thirdparty.zope import ( | |
|
19 | interface as zi, | |
|
20 | ) | |
|
21 | 18 | from . import ( |
|
22 | 19 | encoding, |
|
23 | 20 | error, |
@@ -29,6 +26,7 b' from . import (' | |||
|
29 | 26 | wireprotov2server, |
|
30 | 27 | ) |
|
31 | 28 | from .utils import ( |
|
29 | interfaceutil, | |
|
32 | 30 | procutil, |
|
33 | 31 | ) |
|
34 | 32 | |
@@ -62,7 +60,7 b' def decodevaluefromheaders(req, headerpr' | |||
|
62 | 60 | |
|
63 | 61 | return ''.join(chunks) |
|
64 | 62 | |
|
65 |
@ |
|
|
63 | @interfaceutil.implementer(wireprototypes.baseprotocolhandler) | |
|
66 | 64 | class httpv1protocolhandler(object): |
|
67 | 65 | def __init__(self, req, ui, checkperm): |
|
68 | 66 | self._req = req |
@@ -489,7 +487,7 b' def _sshv1respondooberror(fout, ferr, rs' | |||
|
489 | 487 | fout.write(b'\n') |
|
490 | 488 | fout.flush() |
|
491 | 489 | |
|
492 |
@ |
|
|
490 | @interfaceutil.implementer(wireprototypes.baseprotocolhandler) | |
|
493 | 491 | class sshv1protocolhandler(object): |
|
494 | 492 | """Handler for requests services via version 1 of SSH protocol.""" |
|
495 | 493 | def __init__(self, ui, fin, fout): |
@@ -9,14 +9,14 b' from .node import (' | |||
|
9 | 9 | bin, |
|
10 | 10 | hex, |
|
11 | 11 | ) |
|
12 | from .thirdparty.zope import ( | |
|
13 | interface as zi, | |
|
14 | ) | |
|
15 | 12 | from .i18n import _ |
|
16 | 13 | from . import ( |
|
17 | 14 | error, |
|
18 | 15 | util, |
|
19 | 16 | ) |
|
17 | from .utils import ( | |
|
18 | interfaceutil, | |
|
19 | ) | |
|
20 | 20 | |
|
21 | 21 | # Names of the SSH protocol implementations. |
|
22 | 22 | SSHV1 = 'ssh-v1' |
@@ -179,7 +179,7 b' GETBUNDLE_ARGUMENTS = {' | |||
|
179 | 179 | 'stream': 'boolean', |
|
180 | 180 | } |
|
181 | 181 | |
|
182 |
class baseprotocolhandler( |
|
|
182 | class baseprotocolhandler(interfaceutil.Interface): | |
|
183 | 183 | """Abstract base class for wire protocol handlers. |
|
184 | 184 | |
|
185 | 185 | A wire protocol handler serves as an interface between protocol command |
@@ -188,7 +188,7 b' class baseprotocolhandler(zi.Interface):' | |||
|
188 | 188 | the request, handle response types, etc. |
|
189 | 189 | """ |
|
190 | 190 | |
|
191 |
name = |
|
|
191 | name = interfaceutil.Attribute( | |
|
192 | 192 | """The name of the protocol implementation. |
|
193 | 193 | |
|
194 | 194 | Used for uniquely identifying the transport type. |
@@ -15,9 +15,6 b' from .i18n import _' | |||
|
15 | 15 | from .node import ( |
|
16 | 16 | bin, |
|
17 | 17 | ) |
|
18 | from .thirdparty.zope import ( | |
|
19 | interface as zi, | |
|
20 | ) | |
|
21 | 18 | from . import ( |
|
22 | 19 | bundle2, |
|
23 | 20 | changegroup as changegroupmod, |
@@ -29,6 +26,9 b' from . import (' | |||
|
29 | 26 | util, |
|
30 | 27 | wireprototypes, |
|
31 | 28 | ) |
|
29 | from .utils import ( | |
|
30 | interfaceutil, | |
|
31 | ) | |
|
32 | 32 | |
|
33 | 33 | urlreq = util.urlreq |
|
34 | 34 | |
@@ -110,7 +110,7 b' class unsentfuture(pycompat.futures.Futu' | |||
|
110 | 110 | # on that. |
|
111 | 111 | return self.result(timeout) |
|
112 | 112 | |
|
113 |
@ |
|
|
113 | @interfaceutil.implementer(repository.ipeercommandexecutor) | |
|
114 | 114 | class peerexecutor(object): |
|
115 | 115 | def __init__(self, peer): |
|
116 | 116 | self._peer = peer |
@@ -308,7 +308,8 b' class peerexecutor(object):' | |||
|
308 | 308 | else: |
|
309 | 309 | f.set_result(result) |
|
310 | 310 | |
|
311 |
@ |
|
|
311 | @interfaceutil.implementer(repository.ipeercommands, | |
|
312 | repository.ipeerlegacycommands) | |
|
312 | 313 | class wirepeer(repository.peer): |
|
313 | 314 | """Client-side interface for communicating with a peer repository. |
|
314 | 315 |
@@ -12,9 +12,6 b' from .i18n import _' | |||
|
12 | 12 | from .thirdparty import ( |
|
13 | 13 | cbor, |
|
14 | 14 | ) |
|
15 | from .thirdparty.zope import ( | |
|
16 | interface as zi, | |
|
17 | ) | |
|
18 | 15 | from . import ( |
|
19 | 16 | encoding, |
|
20 | 17 | error, |
@@ -24,6 +21,9 b' from . import (' | |||
|
24 | 21 | wireprotoframing, |
|
25 | 22 | wireprototypes, |
|
26 | 23 | ) |
|
24 | from .utils import ( | |
|
25 | interfaceutil, | |
|
26 | ) | |
|
27 | 27 | |
|
28 | 28 | FRAMINGTYPE = b'application/mercurial-exp-framing-0005' |
|
29 | 29 | |
@@ -340,7 +340,7 b' def dispatch(repo, proto, command):' | |||
|
340 | 340 | |
|
341 | 341 | return func(repo, proto, **args) |
|
342 | 342 | |
|
343 |
@ |
|
|
343 | @interfaceutil.implementer(wireprototypes.baseprotocolhandler) | |
|
344 | 344 | class httpv2protocolhandler(object): |
|
345 | 345 | def __init__(self, req, ui, args=None): |
|
346 | 346 | self._req = req |
@@ -2,6 +2,9 b'' | |||
|
2 | 2 | |
|
3 | 3 | from __future__ import absolute_import, print_function |
|
4 | 4 | |
|
5 | from mercurial import encoding | |
|
6 | encoding.environ[b'HGREALINTERFACES'] = b'1' | |
|
7 | ||
|
5 | 8 | import os |
|
6 | 9 | |
|
7 | 10 | from mercurial.thirdparty.zope import ( |
@@ -27,6 +27,7 b' outputs, which should be fixed later.' | |||
|
27 | 27 | > -X i18n/posplit \ |
|
28 | 28 | > -X mercurial/thirdparty \ |
|
29 | 29 | > -X tests/hypothesishelpers.py \ |
|
30 | > -X tests/test-check-interfaces.py \ | |
|
30 | 31 | > -X tests/test-commit-interactive.t \ |
|
31 | 32 | > -X tests/test-contrib-check-code.t \ |
|
32 | 33 | > -X tests/test-demandimport.py \ |
General Comments 0
You need to be logged in to leave comments.
Login now