ó œçƒQc@sÐddlZddlZddlmZmZmZmZddlmZm Z ddl m Z ddl Z dZ dZdZdZd„Zd„Zd„Zd „Zd „Zd „Zd „Zd „ZdS(iÿÿÿÿN(terrorthttppeertutilt wireproto(t batchabletfuture(t_sa This repository uses the largefiles extension. Please enable it in your Mercurial config file. cCs|jƒtj||ƒ}tjtjj|ƒƒtj|d|j j ƒ}z²yk|j |ƒ|j j dƒ|tj|j ƒkr£tdtdƒƒ‚n|jƒtj||ƒWn@tk r}|jjtdƒ||jfƒtjdƒSXWd|jƒXtjdƒS(sLPut a largefile into a repository's local store and into the user cache.t createmodeis$largefile contents do not match hashs+largefiles: failed to put %s into store: %siN(tredirecttlfutilt storepathRtmakedirstostpathtdirnametatomictempfiletstoreRtgetfilet_fptseekthexsha1tIOErrorRtclosetlinktousercachetuitwarntstrerrorRtpushrestdiscard(trepotprototshaR ttmpfpte((s:/sys/lib/python2.7/site-packages/hgext/largefiles/proto.pytputlfiles$    cs~tj||ƒ}|s4tjtdƒ|ƒ‚nt|dƒ‰tjˆjƒƒd‰‡‡fd†}t j |ƒƒS(sIRetrieve a largefile from the repository-local cache or system cache.s+requested largefile %s not present in cachetrbic3s,dˆVxtjˆƒD] }|VqWdS(Ns%d (Rt filechunkiter(tchunk(tftlength(s:/sys/lib/python2.7/site-packages/hgext/largefiles/proto.pyt generator@s ( R tfindfileRtAbortRtopenR tfstattfilenoRt streamres(RRRtfilenameR(((R&R's:/sys/lib/python2.7/site-packages/hgext/largefiles/proto.pytgetlfile2scCs tj||ƒ}|sdSdS(sReturn '2 ' if the largefile is missing, '0 ' if it seems to be in good condition. The value 1 is reserved for mismatched checksum, but that is too expensive to be verified on every stat and must be caught be running 'hg verify' server side.s2 s0 (R R)(RRRR/((s:/sys/lib/python2.7/site-packages/hgext/largefiles/proto.pyt statlfileFscCs&d|jfd„ƒY}||_dS(NtlfileswirerepositorycBs)eZd„Zd„Zed„ƒZRS(c Ssnt|jtjƒrÚd}y„|jdd|d|didd6ƒ}|jddƒ\}}x3|jtƒD]"}|jj t d ƒ|dƒqnWt |ƒSWqjt t jfk rÖ|jj t d ƒ|ƒdSXnyS|jd|d|ƒ\}}|d kr"tjt d ƒ|ƒ‚nt |ƒSWn:tk rAdSt k ritjt d ƒ|ƒ‚nXdS(NR"tdataRtheaderssapplication/mercurial-0.1s content-types isremote: s unexpected putlfile response: %stsputlfile failed:s&putlfile failed (unexpected response):(t issubclasst __class__RtNonet_calltsplitt splitlinestTrueRRRtintt ValueErrorturllib2t HTTPErrort _callpushRt ResponseErrorR(tselfRtfdtrestdtoutputtltret((s:/sys/lib/python2.7/site-packages/hgext/largefiles/proto.pyR"Ts.     cssÜ|jdd|ƒ}|jƒ}yt|ƒ}Wn0tk rc|jtjtdƒ|ƒƒnXx"tj |d|ƒD] }|VqzWt |j t j ƒrØ|j dƒ}|rØ|jtjtdƒ|ƒƒqØndS( s<returns an iterable with the chunks of the file with sha shaR0Rsunexpected response:i€iiNi(t _callstreamtreadlineR=R>t_abortRRBRRR$R6R7Rtread(RCRtstreamR'R%((s:/sys/lib/python2.7/site-packages/hgext/largefiles/proto.pyR0ts   cssYtƒ}i|d6}||fVyt|jƒVWnttjfk rTdVnXdS(NRi(RR=tvalueR>R?R@(RCRR&tresult((s:/sys/lib/python2.7/site-packages/hgext/largefiles/proto.pyR1‰s   (t__name__t __module__R"R0RR1(((s:/sys/lib/python2.7/site-packages/hgext/largefiles/proto.pyR2Ss (R7(RRR2((s:/sys/lib/python2.7/site-packages/hgext/largefiles/proto.pyt wirereposetupRsDcCst||ƒdS(Ns largefiles=serve(tcapabilitiesorig(RR((s:/sys/lib/python2.7/site-packages/hgext/largefiles/proto.pyt capabilitiesšscCs,tj|ƒrtjtƒStj||ƒS(N(R t islfilesrepoRtooberrortLARGEFILES_REQUIRED_MSGtheads(RR((s:/sys/lib/python2.7/site-packages/hgext/largefiles/proto.pyRYs cKsl|dkr$|jdƒr$d}n|dkr\|jdƒr\|djddƒ|ds"  "    H