Mercurial > hg
changeset 37553:6b08cf6b900f
httppeer: allow opener to be passed to makepeer()
This allows us to use makepeer() in `hg debugwireproto`.
Differential Revision: https://phab.mercurial-scm.org/D3238
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 10 Apr 2018 13:07:13 -0700 |
parents | 8b8a845c85fc |
children | 301a1d2e8016 |
files | mercurial/debugcommands.py mercurial/httppeer.py |
diffstat | 2 files changed, 6 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/debugcommands.py Tue Apr 10 13:11:40 2018 -0700 +++ b/mercurial/debugcommands.py Tue Apr 10 13:07:13 2018 -0700 @@ -2915,12 +2915,7 @@ raise error.Abort(_('--peer %s not supported with HTTP peers') % opts['peer']) else: - url, caps = httppeer.performhandshake(ui, url, opener, - httppeer.urlreq.request) - - peer = httppeer.httppeer(ui, path, url, opener, - httppeer.urlreq.request, - caps) + peer = httppeer.makepeer(ui, path, opener=opener) # We /could/ populate stdin/stdout with sock.makefile()... else:
--- a/mercurial/httppeer.py Tue Apr 10 13:11:40 2018 -0700 +++ b/mercurial/httppeer.py Tue Apr 10 13:07:13 2018 -0700 @@ -620,9 +620,12 @@ return respurl, set(rawcaps.split()) -def makepeer(ui, path, requestbuilder=urlreq.request): +def makepeer(ui, path, opener=None, requestbuilder=urlreq.request): """Construct an appropriate HTTP peer instance. + ``opener`` is an ``url.opener`` that should be used to establish + connections, perform HTTP requests. + ``requestbuilder`` is the type used for constructing HTTP requests. It exists as an argument so extensions can override the default. """ @@ -635,7 +638,7 @@ url, authinfo = u.authinfo() ui.debug('using %s\n' % url) - opener = urlmod.opener(ui, authinfo) + opener = opener or urlmod.opener(ui, authinfo) respurl, caps = performhandshake(ui, url, opener, requestbuilder)