ó ŸçƒQc@síddlZddlZddlZdZdZdZdZdZdZdZ d Z d „Z d „Z e gZ d efd „ƒYZdefd„ƒYZd„Zdd„Zd„Zd„Zd„Zdd„Zd„Zd„ZdS(iÿÿÿÿNiÈi0ii‘i“i”i•iôcCs|dgkp||kS(sÑCheck if username is a member of userlist. If userlist has a single '*' member, all users are considered members. Can be overriden by extensions to provide more complex authorization schemes. t*((tuitusernametuserlist((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pytismembersc Csá|jjdƒ}|jddƒ}|r[| sIt|jj||ƒr[ttdƒ‚n|jddƒ}|ržt|jj||ƒ ržttdƒ‚n|dkrÆ|j rÆttdƒ‚n|dksÞ|dkrâdS|jd d kr d }tt |ƒ‚n|jjd ƒ}|j dd t ƒrR|dkrRtt dƒ‚n|jddƒ}|r›| s‰t|jj||ƒr›ttdƒ‚n|jddƒ} | oÈt|jj|| ƒsÝttdƒ‚ndS(sšCheck permission for operation based on request data (including authentication info). Return if op allowed, else raise an ErrorResponse exception.t REMOTE_USERtwebt deny_readsread not authorizedt allow_readtpullspull not authorizedNtREQUEST_METHODtPOSTspush requires POST requestswsgi.url_schemetpush_sslthttpss ssl requiredt deny_pushspush not authorizedt allow_push(tenvtgett configlistRtrepoRt ErrorResponsetHTTP_UNAUTHORIZEDt allowpulltNonetHTTP_METHOD_NOT_ALLOWEDt configbooltTruetHTTP_FORBIDDEN( thgwebtreqtoptuserRRtmsgtschemetdenytallow((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyt checkauthzs.%!%RcBs eZdgd„Zd„ZRS(cCsG|dkrt|ƒ}ntj|ƒ||_||_||_dS(N(Rt_statusmessaget Exceptiont__init__tcodetmessagetheaders(tselfR(R)R*((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyR'Ps     cCs|jS(N(R)(R+((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyt__str__WsN(t__name__t __module__RR'R,(((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyROstcontinuereadercBs&eZd„Zdd„Zd„ZRS(cCs||_||_t|_dS(N(tft_writetFalset continued(R+R0twrite((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyR'[s  iÿÿÿÿcCs2|js"t|_|jdƒn|jj|ƒS(NsHTTP/1.1 100 Continue (R3RR1R0tread(R+tamt((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyR5`s  cCs&|dkrt|j|ƒSt‚dS(Ntclosetreadlinet readlinest__iter__(sclosesreadlines readliness__iter__(tgetattrR0tAttributeError(R+tattr((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyt __getattr__fs (R-R.R'R5R>(((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyR/Zs  cCs-ddlm}|j}|j|dƒdS(Niÿÿÿÿ(tBaseHTTPRequestHandlertErrors Unknown errori(sErrors Unknown error(tBaseHTTPServerR?t responsesR(R(R?RB((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyR%ks cCsd||pt|ƒfS(Ns%d %s(R%(R(R)((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyt statusmessagepscCsEtjj|dƒ}tjj|ƒr4tj|ƒStj|ƒSdS(s,stat changelog if it exists, spath otherwises 00changelog.iN(tostpathtjointexistststat(tspathtcl_path((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pytget_statss cCs t|ƒjS(N(RKtst_mtime(RI((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyt get_mtime{sc Cs¦|jdƒ}xZ|D]R}|dtjtjfksdtj|ksdtjdk rtj|krdSqWtjj|Œ}t |t ƒr™|g}nx9|D]1}tjj||ƒ}tjj |ƒr Pq q Wyetj |ƒt j|ƒdpûd}t|dƒ} | jƒ} | jƒ|jt|d| ƒWnetk r\ttdƒ‚nFtk r¡} | jtjkrŒttƒ‚q¢tt| jƒ‚nXdS( s+return a file inside directory with guessed Content-Type header fname always uses '/' as directory separator and isn't allowed to contain unusual path components. Content-Type is guessed using the mimetypes module. Return an empty string if fname is illegal or file not found. t/tNis text/plaintrbtbodysillegal filename(tsplitRDtcurdirtpardirtseptaltsepRRERFt isinstancetstrRGRHt mimetypest guess_typetopenR5R7trespondtHTTP_OKt TypeErrorRtHTTP_SERVER_ERRORtOSErrorterrnotENOENTtHTTP_NOT_FOUNDtstrerror( t directorytfnameRtpartstparttfpathtdREtcttfptdataterr((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyt staticfile~s2  -      iccs€|r/|r/|||}|||d@}n d}d}x>tr{|V|d7}|r>||kr>d|}d}q>q>WdS(s5count parity of horizontal stripes for easier readingiiN(R(t stripecounttoffsettcounttparity((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyt paritygen¢s    cCs4|ddƒp3|ddƒp3tjjdƒp3dS(s¾Return repo contact information or empty string. web.contact is the primary source, but if that is not set, try ui.username or $EMAIL as a fallback to display something useful. RtcontactRRtEMAILRO(RDtenvironR(tconfig((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyt get_contact²scCsPt|jƒ}|jjdƒ|kr6ttƒ‚n|jjd|fƒdS(NtHTTP_IF_NONE_MATCHtETag(RXtmtimeRRRtHTTP_NOT_MODIFIEDR*tappend(RRttag((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pytcaching¼s(RaRYRDR]R}tHTTP_BAD_REQUESTRRRcRR_RR$t permhooksR&RtobjectR/R%RRCRKRMRoRtRyR€(((s:/sys/lib/python2.7/site-packages/mercurial/hgweb/common.pyt s*$ .       $