comparison mercurial/debugcommands.py @ 37552:8b8a845c85fc

httppeer: perform capabilities request in makepeer() Previously, we constructed an httppeer then always ran _fetchcaps() to issue the capabilities command. We want to issue the capabilities command before constructing a peer instance so we can construct an appropriate peer instance depending on the capabilities result. With the code for making and sending requests moved out of httppeer, it is now possible to send command requests without an httppeer. This commit creates a new function for making the capabilities request and calls it as part of makepeer(). This code should be functionality equivalent to what existed before. Differential Revision: https://phab.mercurial-scm.org/D3237
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 10 Apr 2018 13:11:40 -0700
parents 835ccc2a5ef1
children 6b08cf6b900f
comparison
equal deleted inserted replaced
37551:946eb204ba67 37552:8b8a845c85fc
2913 peer = None 2913 peer = None
2914 elif opts['peer']: 2914 elif opts['peer']:
2915 raise error.Abort(_('--peer %s not supported with HTTP peers') % 2915 raise error.Abort(_('--peer %s not supported with HTTP peers') %
2916 opts['peer']) 2916 opts['peer'])
2917 else: 2917 else:
2918 url, caps = httppeer.performhandshake(ui, url, opener,
2919 httppeer.urlreq.request)
2920
2918 peer = httppeer.httppeer(ui, path, url, opener, 2921 peer = httppeer.httppeer(ui, path, url, opener,
2919 requestbuilder=httppeer.urlreq.request) 2922 httppeer.urlreq.request,
2920 peer._fetchcaps() 2923 caps)
2921 2924
2922 # We /could/ populate stdin/stdout with sock.makefile()... 2925 # We /could/ populate stdin/stdout with sock.makefile()...
2923 else: 2926 else:
2924 raise error.Abort(_('unsupported connection configuration')) 2927 raise error.Abort(_('unsupported connection configuration'))
2925 2928