# HG changeset patch # User Gregory Szorc # Date 1523390833 25200 # Node ID 6b08cf6b900ff109ea3e2ecdf07a608ccf828a3b # Parent 8b8a845c85fc585977ad90c534a2860b9ada8e2c 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 diff -r 8b8a845c85fc -r 6b08cf6b900f mercurial/debugcommands.py --- 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: diff -r 8b8a845c85fc -r 6b08cf6b900f mercurial/httppeer.py --- 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)