ó œçƒQc@sêdZddlZddlmZmZmZddlmZddlZde fd„ƒYZ de fd„ƒYZ ddl Z ddlZie j gd 6ejgd 6ejgd 6ejgd 6Zejd ƒZded„ZdS(sCbase class for store implementations and store-related utility codeiÿÿÿÿN(tutiltnodethg(t_t StoreErrorcBs)eZdZd„Zd„Zd„ZRS(sZRaised when there is a problem getting files from or putting files to a central store.cCs(||_||_||_||_dS(N(tfilenamethashturltdetail(tselfRRRR((s>/sys/lib/python2.7/site-packages/hgext/largefiles/basestore.pyt__init__s   cCs&tdƒ|j|j|j|jfS(Ns0error getting id %s from url %s for file %s: %s (RRRRR(R ((s>/sys/lib/python2.7/site-packages/hgext/largefiles/basestore.pyt longmessages cCsd|j|jfS(Ns%s: %s(RR(R ((s>/sys/lib/python2.7/site-packages/hgext/largefiles/basestore.pyt__str__s(t__name__t __module__t__doc__R R R (((s>/sys/lib/python2.7/site-packages/hgext/largefiles/basestore.pyRs  t basestorecBsJeZd„Zd„Zd„Zd„Zed„Zd„Zd„Z RS(cCs||_||_||_dS(N(tuitrepoR(R RRR((s>/sys/lib/python2.7/site-packages/hgext/largefiles/basestore.pyR #s  cCstdƒ‚dS(s>Put source file into the store so it can be retrieved by hash.sabstract methodN(tNotImplementedError(R tsourceR((s>/sys/lib/python2.7/site-packages/hgext/largefiles/basestore.pytput(scCstdƒ‚dS(s€Check to see if the store contains the given hashes. Given an iterable of hashes it returns a mapping from hash to bool.sabstract methodN(R(R thashes((s>/sys/lib/python2.7/site-packages/hgext/largefiles/basestore.pytexists,sc CsCg}g}|j}tjtj|jdƒƒd}|jtd„|Dƒƒƒ}xÊ|D]Â\}}|jt dƒ|dddt |ƒƒ|d7}|j t d ƒ||fƒ|j |ƒsý|j t d ƒ|||jfƒ|j|ƒq]ntj|j|ƒ} tj| d d |jjjƒ} y|j| ||ƒ} Wn,tk r{} |j | jƒƒd} nX| jƒ| |krå| dkrÁ|j t d ƒ||| fƒntj| d ƒ|j|ƒq]ntj| d | ƒtj|j|ƒ|j|| fƒq]W|jt dƒdƒ||fS(súGet the specified largefiles from the store and write to local files under repo.root. files is a list of (filename, hash) tuples. Return (success, missing), lists of files successfully downloaded and those not found in the store. success is a list of (filename, hash) tuples; missing is a list of filenames that we could not get. (The detailed error message will already have been presented to the user, so missing is just supplied as a summary.)ticss|]\}}|VqdS(N((t.0t _filenameR((s>/sys/lib/python2.7/site-packages/hgext/largefiles/basestore.pys Assgetting largefilestunittlfilettotalisgetting %s:%s s'%s: largefile %s not available from %s s.tmpt createmodes*%s: data corruption (expected %s, got %s) N(RRtmakedirstlfutilt storepathRRtsettprogressRtlentnotetgettwarnRtappendtatomictempfiletstoreRt_getfileRR tclosetunlinktrenametlinktousercachetNone( R tfilestsuccesstmissingRtatt availableRRt storefilenamettmpfilethhashterr((s>/sys/lib/python2.7/site-packages/hgext/largefiles/basestore.pyR&1sJ          c Cs1t}|jjtdƒt|ƒƒtƒ}xu|D]m}|j|}d|jƒtj |jƒƒf}x2|D]*}|j |||||ƒrut }ququWq6Wt|ƒ} ttg|D]\} } | ^qÀƒƒ} |r|jjtdƒ| | fƒn |jjtdƒ| | fƒt |ƒS(s³Verify the existence (and, optionally, contents) of every big file revision referenced by every changeset in revs. Return 0 if all is well, non-zero on any errors.s'searching %d changesets for largefiles s%d:%ss3verified contents of %d revisions of %d largefiles s4verified existence of %d revisions of %d largefiles ( tFalseRtstatusRR$R"RtrevRtshortt _verifyfiletTruetint( R trevstcontentstfailedtverifiedR<tcctxtcsettstandintnumrevstfnametfnodet numlfiles((s>/sys/lib/python2.7/site-packages/hgext/largefiles/basestore.pytverifyhs(   %  +    cCstdƒ‚dS(sFetch one revision of one file from the store and write it to tmpfile. Compute the hash of the file on-the-fly as it downloads and return the hash. Close tmpfile. Raise StoreError if unable to download the file (e.g. it does not exist in the store).sabstract methodN(R(R R7RR((s>/sys/lib/python2.7/site-packages/hgext/largefiles/basestore.pyR+†scCstdƒ‚dS(spPerform the actual verification of a file in the store. 'cset' is only used in warnings. 'contents' controls verification of content hash. 'standin' is the standin path of the largefile to verify. 'verified' is maintained as a set of already verified files. Returns _true_ if it is a standin and any problems are found! sabstract methodN(R(R RERFRBRGRD((s>/sys/lib/python2.7/site-packages/hgext/largefiles/basestore.pyR>Žs( R RR RRR&R:RLR+R>(((s>/sys/lib/python2.7/site-packages/hgext/largefiles/basestore.pyR"s    7  tfilethttpthttpstsshs^([a-zA-Z0-9+-.]+)://c Cs‡|j}|sŸt|ddƒ}|r9|j|ƒ}n|jddƒ}|dksc|dkrrd}|}qŸtj|ƒ\}}tj|i|ƒ}ntj|dƒr½|j ƒpÃ|j }t j |ƒ}|säd}n|j dƒ}yt|} Wn*tk r-tjtdƒ|ƒ‚nXx9| D]1} y| |||ƒSWq5tjk req5Xq5Wtjtd ƒ|ƒ‚dS( Nt lfpullsources default-pushtdefaultRRRMisunsupported URL scheme %rs*%s does not appear to be a largefile store(RtgetattrR0t expandpathRtparseurltpeerRt safehasattrRtpatht _scheme_retmatchtgroupt_storeprovidertKeyErrortAbortRR tstoreprotonotcapable( RtremoteRRRQRXt _branchesRZtschemetstoreproviderstclassobj((s>/sys/lib/python2.7/site-packages/hgext/largefiles/basestore.pyt _openstore¦s4  '   (Rtret mercurialRRRtmercurial.i18nRR t ExceptionRtobjectRt localstoret wirestoreR\tcompileRYR0R:Re(((s>/sys/lib/python2.7/site-packages/hgext/largefiles/basestore.pyt s  v