�
�c
@s�ddkZddkZddkZddklZddklZlZlZl Z ddkl
Z
lZddkl
Z
lZlZlZlZlZlZlZddklZddklZddkZd�Zd �Zd
efd��YZdS(i�N(t_(tuithgtutilt templater(terrortencoding(t
ErrorResponset get_mtimet
staticfilet paritygentget_contacttHTTP_OKtHTTP_NOT_FOUNDtHTTP_SERVER_ERROR(thgweb(twsgirequestcCs=g}|D]+\}}|ti|�id�|fq~S(Nt/(Rtpconverttstrip(titemst_[1]tnametpath((s//sys/lib/python/mercurial/hgweb/hgwebdir_mod.pyt
cleannamessc
Csh}xt|�D]�}}tii|�\}}y htd<td<|}Wn tj
o|||<qnXtii|�}xzti |dtd|�D]]}tii|�}ti
|t|��id�}|o|d|}n|||<q�WqW|i
�S(Nt*s**t followsymtrecurseR(RtosRtsplittFalsetTruetKeyErrortnormpathRt walkreposRtlenRR( tpathstrepostprefixtroottrootheadtroottailRRR((s//sys/lib/python/mercurial/hgweb/hgwebdir_mod.pyt findreposs$
"thgwebdircBs\eZdZd
d�Zd�Zd�Zd�Zd�Zd�Z dd�Z
d �ZRS(icCs)||_||_d|_|i�dS(Ni(tconftbaseuitlastrefreshtrefresh(tselfR,R-((s//sys/lib/python/mercurial/hgweb/hgwebdir_mod.pyt__init__/s cCs�|i|iti�jodSn|io|ii�|_n<ti�|_|iiddd�|iiddd�t|it t
tf�pDhdd<}|ii|id|dt
�|iid�}nMt|it
tf�o
|i}n't|it �o|ii�}n|iid d
ti�t_|iid d�|_|iid dd
�|_|iid dd�|_|iot|i�|_n|iid d�|_t|�|_x�|iid�D]�\}}ti|�}x�ti|dt
�D]j}tii|�}ti|�}|i|�o|t |�}n|ii!|i"d�|f�q#Wq�ii#�ti�|_dS(NRtreport_untrustedtofftinteractiveshgweb-pathsR$tremapttrusttwebRtmotdtstyletpapertstripesitbaseurltcollectionsRR($R.trefreshintervalttimeR-tcopyRt setconfigt
isinstanceR,tdicttlistttuplet
readconfigRtconfigitemsRtconfigRR8R9tstripecounttintt_baseurlR*R%RRR"RRR!t
startswithR#tappendtlstriptsort(R0tmapR$R&R'RtrepoR((s//sys/lib/python/mercurial/hgweb/hgwebdir_mod.pyR/5sH
'
cCsRtiidd�id�ptd��nddkii}|i|�dS(NtGATEWAY_INTERFACEtsCGI/1.sJThis function is only intended to be called while running as a CGI script.i�( RtenvirontgetRLtRuntimeErrortmercurial.hgweb.wsgicgiRtwsgicgitlaunch(R0RX((s//sys/lib/python/mercurial/hgweb/hgwebdir_mod.pytrun_scCst||�}|i|�S(N(Rtrun_wsgi(R0tenvtrespondtreq((s//sys/lib/python/mercurial/hgweb/hgwebdir_mod.pyt__call__fscCs�|iid�}|idddt�}|o-|p|dgjp
||jotSn|idddt�}|p|dgjp
||jotSntS(sCheck allow_read and deny_read config options of a repo's ui object
to determine user permissions. By default, with neither option set (or
both empty), allow all users to read the repo. There are two ways a
user can be denied read access: (1) deny_read is not empty, and the
user is unauthenticated or deny_read contains user (or *), and (2)
allow_read is not empty and the user is not in allow_read. Return True
if user is allowed to read the repo, else return False.tREMOTE_USERR7t deny_readt untrustedRt
allow_read(R\RUt
configlistRR(R0RR^tuserRaRc((s//sys/lib/python/mercurial/hgweb/hgwebdir_mod.pytread_allowedjs ,%cCs�z�y~|i�|iidd�id�}|i|�}|ddti�}ti|�}|id�pd|ijoU|id�o|d}n|idd }ti d�}t
|||�fSn,|p$|it|�|i
||�Snt|i�}xM|oE|i|�}|o�||id
<y,ti|i|�} t| �i|�SWq�tj
o!}
|
i}tt|��q�tij
o}
ttt|
���q�Xn|d}g}
|D]!}|i|�o|
|q�q�~
o'|it|�|i
|||�Sn|id�}|d joPn|| }qW|it|�|dd|�SWn?tj
o3}|i||�|d
d
|ipd�SnXWdd}XdS(Nt PATH_INFORSRtmimetypeRsstatic/tstaticiit REPO_NAMEtnotfoundRQR( R/R\RURRRt stringifyRLtformttemplatepathR R]Rt makeindexRCR%Rt
repositoryRRR[tIOErrortstrerrorRRRt RepoErrortstrtrfindR
tmessagetNone(R0R^tvirtualttmpltctypetfnameRiR%trealRQtinsttmsgtsubdirRtrtupterr((s//sys/lib/python/mercurial/hgweb/hgwebdir_mod.pyR[�sV
6
#RScshd��dtf�dtd����fd�}�i�ddddg}�\}}d�ijoP�idd }|id
�}|o|d}n||jo
d}q�ng}|D]=} |d| d
|o| |jod
pd| ffq�~}
�i��idj o�i�id<n|dd|d|d|d|t|
��S(Ncss�|idddt�}x~dddgD]m}|d
|jp!|idd|d
dt�o5h|d
d<|d
d<|d<|d<Vq(q(WdS(NR7t
allow_archiveRbtzips.ziptgzs.tar.gztbz2s.tar.bz2itallowttypeit extensiontnodeturl(szips.zip(sgzs.tar.gz(sbz2s.tar.bz2(RdRt
configbool(RtnodeidR�tallowedti((s//sys/lib/python/mercurial/hgweb/hgwebdir_mod.pytarchivelist�s(
RRSc!;sSg}t�i�}x�iD]�\}}|i|�pqn|t|�}�ii��y#�iti i
|dd��Wn5tj
o)}�it
d�||f�qnXd�fd�} �idddt�oqn�i���pqn|g}
d�ijo$|
id �idid
��n�ido|
id �id�ntidd
i
|
��}|id
�tidd
|id��d
}y t|�ti�d
f}
Wntj
o
qnXt| �}| ddd�}| dd|�}td|pdd|i�pdd|d|d|d|pdd|i�pdd|
d|
d
|
d d��d|��
}|p||f�jo|i �|d<|Vq|i!|d||f�qW|oO|i"�|o|i#�nx-|D]!\}}|i �|d<|Vq&WndS(Ns.hgthgrcserror reading %s/.hg/hgrc: %s
cs�i|||dt�S(NRb(RHR(tsectionRtdefault(tu(s//sys/lib/python/mercurial/hgweb/hgwebdir_mod.pyRU�sR7thiddenRbRgiRtSCRIPT_NAMEs((?:https?://)?)(.*)is/+itdescriptionRSRtcontacttunknowntcontact_sortt name_sortR�tdescription_sortt
lastchangetlastchange_sorttarchivesttiptparitys%s_sort($R
RIR%RLR#RR@RFRRtjoint ExceptiontwarnRRwR�RRfR\tinserttrstriptretmatchtgrouptsubRRtmakedatetOSErrorRRCtuppertnextRMROtreverse(t
sortcolumnt
descendingRRPtrowsR�RRteRUtpartstmR�tdR�R�trowtkey(R�R0R^tsortdefault(R�s//sys/lib/python/mercurial/hgweb/hgwebdir_mod.pytentries�sl
# $/
R�R�R�ROit-issort_%ss%s%sR�tindexR�RR�R�(RR/RmRLRKRwR\RC(R0R^RyRR�tsortableR�R�RtcolumnRO((R�R0R^R�s//sys/lib/python/mercurial/hgweb/hgwebdir_mod.pyRo�s* !A
J
cs��fd�}�fd�}��fd�}dt�fd���idj o�i|id<n|iidd�}|id�p|d7}nh}�i}d|ijo|idd |d<}n|d
djodpd}ti ||�} �d
d�p|d}
|
id�p|
d7}
nd|ijo|idd p�i}t
i|�}t
i
|dh|d<|d<|d<|d<|
d<| d<���S(Nc;s�ddti|�VdS(NtheaderR(R(RP(Ry(s//sys/lib/python/mercurial/hgweb/hgwebdir_mod.pyR�#sc;s�d|�VdS(Ntfooter((RP(Ry(s//sys/lib/python/mercurial/hgweb/hgwebdir_mod.pyR�≻s1�idj o�iVn�ddd�VdS(NR7R8RS(R8Rw(RP(R0RH(s//sys/lib/python/mercurial/hgweb/hgwebdir_mod.pyR8)scs�ii||||�S(N(RRH(R�RR�Rb(R0(s//sys/lib/python/mercurial/hgweb/hgwebdir_mod.pyRH/sR�RSRR9ii�t?t&R7t staticurlsstatic/tdefaultsR�R�R8R�tsessionvars(RwRRKR\RUtendswithR9RmtwebutilR�Rtstylemap(R0R^R�R�R8R�tvarsR9tstartR�R�tmapfile((R0RyRHs//sys/lib/python/mercurial/hgweb/hgwebdir_mod.pyR!s8 +
N(t__name__t
__module__R>RwR1R/RZR_RfR[RoR(((s//sys/lib/python/mercurial/hgweb/hgwebdir_mod.pyR+,s * =d(RR�R?tmercurial.i18nRt mercurialRRRRRRtcommonRRR R
RRR
Rt hgweb_modRtrequestRR�RR*tobjectR+(((s//sys/lib/python/mercurial/hgweb/hgwebdir_mod.pys<module> s$":
|