o ]Lb@sddlmZddlZddlmZddlmZddlmZm Z m Z m Z m Z m Z mZmZmZmZmZmZddlmZejZejZGdd d eZGd d d eZGd d d ejZddZ Gddde j!Z"Gddde j#e j$Z%dddZ&dS))absolute_importN)_)sha1nodeconstants) branchmap changelogerror localrepomanifest namespacespathutilpycompat requirementsurlutilvfs)urlutilc@sNeZdZddZddZddZddZdd d Zd d ZddZ ddZ d S)httprangereadercCs||_d|_||_||_dS)Nr)rposopenername)selfrrr:/usr/lib/python3/dist-packages/mercurial/statichttprepo.py__init__'s zhttprangereader.__init__cCs|SNrrrrr __enter__.zhttprangereader.__enter__cCs |dSr)close)rexc_type exc_value tracebackrrr__exit__1 zhttprangereader.__exit__cCs ||_dSr)r)rrrrrseek4s zhttprangereader.seekNc Cs tt|j}d}|r|j|d}|js|r$|dd|j|fz|j|}| }|j }Wn0t j yQ}z|j dkrDt jpEd}t|t|d}~wt jyc}ztd|jd}~ww|dkr}|ru||j|j|}n||jd}n|r|d|}|jt|7_|S)NrRangez bytes=%d-%si)urlreqrequestr strurlrr add_headerropenreadcodeurlerr httperrorerrnoENOENTIOErrorstrurlerrorreasonlen) rbytesreqendfdatar/instnumrrrr.7s4     zhttprangereader.readcCs|dS)NT)r. splitlinesrrrr readlinesXszhttprangereader.readlinescCs t|Sr)iterrArrrr__iter__[r$zhttprangereader.__iter__cCdSrrrrrrr^rzhttprangereader.closer) __name__ __module__ __qualname__rrr#r%r.rArCrrrrrr&s ! rc@seZdZdZdS) _RangeErrorz6Error raised when an unsatisfiable range is requested.N)rErFrG__doc__rrrrrHesrHc@s eZdZdZddZddZdS)_HTTPRangeHandleraHandler that enables HTTP Range headers. This was extremely simple. The Range header is a HTTP feature to begin with so all this class does is tell urllib2 that the "206 Partial Content" response from the HTTP server is what we expected. cCs"t|||}||_||_|Sr)r) addinfourl get_full_urlr/msg)rr:fpr/rMhdrsrrrrhttp_error_206rsz _HTTPRangeHandler.http_error_206cCstd)NsRequested Range Not Satisfiable)rH)rr:rNr/rMrOrrrhttp_error_416ysz _HTTPRangeHandler.http_error_416N)rErFrGrIrQrRrrrrrJis rJcs2t||tGfdddtj}|S)Ncs*eZdZddZd fdd ZddZdS) z#build_opener..statichttpvfscSs||_i|_dSr)baseoptions)rrSrrrrs z,build_opener..statichttpvfs.__init__rcs0|dvrtdd|jt|f}t|S)N)rUsrbsPermission denied/)r4joinrSr)quoter)rpathmodeargskwr< urlopenerrr__call__s z,build_opener..statichttpvfs.__call__cSs|r t|j|S|jSr)r rWrS)rrYrrrrWsz(build_opener..statichttpvfs.joinN)rU)rErFrGrr_rWrr]rr statichttpvfss r`)rr add_handlerrJvfsmod abstractvfs)uiauthinfor`rr]r build_opener~s  rfc@seZdZddZddZdS)statichttppeercCrDrrrrrrlocalrzstatichttppeer.localcCdSNFrrrrrcanpushrzstatichttppeer.canpushN)rErFrGrhrkrrrrrgs rgcs`eZdZejjZddZfddZddZ ddZ d d Z dd d Z dddZ ddZZS)statichttprepositoryc Cs>||_||_||_t|dd}|\|_}t||}||j|_ ||j d|_ g|_ t |_d|_d|_t|_t|_z t|j d}WnKty}z?|jtjkr_t}z| d}|d|Wnty}z|jtjkrtd|} t| d}~wwWYd}~nd}~wwtj|vr||j d} |t| dO}t |} t!|| t"||t#|_$|j$j%|_%t&||j||_'|j'j|_(|j'j)|_*|j'j |_+i|_,||_-t./|j$|j*} t.0|j*|| |1|_0t22|j*|_2d|_3d|_4t56|_7d|_8d|_9d|_:d|_;dS) NrVs/.hgscachesrequiress 00changelog.irs+'%s' does not appear to be an hg repositorysstore)<_urlrdrootrrrstriprerYrfrrWcachevfs_phasedefaultsr names filtername_extrafilteridset_wanted_sidedatafeaturesr.r@r4r2r3rrr RepoErrorrequirementsmodSHARESAFE_REQUIREMENTr gathersupportedrequirementsensurerequirementsrecognizedensurerequirementscompatibler nodeconstantsnullid makestorestorespathrsvfssjoin _filecacherr manifestrevlog manifestlog narrowmatchr_tags nodetagscacherBranchMapCache _branchcaches_revbranchcache encodepats decodepats _transref) rrdrYurevfsclassrr>rNrMstorevfssupportedrequirements rootmanifestrrrrs|                    zstatichttprepository.__init__cstt||}|dgS)Nspushkey)superrl_restrictcapabilities difference)rcaps __class__rrrs z*statichttprepository._restrictcapabilitiescCs|jSr)rmrrrrrszstatichttprepository.urlcCrirjrrrrrrhrzstatichttprepository.localcCst|Sr)rgrrrrpeerszstatichttprepository.peerTcCtdtddtdNrslock not availableslocks"cannot lock static-http repositoryrLockUnavailablerrwaitrrrwlock zstatichttprepository.wlockcCrrrrrrrlockrzstatichttprepository.lockcCrDrrrrrr _writecachesrz!statichttprepository._writecaches)T)rErFrGr localrepository_basesupported supportedrrrrhrrrr __classcell__rrrrrls F  rlcCs$|r ttdt||ddS)Ns(cannot create new static-http repository)rAbortrrl)rdrYcreateintents createoptsrrrinstance sr)NN)' __future__rr2i18nrnoderrrrr r r r r rryrrrrbutilsrr0r)objectrr4rH basehandlerrJrf localpeerrgrrevlogfilestoragerlrrrrrs"   8 ? l