##// END OF EJS Templates
httppeer: basic implementation of capabilities interface...
Gregory Szorc -
r37629:ae873087 default
parent child Browse files
Show More
@@ -517,7 +517,7 b' class httppeer(wireproto.wirepeer):'
517 raise exception
517 raise exception
518
518
519 # TODO implement interface for version 2 peers
519 # TODO implement interface for version 2 peers
520 @zi.implementer(repository.ipeerconnection)
520 @zi.implementer(repository.ipeerconnection, repository.ipeercapabilities)
521 class httpv2peer(object):
521 class httpv2peer(object):
522 def __init__(self, ui, repourl, apipath, opener, requestbuilder,
522 def __init__(self, ui, repourl, apipath, opener, requestbuilder,
523 apidescriptor):
523 apidescriptor):
@@ -552,6 +552,33 b' class httpv2peer(object):'
552
552
553 # End of ipeerconnection.
553 # End of ipeerconnection.
554
554
555 # Start of ipeercapabilities.
556
557 def capable(self, name):
558 # The capabilities used internally historically map to capabilities
559 # advertised from the "capabilities" wire protocol command. However,
560 # version 2 of that command works differently.
561
562 # Maps to commands that are available.
563 if name in ('branchmap', 'getbundle', 'known', 'lookup', 'pushkey'):
564 return True
565
566 # Other concepts.
567 if name in ('bundle2',):
568 return True
569
570 return False
571
572 def requirecap(self, name, purpose):
573 if self.capable(name):
574 return
575
576 raise error.CapabilityError(
577 _('cannot %s; client or remote repository does not support the %r '
578 'capability') % (purpose, name))
579
580 # End of ipeercapabilities.
581
555 # TODO require to be part of a batched primitive, use futures.
582 # TODO require to be part of a batched primitive, use futures.
556 def _call(self, name, **args):
583 def _call(self, name, **args):
557 """Call a wire protocol command with arguments."""
584 """Call a wire protocol command with arguments."""
@@ -94,6 +94,8 b' def main():'
94
94
95 ziverify.verifyClass(repository.ipeerconnection,
95 ziverify.verifyClass(repository.ipeerconnection,
96 httppeer.httpv2peer)
96 httppeer.httpv2peer)
97 ziverify.verifyClass(repository.ipeercapabilities,
98 httppeer.httpv2peer)
97 checkzobject(httppeer.httpv2peer(None, '', None, None, None, None))
99 checkzobject(httppeer.httpv2peer(None, '', None, None, None, None))
98
100
99 ziverify.verifyClass(repository.ipeerbase,
101 ziverify.verifyClass(repository.ipeerbase,
General Comments 0
You need to be logged in to leave comments. Login now