bQc@sddlZddlZddlZddlZddlZddlZddlmZddlZddl Z ddl Z ddl Z dej fdYZdejfdYZdZe jedZery ejZWqek reZedd ZqXnd ejfd YZ d Zd ZdejfdYZerdejfdYZ dej!ej"fdYZ#ndej$fdYZ%dej&fdYZ'gZ(ddZ)ddZ*dS(iN(t_t passwordmgrcBs,eZdZdZdZdZRS(cCstjj|||_dS(N(turllib2tHTTPPasswordMgrWithDefaultRealmt__init__tui(tselfR((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRsc Cstjj|||}|\}}|rJ|rJ|j||||fS| sX| rtj|j||}|r|\}}|jd|jd}}|jjd|qn| s| r||jj st j t dn|jj t d|jj t d||rC|jj t d|n|jjt dd d}|s||jj}q|n|j|||||j||||fS( Ntusernametpasswords#using auth.%s.* for authentication shttp authorization requiredshttp authorization required s realm: %s s user: %s suser:tdefault(RRtfind_user_passwordt _writedebugthttpconnectionmodtreadauthforuriRtgettdebugt interactivetutiltAbortRtwritetprompttNonetgetpasst add_password( Rtrealmtauthuritauthinfotusertpasswdtrestgrouptauth((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR s2     cCs@td}|jj|||r1dt|p4dfdS(Ns http auth: user %s, password %s t*snot set(RRRtlen(RRRtmsg((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR 4s cCstjj|d|S(N(RRR R(RR((s1/sys/lib/python2.7/site-packages/mercurial/url.pytfind_stored_password8s (t__name__t __module__RR R R#(((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRs  t proxyhandlercBseZdZdZRS(cCs|jddptjd}|r|jdpB|jdsVd|d}ntj|}|js|jdd|_|jdd|_nd d g}|jg|j dd D]}|j ^q|jgtjd d j dD]$}|j r|j j ^q|j ddrDg|_n ||_t|}i|d6|d6}|jd|j|jfni}|jddrxNddd gD]:}y |tjkrtj|=nWqtk rqXqWntjj||||_dS(Nt http_proxythostshttp:shttps:shttp://t/RRt localhosts 127.0.0.1tnotno_proxytt,talwaysthttpthttpssproxying through http://%s:%s t HTTP_PROXY(tconfigtostgetenvt startswithRturlRRtextendt configlisttlowertsplittstript configbooltno_listtstrRR(tporttenvirontOSErrorRt ProxyHandlerRR(RRtproxyurltproxyR>tptproxiestenv((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR=s@!   ) %      css|jjdd}||jkr,dS|jdffdY}||_tjj||||S(Nt:it_requestcseZfdZRS(cs4|jdkr!|j}nj|||S(Nsproxy-authorization(R:R<t add_header(Rtkeytval(t baseclass(s1/sys/lib/python2.7/site-packages/mercurial/url.pyRKvs(R$R%RK((RN(s1/sys/lib/python2.7/site-packages/mercurial/url.pyRJus(tget_hostR;R>Rt __class__RRCt proxy_open(RtreqREttype_R(RJ((RNs1/sys/lib/python2.7/site-packages/mercurial/url.pyRQms  (R$R%RRQ(((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR&<s 0csfd}|S(NcsZt|tjrI|jdx4tj|D]}||q/Wn ||dS(Ni(t isinstanceR t httpsendfiletseekRt filechunkiter(Rtdatatchunk(torgsend(s1/sys/lib/python2.7/site-packages/mercurial/url.pyt _sendfiles  ((RZR[((RZs1/sys/lib/python2.7/site-packages/mercurial/url.pyt _gen_sendfile~s t HTTPSHandlerc Csd}|\}}xtj||dtjD]}|\}}} } } d} y\tj||| } |tk r| j|n|r| j|n| j| | SWq.tjk r}| dk r| j qq.Xq.Wtj|dS(Ns!getaddrinfo returns an empty listi( tsockett getaddrinfot SOCK_STREAMRt_GLOBAL_DEFAULT_TIMEOUTt settimeouttbindtconnectterrortclose( taddressttimeouttsource_addressR"R(R@Rtaftsocktypetprotot canonnametsatsock((s1/sys/lib/python2.7/site-packages/mercurial/url.pyt_create_connections" "   thttpconnectioncBs,eZeejjZdZdZRS(cCstrs|jrstjtjtj|_|jj|j|jft |rt j |jdd|_qnt jj|dS(N(t has_httpst realhostportR^tAF_INETR`RoRdR(R@t_generic_proxytunneltsslutiltssl_wrap_socketRt keepalivetHTTPConnection(R((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRds  !cCsKt|dd}|r;|jr.|jnd|_|Stjj|S(Ntproxyres(tgetattrRt will_closeRfRzRxRyt getresponse(RRz((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR}s   (R$R%R\RxRytsendRdR}(((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRqs cCst|dd}|r>|d d kr5d|}nt}n|j}t}|sh||jkrtj|}|s|jdkrdj |j |j pdg|_ |j j|_ |j j|jjdSnd|_ d|_ dS( Nt _tunnel_hostishttp://shttps:/shttps://R1RIt443(shttp://shttps:/(R{RtTruet get_selectortFalset get_full_urlRR7tschemetjoinR(R@Rstheaderstcopytupdatetparentt addheaders(thandlerthRRt tunnel_hostt new_tunneltu((s1/sys/lib/python2.7/site-packages/mercurial/url.pyt_generic_start_transactions    $ c Cstg|jD].}|jjdr ||j|f^q }|j|j|j|jd|jx%|j D]}|jd|q{W|jd|j |j d|j d|j }x^tr'|j\}}}|tjkrPnx)tr#|jjj}|sPqqWqW||_|j|_|jdkrx)trz|jj} | dkrRPqRqRWtS|dkrd |_nB|jd rd |_n'|d krd |_ntj||jd krd|_d|_d|_tjtj|_ t!Stj|j|_ d|j _|j j"d} | r| jdkrd|_d|_#n d|_|j$|_|j j"d} | r|j ryt%| |_Wnt&k rd|_qX|jdkrd|_qn d|_|tj'ksY|tj(ksYd|koEdknsY|j dkred|_n|j r|j r|jdkrd|_n||_)t!S(Nsproxy-sCONNECT %s HTTP/1.0 s%s: %s s tstricttmethodisHTTP/1.0i sHTTP/1.i sHTTP/0.9i iistransfer-encodingtchunkedscontent-lengthidtHEAD(*tdictRR:R6t _set_hostportR(R@R~Rst iteritemstresponse_classRoRt_methodRt _read_statusthttplibtCONTINUEtfptreadlineR<tstatustreasontversiontUnknownProtocolRtlengthRR|t HTTPMessaget cStringIOtStringIOR"Rt getheadert chunk_leftt _check_closetintt ValueErrort NO_CONTENTt NOT_MODIFIEDRz( Rtxt proxyheaderstheaderRRRRtskiptlinettrencR((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRus1                             t httphandlercBseZdZdZRS(cCs|jt|S(N(tdo_openRq(RRR((s1/sys/lib/python2.7/site-packages/mercurial/url.pyt http_open:scCs&t|||tjj|||S(N(RRxt HTTPHandlert_start_transaction(RRRR((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR=s(R$R%RR(((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR9s thttpsconnectioncBs;eZejZeejZeje j Z dZ RS(cCst|j|jf|_|j}|jrSt||jjddd}ntj|j|j |j tj |j ||_tj |j ||jdS(NRIii(RpR(R@RoRsRutrsplitRvRwtkey_filet cert_filet sslkwargsRt validator(RR(((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRdHs   ( R$R%Rxt HTTPResponseRR\tsafesendR~twrapgetresponseRtHTTPSConnectionR}Rd(((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRBs t httpshandlercBs/eZdZdZdZddZRS(cCs?tjj|tjj|||_t|j|_dS(N(RxtKeepAliveHandlerRRR]RRtpwmgr(RR((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRUs cCs&t|||tjj|||S(N(RRxRR(RRRR((s1/sys/lib/python2.7/site-packages/mercurial/url.pyR[scCs|j}|jj|\}}tj|j||}|rn|\}}||_|jjd|n d|_|j |j |S(Ns#using auth.%s.* for authentication ( RRR#R R RRRRRt_makeconnection(RRRR7RRRRR((s1/sys/lib/python2.7/site-packages/mercurial/url.pyt https_open_s    c Osd}d}t|dkr+|d}nt|dkrJ|d}n|d}|jrd|jkrd|jkr|jd}|jd}nt||||||}|j|_|S(NiiiRLtcert(RR!RRR(RR(R@targstkwargstkeyfiletcertfiletconn((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRms   '   N(R$R%RRRRR(((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRTs   thttpdigestauthhandlercBs#eZdZdZdZRS(cOs#tjj|||d|_dS(N(RtHTTPDigestAuthHandlerRRt retried_req(RRR((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRscCsdS(N((R((s1/sys/lib/python2.7/site-packages/mercurial/url.pytreset_retry_countscCs||jk r$||_d|_ny tjj|||||SWn6tk r|}|jd}|jdrvdSnXdS(Nis'AbstractDigestAuthHandler doesn't know (RtretriedRRthttp_error_auth_reqedRRR6(Rt auth_headerR(RRRtinsttarg((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRs    (R$R%RRR(((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRs  thttpbasicauthhandlercBs#eZdZdZdZRS(cOs#tjj|||d|_dS(N(RtHTTPBasicAuthHandlerRRR(RRR((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRscCsdS(N((R((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRscCs@||jk r$||_d|_ntjj|||||S(Ni(RRRRR(RRR(RRR((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRs    (R$R%RRR(((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRs  cCsM|jddtr3tj|t|g}n(tg}tr[|jt|n|jt |t|}|d k r|j ||dd!\}}|j d||rdt |pdfn|jt|t|f|jgtD]}|||^qtj|}d g|_|jjd|S(se construct an opener suitable for urllib2 authinfo will be added to the password manager Rtusehttp2iis http auth: user %s, password %s R snot sets User-agentsmercurial/proto-1.0tAcceptsapplication/mercurial-0.1N(s User-agentsmercurial/proto-1.0(Rsapplication/mercurial-0.1(R=RR t http2handlerRRRrtappendRR&RRRR!R8RRt handlerfuncsRt build_openerR(RRthandlerstpassmgrRRRtopener((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRs&     ') cCstj|}|jr?|jj|_|j\}}n4tjtjj|}dt j |}d}t ||j ||S(Nsfile://(RR7RR:RtnormpathR4tpathtabspathturllibt pathname2urlRRtopen(Rturl_RXRRR((s1/sys/lib/python2.7/site-packages/mercurial/url.pyRs (+RRRR4R^Rti18nRRxRRvRqR RRRCR&R\t safehasattrRrtcreate_connectionRptAttributeErrortobjectRaRRyRRuRRRRRR]RRRRRRRR(((s1/sys/lib/python2.7/site-packages/mercurial/url.pyt s4H$ -B      b".