##// END OF EJS Templates
httppeer: implement ipeerconnection...
Gregory Szorc -
r37627:01bfe5ad default
parent child Browse files
Show More
@@ -19,11 +19,15 b' from .i18n import _'
19 19 from .thirdparty import (
20 20 cbor,
21 21 )
22 from .thirdparty.zope import (
23 interface as zi,
24 )
22 25 from . import (
23 26 bundle2,
24 27 error,
25 28 httpconnection,
26 29 pycompat,
30 repository,
27 31 statichttprepo,
28 32 url as urlmod,
29 33 util,
@@ -513,6 +517,7 b' class httppeer(wireproto.wirepeer):'
513 517 raise exception
514 518
515 519 # TODO implement interface for version 2 peers
520 @zi.implementer(repository.ipeerconnection)
516 521 class httpv2peer(object):
517 522 def __init__(self, ui, repourl, apipath, opener, requestbuilder,
518 523 apidescriptor):
@@ -521,15 +526,32 b' class httpv2peer(object):'
521 526 if repourl.endswith('/'):
522 527 repourl = repourl[:-1]
523 528
524 self.url = repourl
529 self._url = repourl
525 530 self._apipath = apipath
526 531 self._opener = opener
527 532 self._requestbuilder = requestbuilder
528 533 self._descriptor = apidescriptor
529 534
535 # Start of ipeerconnection.
536
537 def url(self):
538 return self._url
539
540 def local(self):
541 return None
542
543 def peer(self):
544 return self
545
546 def canpush(self):
547 # TODO change once implemented.
548 return False
549
530 550 def close(self):
531 551 pass
532 552
553 # End of ipeerconnection.
554
533 555 # TODO require to be part of a batched primitive, use futures.
534 556 def _call(self, name, **args):
535 557 """Call a wire protocol command with arguments."""
@@ -554,7 +576,7 b' class httpv2peer(object):'
554 576 'pull': 'ro',
555 577 }[permission]
556 578
557 url = '%s/%s/%s/%s' % (self.url, self._apipath, permission, name)
579 url = '%s/%s/%s/%s' % (self._url, self._apipath, permission, name)
558 580
559 581 # TODO this should be part of a generic peer for the frame-based
560 582 # protocol.
@@ -92,6 +92,10 b' def main():'
92 92 httppeer.httppeer)
93 93 checkzobject(httppeer.httppeer(None, None, None, dummyopener(), None, None))
94 94
95 ziverify.verifyClass(repository.ipeerconnection,
96 httppeer.httpv2peer)
97 checkzobject(httppeer.httpv2peer(None, '', None, None, None, None))
98
95 99 ziverify.verifyClass(repository.ipeerbase,
96 100 localrepo.localpeer)
97 101 checkzobject(localrepo.localpeer(dummyrepo()))
General Comments 0
You need to be logged in to leave comments. Login now