Plan 9 from Bell Labs’s /usr/web/sources/contrib/jas/root/sys/lib/python2.7/site-packages/hgext/largefiles/proto.pyc

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


��c@s�ddlZddlZddlmZmZmZmZddlmZm	Z	ddl
mZddl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
�|�dSXn�yS|jd|d|�\}}|dkr"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
|jt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.pyRY�s
cKsl|dkr$|jd�r$d}n|dkr\|jd�r\|djdd�|d<nt|||�S(NRYt
largefilestlheadstbatchtcmdssheads slheads (tcapabletreplacetssholdcallstream(RCtcmdtargs((s:/sys/lib/python2.7/site-packages/hgext/largefiles/proto.pytsshrepocallstream�s
	cKsl|dkr$|jd�r$d}n|dkr\|jd�r\|djdd�|d<nt|||�S(NRYRZR[R\R]sheads slheads (R^R_thttpoldcallstream(RCRaRb((s:/sys/lib/python2.7/site-packages/hgext/largefiles/proto.pythttprepocallstream�s
	(RR?t	mercurialRRRRtmercurial.wireprotoRRtmercurial.i18nRR	RXR8RTR`RdR"R0R1RSRURYRcRe(((s:/sys/lib/python2.7/site-packages/hgext/largefiles/proto.pyt<module>s""				H			

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.