o ]Lb3@sddlmZddlZddlmZmZddlmZddlm Z m Z m Z ddl m Z mZmZGdd d eZGd d d e jZGd d d e j ZGdddeZGdddeZdS))absolute_importN)hexsha1nodeconstants)getattr)mdiffpycompatrevlog) basestore constants shallowutilc@s$eZdZdZdZdZdZdZdZdS) ChainIndiciesz>A static class for easy reference to the delta chain indicies.rr N) __name__ __module__ __qualname____doc__NAMENODEBASENAMEBASENODEDATArrB/usr/lib/python3/dist-packages/hgext/remotefilelog/contentstore.pyr sr cseZdZfddZddZejjddZddZ ejjd d Z d d Z ejjd dZ ddZ ddZddZdddZZS)unioncontentstorecs:tt|j|i|||_|d|_|dd|_dS)N writestoreallowincompleteF)superr__init__storesgetrrselfargskwargs __class__rrr )s zunioncontentstore.__init__cCsj|||}|dtjtjkrt|t|f|tj}|}|r3|tj}t ||g}|s#|S)a Fetches the full text revision contents of the given name+node pair. If the full text doesn't exist, throws a KeyError. Under the hood, this uses getdeltachain() across all the stores to build up a full chain to produce the full text. ) getdeltachainr rrnullidKeyErrorrpoprrpatches)r$namenodechainfulltexttextdeltarrrr"4s zunioncontentstore.getc C@|jD]}z |||WStyYqwt|t|f)z;Return the single delta entry for the given name/node pair.)r!getdeltar,rr$r/r0storerrrr6Ls  zunioncontentstore.getdeltacCs|||}|dtjtjkr?|d\}}}}}z |||}||Wnty4|js1Y|Sw|dtjtjks|S)a Returns the deltachain for the given name/node pair. Returns an ordered list of: [(name, node, deltabasename, deltabasenode, deltacontent),...] where the chain is terminated by a full text entry with a nullid deltabasenode. r))_getpartialchainr rrr+extendr,r)r$r/r0r1x deltabasename deltabasenode morechainrrrr*Ws    zunioncontentstore.getdeltachainc Cr5)z)Returns the metadata dict for given node.)r!getmetar,rr7rrrr?os  zunioncontentstore.getmetacCsdd|jD}tj|S)NcSsg|]}|qSr) getmetrics).0srrr zsz0unioncontentstore.getmetrics..)r!r sumdicts)r$metricsrrrr@ys zunioncontentstore.getmetricsc Cr5)zReturns a partial delta chain for the given name/node pair. A partial chain is a chain that may not be terminated in a full-text. )r!r*r,rr7rrrr9}s  z"unioncontentstore._getpartialchaincCtdNs5cannot add content only to remotefilelog contentstore RuntimeErrorr$r/r0datarrraddzunioncontentstore.addcCs"|}|jD] }|r||}q|SN)r! getmissing)r$keysmissingr8rrrrOs   zunioncontentstore.getmissingcCs"|jr |j|||dStd)Nsno writable store configured)raddremotefilelognoderIrJrrrrRsz&unioncontentstore.addremotefilelognodeNcCs|jD]}|||qdSrN)r! markledger)r$ledgeroptionsr8rrrrSs zunioncontentstore.markledgerrN)rrrr r"r baseunionstore retriabler6r*r?r@r9rLrOrRrS __classcell__rrr'rr(s        rcsTeZdZfddZddZddZddZd d Zd d Zd dZ ddZ Z S)remotefilelogcontentstorecs$tt|j|i|t|_dSrN)rrYr threadinglocal _threaddatar#r'rrr sz"remotefilelogcontentstore.__init__cCs|||}t|\}}}||||}t|}||\} } } } d} | r+t| } |||||tj@r;d} } t|| | }|SrN) _getdatar parsesizeflags ancestormapr_updatemetacacherREVIDX_EXTSTOREDcreaterevlogtext)r$r/r0rKoffsetsizeflagscontentr_p1p2linknodecopyfromcopyrevrevisionrrrr"s   zremotefilelogcontentstore.getcCs"|||}||tj|||fSrN)r"rr+r?r$r/r0rlrrrr6s  z"remotefilelogcontentstore.getdeltacC|||}||dtj|fgSrNr"rr+rmrrrr* z'remotefilelogcontentstore.getdeltachaincCsN|||jjdkr!|||}t|\}}}|||||jjdSNrr )_sanitizemetacacher\ metacacher]r r^r`)r$r/r0rKrcrdrerrrr?s   z!remotefilelogcontentstore.getmetacCrFrGrHrJrrrrLrMzremotefilelogcontentstore.addcCs&t|jdd}|durd|j_dSdS)Nrs)NN)rr\rs)r$rsrrrrrs z,remotefilelogcontentstore._sanitizemetacachecCs<|||jjdkrdStj|tj|i}||f|j_dS)Nr)rrr\rsr METAKEYFLAG METAKEYSIZE)r$r0rdremetarrrr`s z*remotefilelogcontentstore._updatemetacache) rrrr r"r6r*r?rLrrr`rXrrr'rrYs  rYc@sNeZdZddZddZddZddZd d Zd d Zd dZ dddZ dS)remotecontentstorecCs||_||_dSrN) _fileservice_shared)r$ui fileservicesharedrrrr s zremotecontentstore.__init__cC*|jj|t|fgddd|j||SNT)force fetchdata)rxprefetchrryr"r$r/r0rrrr"zremotecontentstore.getcCs$|||}||tj|j||fSrN)r"rr+ryr?rmrrrr6s  zremotecontentstore.getdeltacCrnrNrormrrrr*rpz remotecontentstore.getdeltachaincCr}r~)rxrrryr?rrrrr?rzremotecontentstore.getmetacCrF)Nscannot add to a remote storerHrJrrrrL zremotecontentstore.addcCs|SrNr)r$rPrrrrOzremotecontentstore.getmissingNcCdSrNr)r$rTrUrrrrSrzremotecontentstore.markledgerrN) rrrr r"r6r*r?rLrOrSrrrrrws rwc@sxeZdZddZddZddZddZd d Zdd d ZddZ ddZ ddZ ddZ ddZ dddZddZd S)manifestrevlogstorecCs4|j|_|j|_t|_tj|jdd|_d|_dS)Ns 00changelog.iradixr) r8_storesvfs_svfsdict_revlogsr_cl_repackstartlinkrev)r$reporrrr s  zmanifestrevlogstore.__init__cCs|||SrN)_revlograwdatarrrrr"szmanifestrevlogstore.getcCs$|||}|||jj|||fSrN)r"rr+r?rmrrrr6"s zmanifestrevlogstore.getdeltacCs |||}||d|jj|fgSrN)r"rr+rmrrrr*&s z!manifestrevlogstore.getdeltachaincCs0||}||}tj||tj||iSrN)rrevr rtrerurawsize)r$r/r0rlrrrrr?*s    zmanifestrevlogstore.getmetaNc Cs|durt}||vr gS||}i}|h}|j||gddD]J}||}||||\} } | |jjkrD| |vrD| | | |jjkrS| |vrS| | |j| |} | | | df|||<|sl|Sq"|S)NT) inclusive) setr ancestorsrr0discardparentsrr+rLlinkrev) r$r/r0knownrrrQancrevancnodergrhrirrr getancestors2s,     z manifestrevlogstore.getancestorscCsD|j}||}||}|||}|d|d||dfSrq)rrrrrr0)r$r/r0clrrrrrr getnodeinfoKs   zmanifestrevlogstore.getnodeinfocGrF)Nscannot add to a revlog storerH)r$r%rrrrLRrzmanifestrevlogstore.addcCsF|j|}|dur!d}|dkrd|}tj|j|d}||j|<|S)N00manifesttreersmeta/%s/00manifestr)rr"rr)r$r/r revlognamerrrrUs  zmanifestrevlogstore._revlogcCs8g}|D]\}}||}||jvr|||fq|SrN)rnodemapappend)r$rPrQr/r0mfrevlogrrrrO_s   zmanifestrevlogstore.getmissingcCs||_||_dSrN)r_repackendlinkrev)r$startrevendrevrrrsetrepacklinkrevrangehs z)manifestrevlogstore.setrepacklinkrevrangec Cs^|r |tjr dSd}tj|jdd}|j}|j}tt |dddD]%}| |}||kr2n||kr7q%| |} | ||| | ||| q%|jD]\\} } } | dddkse| ddd krfqP| dt d  }tj|j| ddd }tt |dddD]%}| |}||krn||krq| |} | ||| | ||| qqPdS) Nrrrr r)smeta/s.is /00manifest) indexfile)r"r OPTION_PACKSONLYrrrrrxrangelenrr0 markdataentrymarkhistoryentryr datafiles) r$rTrUtreenamer startlinkrev endlinkrevrrr0tpathrdrrrrSls>     zmanifestrevlogstore.markledgercCrrNr)r$rTrrrcleanuprzmanifestrevlogstore.cleanuprN)rrrr r"r6r*r?rrrLrrOrrSrrrrrrs    "r) __future__rrZmercurial.noderrmercurial.pycompatr mercurialrrrr r r objectr rVrrYrwrrrrrs  zH-