ó ŸçƒQc@s"ddlZddlZddlZddlmZddlmZmZmZm Z m Z ddlm Z m Z ddl mZmZmZmZmZmZmZmZmZddlmZmZddlmZddlZd„Zd „Zd „Zd „Z d e!fd „ƒYZ"dS(iÿÿÿÿN(t_(tuithgtscmutiltutilt templater(terrortencoding( t ErrorResponset get_mtimet staticfilet paritygentismembert get_contacttHTTP_OKtHTTP_NOT_FOUNDtHTTP_SERVER_ERROR(thgwebtmakebreadcrumb(t wsgirequestcCs5g|D]*\}}tj|ƒjdƒ|f^qS(Nt/(Rtpconverttstrip(titemstnametpath((s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyt cleannamesscCs×g}xÊt|ƒD]¼\}}tjj|ƒ\}}yitd6td6|}Wn'tk r||j||fƒqnXtjjtjj |ƒƒ}t j |dtd|ƒ}|j t |||ƒƒqW|S(Nt*s**t followsymtrecurse(RtosRtsplittFalsetTruetKeyErrortappendtnormpathtabspathRt walkrepostextendturlrepos(tpathstrepostprefixtroottrootheadtroottailR((s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyt findreposs ccs_xX|D]P}tjj|ƒ}|dtj|t|ƒƒjdƒjdƒ|fVqWdS(sˆyield url paths and filesystem paths from a list of repo paths >>> conv = lambda seq: [(v, util.pconvert(p)) for v,p in seq] >>> conv(urlrepos('hg', '/opt', ['/opt/r', '/opt/r/r', '/opt'])) [('hg/r', '/opt/r'), ('hg/r/r', '/opt/r/r'), ('hg', '/opt')] >>> conv(urlrepos('', '/opt', ['/opt/r', '/opt/r/r', '/opt'])) [('r', '/opt/r'), ('r/r', '/opt/r/r'), ('', '/opt')] RN(RRR$RRtlentlstripR(R+R-R)R((s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyR((s cCsqtj|ƒ}|jpd}|jr3|j}n|jp?d}|jdƒs^d|}n|t|ƒ|fS(sê Extract CGI variables from baseurl >>> geturlcgivars("http://host.org/base", "80") ('host.org', '80', '/base') >>> geturlcgivars("http://host.org:8000/base", "80") ('host.org', '8000', '/base') >>> geturlcgivars('/base', 8000) ('', '8000', '/base') >>> geturlcgivars("base", '8000') ('', '8000', '/base') >>> geturlcgivars("http://host", '8000') ('host', '8000', '/') >>> geturlcgivars("http://host/", '8000') ('host', '8000', '/') tR(RturlthosttportRt startswithtstr(tbaseurlR5tuRR((s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyt geturlcgivars6s   thgwebdircBseeZdZd d„Zd„Zd„Zd„Zd„Zd„Z dd„Z d „Z d „Z RS( icCs2||_||_d|_d|_|jƒdS(Ni(tconftbaseuit lastrefreshtNonetmotdtrefresh(tselfR<R=((s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyt__init__Ts     c Csc|j|jtjƒkr dS|jr;|jjƒ}n2tjƒ}|jdddƒ|jdddƒt|jt t t fƒs>idd6}t j j|jƒsÉtjtdƒ|jƒ‚n|j|jd |d tƒg}x˜|jdƒD]<\}}x-|jd|ƒD]}|j||fƒqWqûWnHt|jt t fƒrb|j}n$t|jt ƒr†|jjƒ}nt|ƒ}x«|jd ƒD]š\}} tj|ƒ}x|tj| d tƒD]e}t j j|ƒ} tj| ƒ}|j|ƒr|t|ƒ}n|j|jd ƒ| fƒqÓWq¢W||_ ||_|jj!ddt"j"ƒt"_"|jj!dddƒ|_#|jj!dddƒ|_%|jj!dddƒ|_&|j&rßt'|j&ƒ|_&n|jj!ddƒ|_(|jj!dddƒ}|jd ƒr+|d}n|j)d ƒrG|d }n||_*tjƒ|_dS(NRtreport_untrustedtofftnonttyttrues hgweb-pathsR)sconfig file %s not found!tremapttrustt collectionsRRtwebRtstyletpapert templateststripesiR8R+R2iÿÿÿÿ(+R>trefreshintervalttimeR=tcopyRt setconfigt isinstanceR<tdicttlistttupleRRtexistsRtAbortRt readconfigR!t configitemst configlistR#RR/RRR&R$R6R0R1R*tconfigRRLR?t templatepatht stripecounttintt_baseurltendswithR+( RBR9tmapR)RtignoredRR*R+R,trepo((s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyRA[s\     $      cCsPtjjddƒjdƒs-tdƒ‚nddljj}|j|ƒdS(NtGATEWAY_INTERFACER2sCGI/1.sJThis function is only intended to be called while running as a CGI script.iÿÿÿÿ( RtenvirontgetR6t RuntimeErrortmercurial.hgweb.wsgicgiRtwsgicgitlaunch(RBRk((s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pytrunscCst||ƒ}|j|ƒS(N(Rtrun_wsgi(RBtenvtrespondtreq((s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyt__call__—scCs†|jjdƒ}|jdddtƒ}|rM| sIt|||ƒrMtS|jdddtƒ}| s~t|||ƒr‚tStS(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.t REMOTE_USERRKt deny_readt untrustedt allow_read(RoRhR\R!R R (RBRRqtuserRtRv((s@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyt read_allowed›s cCsz yÌ|jƒ|jjddƒjdƒ}|j|ƒ}|ddtjƒ}tj|ƒ}|jdƒsd|jkr?|jdƒr›|d}n|jdd }|j j d ddd t ƒ}|s+|j pâtj ƒ}t|tƒr|g}ng|D]}tjj|dƒ^q}nt|||ƒgS|se|jt|ƒ|j||ƒSt|jƒ} |} xÜ| rX| j| ƒ} | r,| |jd {streversetparity(tsortedR—R R_(t sortcolumnt descendingR“RctrowsRÉRÑ(RËRBt sortdefault(RÎs@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pytentriesvs  % RRªR§R¬tsortit-issort_%ss%s%stindexR×R“tpathdefRRÓRÔ( R?R RARR6t updatereqenvRoRR+RU( RBRqR‰R“R×tsortableRÓRÔtcolumnRØ((R£RËRqRBRÖs@/sys/lib/python2.7/site-packages/mercurial/hgweb/hgwebdir_mod.pyRös, s      C  c sʇfd†}‡fd†}‡‡fd†}dt‡fd†‰ˆj|jƒ|jjddƒ}|jdƒs†|d7}ni}|jjddgƒd ˆd dƒd f}tj|ˆj ƒ\}} ||d krò||d s$(@