D337: httppeer: use peer interface
indygreg (Gregory Szorc)
phabricator at mercurial-scm.org
Tue Aug 15 17:51:15 UTC 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGf913e90f15a0: httppeer: use peer interface (authored by indygreg).
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D337?vs=762&id=936
REVISION DETAIL
https://phab.mercurial-scm.org/D337
AFFECTED FILES
mercurial/httppeer.py
CHANGE DETAILS
diff --git a/mercurial/httppeer.py b/mercurial/httppeer.py
--- a/mercurial/httppeer.py
+++ b/mercurial/httppeer.py
@@ -21,6 +21,7 @@
error,
httpconnection,
pycompat,
+ repository,
statichttprepo,
url,
util,
@@ -86,7 +87,7 @@
resp.__class__ = readerproxy
-class httppeer(wireproto.wirepeer):
+class httppeer(wireproto.wirepeer, repository.legacypeer):
def __init__(self, ui, path):
self._path = path
self._caps = None
@@ -100,28 +101,48 @@
# urllib cannot handle URLs with embedded user or passwd
self._url, authinfo = u.authinfo()
- self.ui = ui
- self.ui.debug('using %s\n' % self._url)
+ self._ui = ui
+ ui.debug('using %s\n' % self._url)
self._urlopener = url.opener(ui, authinfo)
self._requestbuilder = urlreq.request
+ # TODO remove once peerrepository isn't in inheritance.
+ self._capabilities = self.capabilities
+
def __del__(self):
urlopener = getattr(self, '_urlopener', None)
if urlopener:
for h in urlopener.handlers:
h.close()
getattr(h, "close_all", lambda : None)()
+ # Begin of _basepeer interface.
+
+ @util.propertycache
+ def ui(self):
+ return self._ui
+
def url(self):
return self._path
- # look up capabilities only when needed
+ def local(self):
+ return None
+
+ def peer(self):
+ return self
+
+ def canpush(self):
+ return True
- def _fetchcaps(self):
- self._caps = set(self._call('capabilities').split())
+ def close(self):
+ pass
- def _capabilities(self):
+ # End of _basepeer interface.
+
+ # Begin of _basewirepeer interface.
+
+ def capabilities(self):
if self._caps is None:
try:
self._fetchcaps()
@@ -131,6 +152,13 @@
(' '.join(self._caps or ['none'])))
return self._caps
+ # End of _basewirepeer interface.
+
+ # look up capabilities only when needed
+
+ def _fetchcaps(self):
+ self._caps = set(self._call('capabilities').split())
+
def _callstream(self, cmd, _compressible=False, **args):
if cmd == 'pushkey':
args['data'] = ''
To: indygreg, #hg-reviewers
Cc: mercurial-devel
More information about the Mercurial-devel
mailing list