o ]Lb /@sddlmZddlZddlmZddlmZmZddlm Z m Z m Z m Z m Z mZmZmZddlmZddlmZmZmZmZmZmZmZmZmZmZd d Zd d Zd dZ ddZ!ddZ"ddZ#dS))absolute_importN)_)hexnullrev)encodingerror localrepomatchpycompatscmutilsparseutil)procutil) connectionpool constants contentstoredatapackfileserverclient historypack metadatastore remotefilectx remotefilelog shallowutilcCsZtj|jjjd}tj|st|tj |||j dd}t j |||j dd}||fS)z:In-repo stores, like .hg/store/data; can not be discarded.sdataFshared) ospathjoinsvfsvfsbaseexistsmakedirsrremotefilelogcontentstorenamerremotefilelogmetadatastore)repo localpath localcontent localmetadatar+A/usr/lib/python3/dist-packages/hgext/remotefilelog/shallowrepo.pymakelocalstores's    r-cCsZt|j}tj|||jdd}tj|||jdd}||_|j ||j |||fS)z?Typically machine-wide, cache of remote data; can be discarded.Tr) r getcachepathuirr$r%rr& sharedstoreshareddatastoresappendsharedhistorystores)r' cachepath cachecontent cachemetadatar+r+r,makecachestores7s     r7cCs8t||_t|j|j|}t|j|j|}||fS)z-These stores fetch data from a remote server.)r fileservicerremotecontentstorer/rremotemetadatastore)r'r5r6 remotecontentremotemetadatar+r+r,makeremotestoresIs   r=cCs\t|tj}t|j|}t|j|}|j ||j |t |jd||||fS)z5Packs are more efficient (to read from) cache stores. filestore) rgetcachepackpathrFILEPACK_CATEGORYr datapackstorer/rhistorypackstorer1r2r3reportpackmetrics)r'packpathpackcontentstorepackmetadatastorer+r+r,makepackstoresVs   rGc Csg|_g|_t|\}}t|\}}t|\}}t|||\}}tj|||||d|_tj |||||d|_|} |} |j |j|j| | t |jd||dS)zBUnion stores iterate the other stores and return the first result.) writestorer>N)r1r3rGr7r-r=runioncontentstorerunionmetadatastorer8setstorerrCr/) r'rErFr5r6r)r*r;r<fileservicedatawritefileservicehistorywriter+r+r,makeunionstoresesB    rNcsGfdddj_t_tjddd_jddd_t ds6t _ js<jrKtj ddjj_dSdS)NcseZdZejddZejfddZfddZfddZfd d Z e j dfd d Z dfdd Z dfdd Zdfdd ZfddZZS)z#wraprepo..shallowrepositorycSs|jddS)N remotefilelogsreponame)r/configselfr+r+r,r%sz(wraprepo..shallowrepository.namecs,jddjdd}|std|S)NrOs fallbackpathspathssdefaults>no remotefilelog server configured - is your .hg/hgrc trusted?)r/rPrAbort)rRrr'r+r, fallbackpaths z0wraprepo..shallowrepository.fallbackpathcs.|r tj|d}nt}|rdS|S)z A wrapper that allows the remotefilelog to invoke sparsematch() if this is a sparse repository, or returns None if this is not a sparse repository. )revsN)r matcheralways)rRrVkwargsretrTr+r,maybesparsematchs  z4wraprepo..shallowrepository.maybesparsematchcsB|ddkr |dd}||rt|j||St||S)Nr/r) shallowmatchrrsuperfile)rRf __class__shallowrepositoryr+r,r_s   z(wraprepo..shallowrepository.filecsB||rtj||g|Ri|St|j|g|Ri|SN)r]rr^filectx)rRrargsrYrar+r,res  z+wraprepo..shallowrepository.filectxFNcsz|s2|}g}||D]}|||j}||jkr+||t|fq|j |t |j |||dS)z{Add a new revision to current repository. Revision information is passed via the context argument. )rorigctx) manifestnodep1manifestmodifiedaddedgetnullidr2rr8prefetchr^ commitctx)rRctxrrgm1filesr`fparent1rar+r,rps    z-wraprepo..shallowrepository.commitctxcsltdjdg}|r|d|r|d|g7}i}jddr'jj|d<tj|tj fdd i|d S) z0Runs prefetch in background with optional repacks-Rsprefetchs--repacks-rsdevelsremotefilelog.bg-wait record_wait ensurestartFN) r hgexecutableorigrootr2r/ configboolatexit runbgcommandrenviron)rRrVr!repackpatsoptscmdrYrTr+r,backgroundprefetchs    z6wraprepo..shallowrepository.backgroundprefetchc sVjddddtdj|||||WddS1s$wYdS)z|Prefetches all the necessary file revisions for the given revs Optionally runs repack in background s prefetchlockTNsprefetching in %s)_lockrrrx _prefetch)rRrVr!r~rrTr+r,ros "z,wraprepo..shallowrepository.prefetchcs|j}|r#d|}|dur"|tkr"td||}|r"|d}n}j}|d} |durC||} tt | } nt} | } | } t}| tt |}|jjtd|d}|dt|D]l}|}|r|t|||||}| |}| |\}}||vr||vr||} n||} t | }|rfdd|D}rfd d|D}||vr| |n| || ||qm| | | | || rd d | D}jj|d d | r dd | D}j|dSdS)Ns outgoing(%s)sfirst(reverse(::%s) - %ld)rs prefetching)totalc3 |] }|dr|VqdSrNr+.0pf)mr+r, 0z@wraprepo..shallowrepository._prefetch..c3rrr+r) sparsematchr+r,r2rcSg|] \}}|t|fqSr+rrrfnoder+r+r, AzAwraprepo..shallowrepository._prefetch..T)forcecSrr+rrr+r+r,rFr)rUrVrlist manifestlog getstoragerhreadsetr iteritemscopyaddlenr/ makeprogressrupdatesortedr r r[rev parentrevsreadfast incrementdifference_updatecompleter8ro)rRrVr!r~rrU localrevs serverbasemflmfrevlogmfdictskiprs serverfilesvisitedrevcountprogressrrqmfnodemfrevrip2diffresultsrT)rrr,rsr               z-wraprepo..shallowrepository._prefetchcst||jdSrd)r^closerrQrar+r,rIsz)wraprepo..shallowrepository.close)FN)NFNN)NNN)__name__ __module__ __qualname__r propertycacher%rUr[r_rerunfilteredmethodrprrorr __classcell__r+r'rc)rbr,rcs   OrcrOsincludepatternsexcludepatternrr) rbr rXr]rNr/ configlistincludepatternexcludepatternr safehasattrrrootrTr+rr,wraprepos$?     r)$ __future__rrmercurial.i18nrmercurial.noderr mercurialrrrr r r r r mercurial.utilsrrrrrrrrrrrr-r7r=rGrNrr+r+r+r,s  ( 0  )