��c@sWddlZddlmZmZmZmZmZmZmZm Z ddl
mZddlm
Z
ddlmZmZmZmZddlmZmZmZddlmZmZddlmZddlZddlZddlZddlZid d
6d d6d d6d d
6d d6dd6dd6Zdd�Zde fd��YZ!dS(i�N(tuithgthookterrortencodingt templatertutiltrepoview(twebsub(t_(tget_statt
ErrorResponset permhookstcaching(tHTTP_OKtHTTP_NOT_MODIFIEDtHTTP_BAD_REQUEST(tHTTP_NOT_FOUNDtHTTP_SERVER_ERROR(twsgirequesttpulltchangegrouptchangegroupsubsett getbundlet
stream_outtlistkeystpushtunbundletpushkeytcCs�|jd�r|d }n|r3d||}n|}|jd�rU|d}ng}|}dg|jd�}xSt|�D]E}|s�|r�Pn|ji|d6|d6�tjj|�}q�Wt|�S(s�Return a 'URL breadcrumb' list
A 'URL breadcrumb' is a list of URL-name pairs,
corresponding to each of the path items on a URL.
This can be used to create path navigation entries.
t/i�iRturltname(tendswitht
startswithtsplittreversedtappendtostpathtdirname(Rtprefixtrelpatht
breadcrumbturlelt pathitemstpathel((s=/sys/lib/python2.7/site-packages/mercurial/hgweb/hgweb_mod.pytmakebreadcrumbs
thgwebcBs�eZddd�Zded�Zeed�Zded�Zd�Z dd�Z
d�Zd�Zd�Z
d �Zd
�Zd�Zidd6dd6dd6Zd�ZRS(cCs,t|t�rH|r$|j�}ntj�}tj||�|_n ||_|j|j�|_|jjjddd�|jj jddd�|jjjddd�|jj jddd�t
jt�d|_
d|_||_d
|_d
|_|jdd�|_|j�|_dS(NRtreport_untrustedtofftnonttyttruei�tziptgztbz2itwebt templates(szipsgzsbz2(t
isinstancetstrtcopyRRt
repositorytrepot_getviewt setconfigtbaseuiRtredirecttTruetmtimetsizetreponametarchiveststripecounttconfigttemplatepatht
loadwebsubtwebsubtable(tselfR>R RAtu((s=/sys/lib/python2.7/site-packages/mercurial/hgweb/hgweb_mod.pyt__init__8s&
cCs|jjj|||d|�S(Nt untrusted(R>RRI(RMtsectionR tdefaultRP((s=/sys/lib/python2.7/site-packages/mercurial/hgweb/hgweb_mod.pyRITscCs|jjj|||d|�S(NRP(R>Rt
configbool(RMRQR RRRP((s=/sys/lib/python2.7/site-packages/mercurial/hgweb/hgweb_mod.pyRSXscCs|jjj|||d|�S(NRP(R>Rt
configlist(RMRQR RRRP((s=/sys/lib/python2.7/site-packages/mercurial/hgweb/hgweb_mod.pyRT\scCsX|jddd�}|dkr+|j�S|tjkrG|j|�S|jd�SdS(NR8tviewtservedtall(RIt
unfilteredRtfiltertabletfiltered(RMR>t
viewconfig((s=/sys/lib/python2.7/site-packages/mercurial/hgweb/hgweb_mod.pyR?`s
cCsKt|jj�}|j|jks6|j|jkr,|j|_|j|_tj|jj |jj
�}|j|�|_t|j
ddd��|_t|j
ddd��|_t|j
ddd��|_t|j
ddd��|_|jdd t�|_|j
dd
tj�t_n|rG|j|jj_ndS(NR8t
maxchangesi
tstripesitmaxshortchangesi<tmaxfilest allowpullR(R
R>tspathtst_mtimeRDtst_sizeRERR=RAtrootR?tintRIR\RHR^R_RSRCR`RtenvRtenviron(RMtrequesttsttr((s=/sys/lib/python2.7/site-packages/mercurial/hgweb/hgweb_mod.pytrefreshis $cCsPtjjdd�jd�s-td��nddljj}|j|�dS(NtGATEWAY_INTERFACERsCGI/1.sJThis function is only intended to be called while running as a CGI script.i�( R&RgtgetR"tRuntimeErrortmercurial.hgweb.wsgicgiR0twsgicgitlaunch(RMRp((s=/sys/lib/python2.7/site-packages/mercurial/hgweb/hgweb_mod.pytrun}scCst||�}|j|�S(N(Rtrun_wsgi(RMRftrespondtreq((s=/sys/lib/python2.7/site-packages/mercurial/hgweb/hgweb_mod.pyt__call__�scCss|j|�|jd|_|jjd�sA|jd7_nd|jkrm|j|jdd7_nd|jkr�jdjd�jd�}|jjdd�jd�}|t|� |kr�t|�}ndj|�}n3|jdjdd�d }|jd
d�d }|j jddg�d }t
j|�r-yR|rjtt
��n|tkr�|j|t|�nt
j|j||�SWq-tk
r)}|dkr�jjd
d�j�dks�jjdd�r|j�n|j|t
jdd|j�dSXn|jdd�}d|j kr|r|d r|jd �}|jd�}|dkr�|| g|j d<||d}ntjt|�r�|g|j d<nd}|dkrdj|�g|j d<nH|r2|d r2|jd �} | g|j d<n|rH||j d<n|jjdd�}
|dkr�d|
kr�dg|j d<n|dkr|j dd }xg|jj�D]S\}}
|
d}|j|�r�|t|� g|j d<|g|j d<q�q�WqnyT|j|�}|dd tj�}tj |�}|dkrg|j|d�n|dkr�|j"d!g|j d<|j dd }n|j#d"d#t$�r�t%||�n|tj&kr�$|}tt'|��ns|dkr6d|j jdg�kr6||_(tj)|||�}n+t*t|�|||�}|jt+|�|SWnt,j-t,j.fk
r�}|jt
|�t/|�}tj|d%�r�t0|t,j1�r�d&|j2}n|d'd'|�St,j3t,j4fk
r&}|jt5|�|d'd't/|��Stk
rn}|j||�|j6t7kr[dgS|d'd'|j�SXdS((NtSCRIPT_NAMERt REPO_NAMEt PATH_INFORtQUERY_STRINGt&iit;tcmdRtHTTP_EXPECTs100-continues X-HgHttp2tbodys0
%s
it-i�tstyletstatictfiletnodetHTTP_USER_AGENTtrevt mercurialtrawtarchivettypetmimetypeRRRR8tcachesno such method: %sR srevision not found: %sR(8RkRfRR!tstripR#RmtlentjointformtprotocoltiscmdRRtpermst
check_permtcallR>tlowertdrainRttHGTYPEtmessagetpoptrfindRtsafehasattrtwebcommandst
archive_specst iteritemsRRt stringifytNoneR�RSRCR
t__all__RtctypetrawfiletgetattrRRtLookupErrortRepoLookupErrorR;R:tManifestLookupErrorR t RepoErrortRevlogErrorRtcodeR(RMRutpartst
repo_partstqueryR}tinsttargsR�R�tuatfnttype_tspectextttmplR�tmsgtcontentterr((s=/sys/lib/python2.7/site-packages/mercurial/hgweb/hgweb_mod.pyRs�s�
' cCs�g}|jjjd�}||jjjd�7}xm|D]e\}}|d}tj|�}tjd|||f|�}|s�|jjjtd�||f�q;ntjd|�}|j ||j
d��} |j ||j
d��}
|j
d�}d }|r=x(|j�D]}
|tj|
O}qWny)tj| |�} |j
| |
f�Wq;tjk
r�|jjjtd
�|| f�q;Xq;W|S(NRtinterhgis1^s%s(.+)(?:(?<=\\\\)|(?<!\\))%s(.*)%s([ilmsux])*$s#websub: invalid pattern for %s: %s
s(?<!\\)\\%siiis"websub: invalid regexp for %s: %s
(R>RtconfigitemstretescapetmatchtwarnR tcompiletsubtgrouptuppert__dict__R%R(RMRLt
websubdefstkeytpatterntunesctdelimR�tdelim_retregexptformattflagintflagstflag((s=/sys/lib/python2.7/site-packages/mercurial/hgweb/hgweb_mod.pyRKs8
cs�|jjd�}|dkr-d}d}nd}d}|jd}||kr\d|p_d}d ||jd
|f}�jddd
�}�jddd�}�jdd�p�|jd}|jd�s�d7}n�fd�} �fd�}
�fd�}i}|jjddg�d�jdd�df}
tj|
�j �\}}||
dkr}||d<n|jddkr�dp�d}t
j||�}�js�jdd�p�jjd�p�jj
d�p�jj�_n�fd�}tj|di|d 6d!i|jd"6|d6|d6|d6|d#6�jd$6| d%6|
d&6|d'6|d(6t|j�d)6���S(*Nswsgi.url_schemethttpst443thttpt80tSERVER_PORTt:Rs %s://%s%stSERVER_NAMER8tlogourlshttp://mercurial.selenic.com/tlogoimgs
hglogo.pngt staticurlsstatic/Rc;s�ddtj|�VdS(NtheaderR(R(tmap(R�(s=/sys/lib/python2.7/site-packages/mercurial/hgweb/hgweb_mod.pyR�Lsc;s�d|�VdS(Ntfooter((R�(R�(s=/sys/lib/python2.7/site-packages/mercurial/hgweb/hgweb_mod.pyR�Osc;s�jddd�VdS(NR8tmotdR(RI(R�(RM(s=/sys/lib/python2.7/site-packages/mercurial/hgweb/hgweb_mod.pyR�RsR�itpaperi�t?R{R Rxcst|�j�S(N(RRL(ttext(RM(s=/sys/lib/python2.7/site-packages/mercurial/hgweb/hgweb_mod.pytwebsubfilteristfiltersRtdefaultsRturlbaseR>R�R�R�tsessionvarstpathdef(RfRmRIRR!R�R�RtstylemapRJtwebutilR�RFR�R>RdR/(RMRutprototdefault_porttportR�R�R�R�R�R�R�tvarststylesR�tmapfiletstartR�R�((RMR�s=/sys/lib/python2.7/site-packages/mercurial/hgweb/hgweb_mod.pyR4sZ
$
ccsy|jdd�}x`|jj�D]O\}}||ksP|jdd|�r"i|d6|dd6|d6Vq"q"WdS(NR8t
allow_archivetallowR�it extensionR�(RTR�R�RS(RMtnodeidtallowedtiR�((s=/sys/lib/python2.7/site-packages/mercurial/hgweb/hgweb_mod.pytarchivelist~s"sapplication/x-bzip2ttbz2s.tar.bz2R7sapplication/x-gzipttgzs.tar.gzR6sapplication/zipR5s.zipcCs%xtD]}||||�qWdS(N(R(RMRutopR((s=/sys/lib/python2.7/site-packages/mercurial/hgweb/hgweb_mod.pyR��s
N(sapplication/x-bzip2R�s.tar.bz2N(sapplication/x-gzipR�s.tar.gzN(sapplication/zipszips.zipN(t__name__t
__module__R�RORCRItFalseRSRTR?RkRrRvRsRKRR�R�R�(((s=/sys/lib/python2.7/site-packages/mercurial/hgweb/hgweb_mod.pyR07s" �) J
("R&R�RRRRRRRRtmercurial.templatefiltersRtmercurial.i18nR tcommonR
RRR
RRRRRRhRR�R�R�R�R�R/tobjectR0(((s=/sys/lib/python2.7/site-packages/mercurial/hgweb/hgweb_mod.pyt<module> s$:"0
|