ó a˜Qc@s­ddlmZddlZddlZddlZddlZddlZddlZda d„Z de fd„ƒYZ de fd„ƒYZ de fd „ƒ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 RtstructtpackR tlenR(R tdata((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pyR$s (cCs+|dkrt|ƒ‚nt|j|ƒS(Ntisattytfileno(sisattysfileno(tAttributeErrortgetattrR (R tattr((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  tchanneledinputcBsYeZdZd Zd„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 (R R 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(t maxchunksizet_readR (R tsizetstbuf((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(R RR tlength((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(R RRR ((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(R tl((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pytnextus  cCs+|dkrt|ƒ‚nt|j|ƒS(NRR(sisattysfileno(RRR (R R((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pyR{s i( 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 |_ |dkr ttjtjdƒ|_ttjtjdƒ|_ttjtjd ƒ|_ttjtjd ƒ|_tj|_ntjtd ƒ|ƒ‚dS( Nt cmdserverRt-tdRtpipetetotItrsunknown mode %s(tostgetcwdtcwdtconfigtNoneRtsyststdoutRtopentbaseuituitrepotrepouitstderrtcerrtcoutRtstdintcintcresulttclienttutiltAbortR(R R>R?tmodetlogpath((s;/sys/lib/python2.7/site-packages/mercurial/commandserver.pyR …s      cCs/|s dS|jj|ƒ}|s+t‚n|S(NR"(RGR!tEOFError(R RR((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ütj|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(R R%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.pyt getencodingÊscCsd|jjƒd }|rZ|jj|ƒ}|r>||ƒqZtjtdƒ|ƒ‚n|dkS(Niÿÿÿÿsunknown command %sR"(RGR't capabilitiestgetRHRIR(R tcmdthandler((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(R thellomsg((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.pyts $ P