\x89\x50\x4E\x47\x0D\x0A\x1A\x0A PNG  \x89\x50\x4E\x47\x0D\x0A\x1A\x0A  13\c@@sddlmZddlZddlZddlmZddlmZmZm Z m Z m Z m Z m Z ddlmZmZdZdZd efd YZd Zdd Zd ZdZde jfdYZdefdYZedZdddZdS(i(tabsolute_importNi(t_(terrortpycompattutiltwireprotoservertwireprototypestwireprotov1peertwireprotov1server(tprocutilt stringutilcC@s4|s |Stjd|r |Sd|jddS(s=quote a string for the remote shell ... which we assume is shs[a-zA-Z0-9@%_+=:,./-]*$s'%s't's'\''(tretmatchtreplace(ts((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyt _serverquotes cC@sU|rQtj|}|rQx0|jD]}|jtd|dq(WqQndS(sYdisplay all data currently available on pipe as remote output. This is non blocking.sremote: s N(R treadpipet splitlineststatusR(tuitpipeRtl((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyt_forwardoutput$s t doublepipecB@sbeZdZdZdZdZdZdZdZd dZ dZ d Z RS( s3Operate a side-channel pipe in addition of a main one The side-channel pipe contains server output to be forwarded to the user input. The double pipe will behave as the "main" pipe, but will ensure the content of the "side" pipe is properly processed while we wait for blocking call on the "main" pipe. If large amounts of data are read from "main", the forward will cease after the first bytes start to appear. This simplifies the implementation without affecting actual output of sshpeer too much as we rarely issue large read for data not yet emitted by the server. The main pipe is expected to be a 'bufferedinputpipe' from the util module that handle all the os specific bits. This class lives in this module because it focus on behavior specific to the ssh protocol.cC@s||_||_||_dS(N(t_uit_maint_side(tselfRtmaintside((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyt__init__?s  cC@st|jtjr+|jjr+ttfS|jj|jjg}ytj|}Wnt k ru|}nX|jj|k|jj|kfS(swait until some data are available on main or side return a pair of boolean (ismainready, issideready) (This will only wait for data if the setup is supported by `util.poll`) ( t isinstanceRRtbufferedinputpipet hasbuffertTruetfilenoRtpolltNotImplementedError(Rtfdstact((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyt_waitDs    cC@s|jd|S(Ntwrite(t_call(Rtdata((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyR*XscC@s?|jd|}|dkr;| r;t|j|jn|S(Ntreadi(R+RRR(Rtsizetr((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyR-[scC@s?|jd|}|dkr;| r;t|j|jn|S(Ntunbufferedreadi(R+RRR(RR.R/((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyR0fscC@s |jdS(Ntreadline(R+(R((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyR1qscC@s|dk r| s|jjr6t|j|jdSxptr|j\}}|rmt|j|jn|r9t|j|}|dkr|S||Sq9q9WdS(sKcall on "main", forward output of "side" while blocking tN( tNoneRtclosedRRRR#R)tgetattr(RtmethnameR,t mainreadyt sidereadytmeth((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyR+ts  cC@s |jjS(N(Rtclose(R((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyR:scC@s |jjS(N(Rtflush(R((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyR;sN( t__name__t __module__t__doc__RR)R*R-R0R1R3R+R:R;(((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyR.s      cC@s|r|jn|r&|jn|r~y+x$|D]}|jtd|q6WWnttfk rpnX|jndS(s)Clean up pipes used by an SSH connection.sremote: N(R:RRtIOErrort ValueError(RtpipeitpipeotpipeeR((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyt _cleanuppipess   c C@sd||tjdt|t|ff}|jd|tj|}tj|ddd|\}}} } | ||| fS(sCreate an SSH connection to a server. Returns a tuple of (process, stdin, stdout, stderr) for the spawned process. s%s %s %ss%s -R %s serve --stdios running %s tbufsizeitenv(R t shellquoteRtdebugt quotecommandtpopen4( Rtsshcmdtargst remotecmdtpathtsshenvtcmdtstdintstdouttstderrtproc((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyt_makeconnections  'cC@sXdh}gtjjtjD]}|jj^q}|jddj||S(swReturn list of capabilities of this client. Returns a list of capabilities that are supported by this client. s partial-pullscomp=%st,(Rt compenginestsupportedwireenginest CLIENTROLEtwireprotosupporttnametaddtjoin(t protoparamstetcomps((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyt_clientcapabilitiess  .c@sfd}jdd}tjttj}dtjfg}tj j |}ydddddf}dd d t ||g} jd d rj d ||f| j dd||fn|r j dj dt |nj dj d|jdj| |jWntk rb|nXtj} tjdtj|} ddg} d} x| drq| rqy|j}t| j|}|r|jd} j d| Pn| ddkr"|dkr"Pn|r;j d|n| j|| d8} Wqtk rm|qXqW|t}| tjkrxt| D]=}|jdr|j |d j!ddj!PqqWn| tjkr|j}yt"|}Wnt#k r'|nX|j$|}|jd sP|nj d!||j |j!ddj!|j$dn|s|nt| |fS("Nc@sDttd}jdd}tj|d|dS(Ns#no suitable response from remote hgRt ssherrorhintthint(RRtconfigRt RepoError(tmsgRc(RSR(s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyt badresponses  tdevelsdebug.peer-requesttprotos%s-%st0i(shello sbetween s pairs %d t experimentalssshpeer.advertise-v2ssending upgrade request: %s %s isupgrade %s %s s"devel-peer-request: hello+between s&devel-peer-request: pairs: %d bytes ssending hello command ssending between command R2s^upgraded %s (.*)$tdummyiiisprotocol upgraded to %s s1 s sremote: s capabilities:t:scapabilities: s remote: %s (%t configboolRtsysbyteststrtuuidtuuid4RtSSHV2Rturlreqt urlencodetlenRHtinsertR*R]R;R?RtSSHV1R tcompileR treescapeR1RR tgrouptappendtsettreversedt startswithtupdatetsplittintR@R-(RRQRRRSRgt requestlogttokent upgradecapstpairsargt handshaket protonamet reupgradedtlinest max_noiseRtmtcapstlinetvaluelentcapsline((RSRs7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyt_performhandshakes<              $        t sshv1peercB@seZedZdhZdZdZdZdZdZ dZ dZ d Z d Z e Zed Zd Zd ZdZdZdZdZdZedZRS(c C@s||_||_||_|rQt|tj||}t|||}n||_||_||_||_ ||_ dS(sCreate a peer from an existing SSH connection. ``proc`` is a handle on the underlying SSH process. ``stdin``, ``stdout``, and ``stderr`` are handles on the stdio pipes for that process. ``caps`` is a set of capabilities supported by the remote. ``autoreadstderr`` denotes whether to automatically read from stderr and to forward its output. N( t_urlRt _subprocessRRR!t_pipeot_pipeit_pipeet_capst_autoreadstderr( RRturlRTRQRRRSRtautoreadstderr((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyRos       tbatchcC@s|jS(N(R(R((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyRscC@sdS(N(R3(R((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pytlocalscC@s|S(N((R((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pytpeerscC@stS(N(R#(R((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pytcanpushscC@sdS(N((R((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyR:scC@s|jS(N(R(R((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyt capabilitiesscC@st|j|jdS(N(RRR(R((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyt_readerrscC@s|j|dS(N(t_cleanup(Rt exception((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyt_aborts cC@s#t|j|j|j|jdS(N(RDRRRR(R((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyRscC@sS|jjr|jjddr|jj}d}|||xt|jD]\}}t|ts||d|t|fqTxAt|jD]-\}} ||d||t| fqWqTWn|jjd||j j d|t j |\} } | j } i} x=| D]5}|dkrO|| dsR;(R+titert _writeframedR#t _readframed(RRPRRLR/td((Rs7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyt _callpushs   c @s~|j||}|r4tjtd|nx-tfddD]}|j|qMW|jddt|jS(Nsunexpected remote reply: %sc@s jdS(Ni(R-((R(s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyRsR2R;(R+RtAbortRRRR#R(RRPRRLR/R((Rs7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyt_calltwowaystreamscC@s|jj}|dkrY|jr1|jntd}|jtjd|n|jro|jnyt|SWn0t k r|jtj td|nXdS(Ns scheck previous remote outputRcsunexpected response:( RR1RRRRRtOutOfBandErrorRR@t ResponseError(RRRf((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyRs       cC@s&|j}|sdS|jj|S(NR2(RRR-(RR.((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyR#s cC@sc|jjdt||r3|jj|n|rI|jjn|jr_|jndS(Ns%d (RR*RvR;RR(RR,R;((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyR*s (R<R=R#RRRRRRR:RRRRt__del__tFalseRRRR+RRRRR(((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyRns*            ,       t sshv2peercB@seZdZRS(s9A peer that speakers version 2 of the transport protocol.(R<R=R>(((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyR3sc C@syt||||\}}Wn'tk rHt||||nX|tjkrzt|||||||d|S|tjkrt|||||||d|St||||tj t d|dS(sMake a peer instance from existing pipes. ``path`` and ``proc`` are stored on the eventual peer instance and may not be used for anything meaningful. ``stdin``, ``stdout``, and ``stderr`` are the pipes connected to the SSH server's stdio handles. This function is factored out to allow creating peers that don't actually spawn a new process. It is useful for starting SSH protocol servers and clients via non-standard means, which can be useful for testing. Rs#unknown version of SSH protocol: %sN( Rt ExceptionRDRRxRRsRRReR( RRNRTRQRRRSRRR((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pytmakepeer9s cC@sktj|dtdt}|jdksC|j sC|jdkr_tjt d|ntj ||j dk rtjt dn|j dd}|j dd}t |jd}tj|} |jpd } tj||j|j|j} |r|r/tjt d nd || tjd t|t| ff} |jd | |j| ddd| } | dkrtjt dqnt||| || | \}}}}t||||||}d|jkrgy)|jdddjttWqgtk rc|j tjt dqgXn|S(siCreate an SSH peer. The returned object conforms to the ``wireprotov1peer.wirepeer`` interface. t parsequeryt parsefragmenttsshscouldn't parse location %sspassword in URL not supportedRRMROt.s8cannot create remote SSH repositories with extra optionss%s %s %ss %s init %ss running %s t blockedtagtsshpeertenvironiscould not create remote repot protocapsRt scapability exchange failedN(!RRRtschemethostRNR3RReRt checksafesshtpasswdRdRt configitemsR t shellenvirontsshargstusertportRGRRHtsystemRURRR+R]RRaR?R(RRNtcreatetintentst createoptstuRKRMt sshaddenvROt remotepathRLRPtresRTRQRRRSR((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pytinstanceXsB( !       ( t __future__RR Rqti18nRR2RRRRRRRtutilsR R RRtobjectRRDR3RURaRtwirepeerRRR#RR(((s7/usr/lib64/python2.7/site-packages/mercurial/sshpeer.pyts   4   ^