##// 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 from .thirdparty import (
19 from .thirdparty import (
20 cbor,
20 cbor,
21 )
21 )
22 from .thirdparty.zope import (
23 interface as zi,
24 )
22 from . import (
25 from . import (
23 bundle2,
26 bundle2,
24 error,
27 error,
25 httpconnection,
28 httpconnection,
26 pycompat,
29 pycompat,
30 repository,
27 statichttprepo,
31 statichttprepo,
28 url as urlmod,
32 url as urlmod,
29 util,
33 util,
@@ -513,6 +517,7 b' class httppeer(wireproto.wirepeer):'
513 raise exception
517 raise exception
514
518
515 # TODO implement interface for version 2 peers
519 # TODO implement interface for version 2 peers
520 @zi.implementer(repository.ipeerconnection)
516 class httpv2peer(object):
521 class httpv2peer(object):
517 def __init__(self, ui, repourl, apipath, opener, requestbuilder,
522 def __init__(self, ui, repourl, apipath, opener, requestbuilder,
518 apidescriptor):
523 apidescriptor):
@@ -521,15 +526,32 b' class httpv2peer(object):'
521 if repourl.endswith('/'):
526 if repourl.endswith('/'):
522 repourl = repourl[:-1]
527 repourl = repourl[:-1]
523
528
524 self.url = repourl
529 self._url = repourl
525 self._apipath = apipath
530 self._apipath = apipath
526 self._opener = opener
531 self._opener = opener
527 self._requestbuilder = requestbuilder
532 self._requestbuilder = requestbuilder
528 self._descriptor = apidescriptor
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 def close(self):
550 def close(self):
531 pass
551 pass
532
552
553 # End of ipeerconnection.
554
533 # TODO require to be part of a batched primitive, use futures.
555 # TODO require to be part of a batched primitive, use futures.
534 def _call(self, name, **args):
556 def _call(self, name, **args):
535 """Call a wire protocol command with arguments."""
557 """Call a wire protocol command with arguments."""
@@ -554,7 +576,7 b' class httpv2peer(object):'
554 'pull': 'ro',
576 'pull': 'ro',
555 }[permission]
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 # TODO this should be part of a generic peer for the frame-based
581 # TODO this should be part of a generic peer for the frame-based
560 # protocol.
582 # protocol.
@@ -92,6 +92,10 b' def main():'
92 httppeer.httppeer)
92 httppeer.httppeer)
93 checkzobject(httppeer.httppeer(None, None, None, dummyopener(), None, None))
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 ziverify.verifyClass(repository.ipeerbase,
99 ziverify.verifyClass(repository.ipeerbase,
96 localrepo.localpeer)
100 localrepo.localpeer)
97 checkzobject(localrepo.localpeer(dummyrepo()))
101 checkzobject(localrepo.localpeer(dummyrepo()))
General Comments 0
You need to be logged in to leave comments. Login now