�
�c@s�ddklZddklZlZddkZddkZddkZddkZddk Z ddk
Z
ddkZdefd��YZ
dS(i�(t_(tbinthexNt sshservercBs�eZd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z
d �Zd
�Zd�Z
d�Zd
�Zd�Zd�Zd�Zd�Zd�ZRS(cCsp||_||_d|_ti|_ti|_t i
t�tit_t
i|i�t
i|i�dS(N(tuitrepotNonetlocktsyststdintfintstdouttfoutthooktredirecttTruetstderrtutilt
set_binary(tselfRR((s&/sys/lib/python/mercurial/sshserver.pyt__init__s
cCsG|ii�d }|i�\}}|iit|��}||fS(Ni�(R
treadlinetsplittreadtint(Rtarglinetargtltval((s&/sys/lib/python/mercurial/sshserver.pytgetargscCs;|iidt|��|ii|�|ii�dS(Ns%d
(Rtwritetlentflush(Rtv((s&/sys/lib/python/mercurial/sshserver.pytrespond#scCsOzx|i�oqWWd|idj o|ii�nXtid�dS(Ni(t serve_oneRRtreleaseRtexit(R((s&/sys/lib/python/mercurial/sshserver.pyt
serve_forever(s
cCs]|ii�d }|o9t|d|d�}|o|�qS|id�n|djS(Ni�tdo_t(R
RtgetattrRR"(Rtcmdtimpl((s&/sys/lib/python/mercurial/sshserver.pyR#0scCs�|i�\}}|djpt�y"t|ii|��}d}Wn'tj
o}t|�}d}nX|id||f�dS(Ntkeyiis%s %s
(RtAssertionErrorRRtlookupt ExceptiontstrR"(RRR,trtsuccesstinst((s&/sys/lib/python/mercurial/sshserver.pyt do_lookup8s
c Cs�|ii�}g}xp|i�D]b\}}ti|�}g}|D]}|t|�qH~}|id|di|�f�q"W|idi|��dS(Ns%s %st s
( Rt branchmapt iteritemsturllibtquoteRtappendtjoinR"( RR6theadstbranchtnodest
branchnamet_[1]tnodetbranchnodes((s&/sys/lib/python/mercurial/sshserver.pytdo_branchmapCs
'$cCs6|ii�}|iditt|��d�dS(NR5s
(RR<R"R;tmapR(Rth((s&/sys/lib/python/mercurial/sshserver.pytdo_headsLscCsgddddg}|iidd�o|id|iii�n|idd i|�f�d
S(s)the hello command returns a set of lines describing various
interesting things about the server, in an RFC822-like format.
Currently the only one defined is "capabilities", which
consists of a line in the form:
capabilities: space separated list of tokens
tunbundleR.tchangegroupsubsetR6tservertuncompresseds stream=%dscapabilities: %s
R5N(Rt
configboolR:Rt changelogtversionR"R;(Rtcaps((s&/sys/lib/python/mercurial/sshserver.pytdo_helloPs cCs#|ii�|_|id�dS(s<DEPRECATED - allowing remote client to lock repo is not safeR(N(RRR"(R((s&/sys/lib/python/mercurial/sshserver.pytdo_lock^scCs5|io|ii�nd|_|id�dS(t
DEPRECATEDR(N(RR$RR"(R((s&/sys/lib/python/mercurial/sshserver.pyt do_unlockds
cCs�|i�\}}tt|id��}g}x=|ii|�D])}|iditt|��d�qCW|i di|��dS(NR5s
R((
RRDRRRtbranchesR:R;RR"(RRR>R1tb((s&/sys/lib/python/mercurial/sshserver.pytdo_branchesls'cCs�|i�\}}g}|id�D]}|tt|id��q&~}g}x=|ii|�D])}|iditt|��d�qgW|i di|��dS(NR5t-s
R((
RRRDRRtbetweenR:R;RR"(RRtpairsR@tpR1RT((s&/sys/lib/python/mercurial/sshserver.pyt
do_betweents<'cCs�g}|i�\}}tt|id��}|ii|d�}x7to/|id�}|pPn|ii |�qHW|ii
�dS(NR5tservei(RRDRRRtchangegroupRRRRR (RR>Rtrootstcgtd((s&/sys/lib/python/mercurial/sshserver.pytdo_changegroup|s
c Cs�t|i�|i�g�}g}|did�D]}|t|�q6~}g}|did�D]}|t|�qj~}|ii||d�}x7to/|id�}|pPn|ii |�q�W|ii
�dS(NtbasesR5R<R[i(tdictRRRRRHRRRRR ( RtargmapR@tnRat_[2]R<R^R_((s&/sys/lib/python/mercurial/sshserver.pytdo_changegroupsubset�s44
cCsd|ip|id�dSn|id�|ii|id|i��}|it|��dS(RQs
not lockedNR(R[(RR"RtaddchangegroupR
t
client_urlR0(RR1((s&/sys/lib/python/mercurial/sshserver.pytdo_addchangegroup�s
!cCs-tiidd�idd�d}d|S(Nt
SSH_CLIENTR(R5iisremote:ssh:(tostenvirontgetR(Rtclient((s&/sys/lib/python/mercurial/sshserver.pyRh�s%cs��i�di����fd�}|�p�itd��dSn�id�d}}zEtidd�\}}ti|d�}t �i
i��}x:|o2|i�i
i
|��t �i
i��}q�W�idj }|p�ii��_nzt|�p�itd��dSn�id�|id��ii|d �i��}�it|��Wd|p�ii�d�_nXWd|dj o|i�n|dj oti|�nXdS(
Nics8tt�ii��}�td�gjp
�|jS(Ntforce(RDRRR<(R<(Rttheir_heads(s&/sys/lib/python/mercurial/sshserver.pytcheck_heads�ssunsynced changesR(tprefixshg-unbundle-swb+iR[(RRR"RRttempfiletmkstempRktfdopenRR
RRRRRtseekRgRhR0R$tclosetunlink(RRqttempnametfptfdtcountt
was_lockedR1((RRps&/sys/lib/python/mercurial/sshserver.pytdo_unbundle�s@
cCs�y>x*ti|i�D]}|ii|�qW|ii�Wn;tij
o,}|iit|��|ii�nXdS(N(tstreamclonet
stream_outRRRR tStreamExceptionR0(RtchunkR3((s&/sys/lib/python/mercurial/sshserver.pyt
do_stream_out�s(t__name__t
__module__RRR"R&R#R4RCRFRORPRRRURZR`RfRiRhR~R�(((s&/sys/lib/python/mercurial/sshserver.pyRs& 3(ti18nRRARRRRR
RkRRsR8tobjectR(((s&/sys/lib/python/mercurial/sshserver.pys<module> s$0
|