��Qc@s�ddlmZddlZddlZddlZddlZddlZddlZda d�Z
defd��YZdefd��YZ
defd ��YZdS(
i�(t_NcGs<ts
dSx!|D]}tjt|��qWtj�dS(N(tlogfiletwritetstrtflush(targsta((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pytlogs
tchanneledoutputcBs)eZdZd�Zd�Zd�ZRS(sg
Write data from in_ to out in the following format:
data length (unsigned int),
data
cCs||_||_||_dS(N(tin_touttchannel(tselfR R
R((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pyt__init__s cCsS|s
dS|jjtjd|jt|���|jj|�|jj�dS(Ns>cI(R
RtstructtpackRtlenR(Rtdata((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pyR$s
(cCs+|dkrt|��nt|j|�S(Ntisattytfileno(sisattysfileno(tAttributeErrortgetattrR (Rtattr((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pyt__getattr__+s(t__name__t
__module__t__doc__R
RR(((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pyRs tchanneledinputcBsYeZdZdZd�Zdd�Zd�Zdd�Zd�Zd �Z d
�Z
RS(s/
Read data from in_.
Requests for input are written to out in the following format:
channel identifier - 'I' for plain input, 'L' line based (1 byte)
how many bytes to send at most (unsigned int),
The client replies with:
data length (unsigned int), 0 meaning EOF
data
iicCs||_||_||_dS(N(R R
R(RR R
R((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pyR
?s i�cCsw|dkr`|j}|j||j�}|}x)|r[|j||j�}||7}q3W|S|j||j�SdS(Ni(tmaxchunksizet_readR(Rtsizetstbuf((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pytreadDs cCs�|s
dS|dkst�|jjtjd||��|jj�|jjd�}tjd|�d}|szdS|jj|�SdS(Ntis>cIis>I( tAssertionErrorR
RRRRR R!tunpack(RRRtlength((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pyRSs
cCs~|dkrj|j}|j|d�}|}x6|re|ddkre|j|d�}||7}q0W|S|j|d�SdS(NitLi�s
(RR(RRRR ((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pytreadlinecs cCs|S(N((R((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pyt__iter__rscCs|j�}|st�n|S(N(R't
StopIteration(Rtl((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pytnextus cCs+|dkrt|��nt|j|�S(NRR(sisattysfileno(RRR (RR((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pyR{si(RRRRR
R!RR'R(R+R(((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pyR0s tservercBsXeZdZd�Zd�Zd�Zd�Zd�Zied6ed6Zd�Z RS( sq
Listens for commands on stdin, runs them and writes the output on a channel
based stream to stdout.
cCs(tj�|_|jddd�}|rc|dkrQttjtjd�aqct |d�an|j
|_||_|j|_
|dkrttjtjd�|_ttjtjd�|_ttjtjd �|_ttjtjd
�|_tj|_ntjtd�|��dS(Nt cmdserverRt-tdRtpipetetotItrsunknown mode %s(tostgetcwdtcwdtconfigtNoneRtsyststdoutRtopentbaseuituitrepotrepouitstderrtcerrtcoutRtstdintcintcresulttclienttutiltAbortR(RR>R?tmodetlogpath((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pyR
�s cCs/|s
dS|jj|�}|s+t�n|S(NR"(RGR!tEOFError(RRR((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pyR�s cCs"tjd|jd��d}|s.g}n|j|�jd�}|jj�}||j_|jj�|j_|jj _
|jj�|jj�t
j|||j|j|j|j�}t
j
|�p�d}d|kr�j|j�n|jjtjdt|���dS(sk reads a list of terminated arguments, executes
and writes the return code to the result channel s>Iiits--cwds>iN(RR$RtsplitR>tcopyR?R=R@tdirstatet_uit
invalidatetinvalidatedirstatetdispatchtrequestRERCRBR5tchdirR7RFRRtint(RR%Rtcopieduitreqtret((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pyt
runcommand�s "
cCs|jjtj�dS(s3 writes the current encoding to the result channel N(RFRtencoding(R((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pytgetencoding�scCsd|jj�d }|rZ|jj|�}|r>||�qZtjtd�|��n|dkS(Ni�sunknown command %sR"(RGR'tcapabilitiestgetRHRIR(Rtcmdthandler((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pytserveone�s
R[R]cCswddjt|j��}|d7}|dtj7}|jj|�yx|j�r\qMWWntk
rrdSXdS(Nscapabilities: t s
s
encoding: ii(tjointsortedR^R\RCRRbRL(Rthellomsg((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pytserve�s
(
RRRR
RR[R]RbR^Rg(((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pyR,�s
(ti18nRRR:R5RTR\RHR9RRtobjectRRR,(((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pyt<module>s$ P
|