Show More
@@ -21,6 +21,7 b' from . import (' | |||||
21 | error, |
|
21 | error, | |
22 | httpconnection, |
|
22 | httpconnection, | |
23 | pycompat, |
|
23 | pycompat, | |
|
24 | repository, | |||
24 | statichttprepo, |
|
25 | statichttprepo, | |
25 | url, |
|
26 | url, | |
26 | util, |
|
27 | util, | |
@@ -86,7 +87,7 b' def _wraphttpresponse(resp):' | |||||
86 |
|
87 | |||
87 | resp.__class__ = readerproxy |
|
88 | resp.__class__ = readerproxy | |
88 |
|
89 | |||
89 | class httppeer(wireproto.wirepeer): |
|
90 | class httppeer(wireproto.wirepeer, repository.legacypeer): | |
90 | def __init__(self, ui, path): |
|
91 | def __init__(self, ui, path): | |
91 | self._path = path |
|
92 | self._path = path | |
92 | self._caps = None |
|
93 | self._caps = None | |
@@ -100,12 +101,15 b' class httppeer(wireproto.wirepeer):' | |||||
100 | # urllib cannot handle URLs with embedded user or passwd |
|
101 | # urllib cannot handle URLs with embedded user or passwd | |
101 | self._url, authinfo = u.authinfo() |
|
102 | self._url, authinfo = u.authinfo() | |
102 |
|
103 | |||
103 | self.ui = ui |
|
104 | self._ui = ui | |
104 |
|
|
105 | ui.debug('using %s\n' % self._url) | |
105 |
|
106 | |||
106 | self._urlopener = url.opener(ui, authinfo) |
|
107 | self._urlopener = url.opener(ui, authinfo) | |
107 | self._requestbuilder = urlreq.request |
|
108 | self._requestbuilder = urlreq.request | |
108 |
|
109 | |||
|
110 | # TODO remove once peerrepository isn't in inheritance. | |||
|
111 | self._capabilities = self.capabilities | |||
|
112 | ||||
109 | def __del__(self): |
|
113 | def __del__(self): | |
110 | urlopener = getattr(self, '_urlopener', None) |
|
114 | urlopener = getattr(self, '_urlopener', None) | |
111 | if urlopener: |
|
115 | if urlopener: | |
@@ -113,15 +117,32 b' class httppeer(wireproto.wirepeer):' | |||||
113 | h.close() |
|
117 | h.close() | |
114 | getattr(h, "close_all", lambda : None)() |
|
118 | getattr(h, "close_all", lambda : None)() | |
115 |
|
119 | |||
|
120 | # Begin of _basepeer interface. | |||
|
121 | ||||
|
122 | @util.propertycache | |||
|
123 | def ui(self): | |||
|
124 | return self._ui | |||
|
125 | ||||
116 | def url(self): |
|
126 | def url(self): | |
117 | return self._path |
|
127 | return self._path | |
118 |
|
128 | |||
119 | # look up capabilities only when needed |
|
129 | def local(self): | |
|
130 | return None | |||
|
131 | ||||
|
132 | def peer(self): | |||
|
133 | return self | |||
|
134 | ||||
|
135 | def canpush(self): | |||
|
136 | return True | |||
120 |
|
137 | |||
121 |
def |
|
138 | def close(self): | |
122 | self._caps = set(self._call('capabilities').split()) |
|
139 | pass | |
123 |
|
140 | |||
124 | def _capabilities(self): |
|
141 | # End of _basepeer interface. | |
|
142 | ||||
|
143 | # Begin of _basewirepeer interface. | |||
|
144 | ||||
|
145 | def capabilities(self): | |||
125 | if self._caps is None: |
|
146 | if self._caps is None: | |
126 | try: |
|
147 | try: | |
127 | self._fetchcaps() |
|
148 | self._fetchcaps() | |
@@ -131,6 +152,13 b' class httppeer(wireproto.wirepeer):' | |||||
131 | (' '.join(self._caps or ['none']))) |
|
152 | (' '.join(self._caps or ['none']))) | |
132 | return self._caps |
|
153 | return self._caps | |
133 |
|
154 | |||
|
155 | # End of _basewirepeer interface. | |||
|
156 | ||||
|
157 | # look up capabilities only when needed | |||
|
158 | ||||
|
159 | def _fetchcaps(self): | |||
|
160 | self._caps = set(self._call('capabilities').split()) | |||
|
161 | ||||
134 | def _callstream(self, cmd, _compressible=False, **args): |
|
162 | def _callstream(self, cmd, _compressible=False, **args): | |
135 | if cmd == 'pushkey': |
|
163 | if cmd == 'pushkey': | |
136 | args['data'] = '' |
|
164 | args['data'] = '' |
General Comments 0
You need to be logged in to leave comments.
Login now