
    6h-                        S SK Jr  S SKrS SKJr  S SKJrJr  S SKJ	r	J
r
JrJrJrJrJr  S SKJr  SSKJrJrJrJrJrJrJrJrJrJr  S	 rS
 rS rS r S r!S r"g)    )annotationsN)_)hexnullrev)encodingerror	localrepomatchscmutilsparseutil)procutil   )
connectionpool	constantscontentstoredatapackfileserverclienthistorypackmetadatastoreremotefilectxremotefilelogshallowutilc                x   [         R                  R                  U R                  R                  R
                  S5      n[         R                  R                  U5      (       d  [         R                  " U5        [        R                  " XU R                  SS9n[        R                  " XU R                  SS9nX#4$ )z:In-repo stores, like .hg/store/data; can not be discarded.s   dataFshared)ospathjoinsvfsvfsbaseexistsmakedirsr   remotefilelogcontentstorenamer   remotefilelogmetadatastore)repo	localpathlocalcontentlocalmetadatas       A/usr/lib/python3/dist-packages/hgext/remotefilelog/shallowrepo.pymakelocalstoresr-   (   s    TYY]]//9I77>>)$$
I  995L "<<5M &&    c                @   [         R                  " U R                  5      n[        R                  " XU R
                  SS9n[        R                  " XU R
                  SS9nX l        U R                  R                  U5        U R                  R                  U5        X#4$ )z?Typically machine-wide, cache of remote data; can be discarded.Tr   )r   getcachepathuir   r%   r&   r   r'   sharedstoreshareddatastoresappendsharedhistorystores)r(   	cachepathcachecontentcachemetadatas       r,   makecachestoresr9   8   s     ((1I994L "<<4M $  .##M2&&r.   c                    [         R                   " U 5      U l        [        R                  " U R                  U R                  U5      n[
        R                  " U R                  U R                  U5      nX44$ )z-These stores fetch data from a remote server.)r   fileservicer   remotecontentstorer1   r   remotemetadatastore)r(   r7   r8   remotecontentremotemetadatas        r,   makeremotestoresr@   J   sf     (88>D 33!!<M #66!!=N ((r.   c                   [         R                  " U [        R                  5      n[        R
                  " U R                  U5      n[        R                  " U R                  U5      nU R                  R                  U5        U R                  R                  U5        [         R                  " U R                  SX#5        X#4$ )z5Packs are more efficient (to read from) cache stores.	   filestore)r   getcachepackpathr   FILEPACK_CATEGORYr   datapackstorer1   r   historypackstorer3   r4   r5   reportpackmetrics)r(   packpathpackcontentstorepackmetadatastores       r,   makepackstoresrK   W   s     ++D)2M2MNH--dggx@#44TWWhG  !12##$56!!/ ..r.   c                   / U l         / U l        [        U 5      u  p[        U 5      u  p4[	        U 5      u  pV[        XU5      u  px[        R                  " UUUUUS9U l        [        R                  " UUUUUS9U l        Un	Un
U R                  R                  U R                  U R                  U	U
5        [        R                  " U R                  SX5        g)zBUnion stores iterate the other stores and return the first result.)
writestorerB   N)r3   r5   rK   r9   r-   r@   r   unioncontentstorer   unionmetadatastorer;   setstorer   rG   r1   )r(   rI   rJ   r7   r8   r*   r+   r>   r?   fileservicedatawritefileservicehistorywrites              r,   makeunionstoresrS   f   s    D!D*8*>'"1$"7L"1$"7L$4M%!M
 %66D '99 D (+	 !!/r.   c                .  ^   " U 4S jST R                   5      nUT l         [        R                  " 5       T l        [	        T 5        T R
                  R                  SSS 5      T l        T R
                  R                  SSS 5      T l        [        T S5      (       d  [        R                  " T 5      T l
        T R                  (       d  T R                  (       a>  [        R                  " T R                  SS T R                  T R                  5      T l        g g )Nc                     >^  \ rS rSr\R
                  S 5       r\R
                  U4S j5       rU4S jrU 4S jr	U 4S jr
\R                  SU 4S jj5       r SU4S jjrSU4S	 jjrSU4S
 jjrU 4S jrSrU =r$ )#wraprepo.<locals>.shallowrepository   c                :    U R                   R                  SS5      $ )N   remotefilelogs   reponame)r1   config)selfs    r,   r&   (wraprepo.<locals>.shallowrepository.name   s    77>>"2K@@r.   c                   > TR                   R                  SSTR                   R                  SS5      5      nU(       d  [        R                  " S5      eU$ )NrY   s   fallbackpaths   pathss   defaults>   no remotefilelog server configured - is your .hg/hgrc trusted?)r1   rZ   r   Abort)r[   r   r(   s     r,   fallbackpath0wraprepo.<locals>.shallowrepository.fallbackpath   sO    77>> x4D
 kk> 
 Kr.   c                   > U(       a  [         R                  " TUS9nO[         R                  " T5      nUR                  5       (       a  gU$ )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   matcheralways)r[   rb   kwargsretr(   s       r,   maybesparsematch4wraprepo.<locals>.shallowrepository.maybesparsematch   s9     nnT5nnT*zz||Jr.   c                   > US   S:X  a  USS  nU R                  U5      (       a!  [        R                  " U R                  X5      $ [        TU ]  U5      $ )Nr      /r   )shallowmatchr   r    superfile)r[   f	__class__s     r,   rm   (wraprepo.<locals>.shallowrepository.file   sO    tt|abE  ##$22499aFFw|A&r.   c                   > U R                  U5      (       a  [        R                  " X/UQ70 UD6$ [        TU ]  " U/UQ70 UD6$ N)rk   r   rl   filectx)r[   r   argsre   ro   s       r,   rs   +wraprepo.<locals>.shallowrepository.filectx   sH      &&$224OOOOwt=d=f==r.   c                  > UR                  5       (       d  UR                  5       R                  5       n/ nUR                  5       UR	                  5       -    HK  nUR                  X`R                  5      nXpR                  :w  d  M/  UR                  U[        U5      45        MM     U R                  R                  U5        [        TU ]1  XUS9$ )zcAdd a new revision to current repository.
Revision information is passed via the context argument.
)r   origctx)manifestnodep1manifestmodifiedaddedgetnullidr4   r   r;   prefetchrl   	commitctx)	r[   ctxr   rw   m1filesrn   fparent1ro   s	           r,   r   -wraprepo.<locals>.shallowrepository.commitctx   s     ##%%VVX&&(#))+5A!vva5H;;.aX%78 6   ))%07$Sw$GGr.   c                `  > [         R                  " 5       STR                  S/nU(       a  UR                  S5        U(       a  USU/-  n0 nTR                  R                  SS5      (       a  TR                  R                  US'   [         R                  " U[        R                  4SS	0UD6  g
)z0Runs prefetch in background with optional repacks   -Rs   prefetchs   --repacks   -rs   devels   remotefilelog.bg-waitrecord_waitensurestartFN)
r   hgexecutableorigrootr4   r1   
configboolatexitrunbgcommandr   environ)	r[   rb   r"   repackpatsoptscmdre   r(   s	           r,   backgroundprefetch6wraprepo.<locals>.shallowrepository.backgroundprefetch   s     ((*E4==+NC

;'t}$ Fww!!(,DEE(,}%!!X%%38<Br.   c           
        > TR                  TR                  SSSS[        S5      TR                  -  5         U R	                  XX45        SSS5        g! , (       d  f       g= f)zdPrefetches all the necessary file revisions for the given revs
Optionally runs repack in background
s   prefetchlockTNs   prefetching in %s)_lockr    r   r   	_prefetch)r[   rb   r"   r   r   r(   s        r,   r   ,wraprepo.<locals>.shallowrepository.prefetch   sV     		&'$--7 t46  s   A
A"c                  >^^ U R                   nU(       aG  TR                  SU5      nUb1  U[        :w  a'  [        TR                  SX&5      5      nU(       a  US   nOTnTR                  nUR                  S5      n	Ub>  UTU   R                  5          R                  5       n
[        U
R                  5       5      nO
[        5       nUR                  5       nUR                  5       n[        5       nUR                  [        5        [        U5      nU R                  R                  [        S5      US9nUR!                  S5        [#        U5       H  nTU   nU(       a  [$        R&                  " UX45      mTR)                  U5      mUR                  5       nU	R+                  U5      nUU   R-                  U5      S   n
U
R                  5       nU(       a  U4S jU 5       nT(       a  U4S	 jU 5       nUU;  a  UR!                  U5        OUR!                  U5        UR                  U5        UR/                  5         M     UR1                  U5        UR1                  U5        UR3                  5         U(       a<  U VVs/ s H  u  nnU[5        U5      4PM     nnnTR6                  R9                  US
S9  U(       a>  U VVs/ s H  u  nnU[5        U5      4PM     nnnTR6                  R9                  U5        g g s  snnf s  snnf )Ns   outgoing(%s)s   first(reverse(::%s) - %ld)r   r.   s   prefetching)totalr   c              3  L   >#    U  H  nT" US    5      (       d  M  Uv   M     g7fr   N ).0pfms     r,   	<genexpr>@wraprepo.<locals>.shallowrepository._prefetch.<locals>.<genexpr>)  s     :22a5BB   $	$c              3  L   >#    U  H  nT" US    5      (       d  M  Uv   M     g7fr   r   )r   r   sparsematchs     r,   r   r   +  s     D2RU1CBBr   T)force)r_   rb   r   listmanifestlog
getstoragerx   readsetitemscopyaddlenr1   makeprogressr   updatesortedr   r
   rg   revread_any_fast_delta	incrementdifference_updatecompleter   r;   r   )r[   rb   r"   r   r   r_   	localrevs
serverbasemflmfrevlogmfdictskipr   serverfilesvisitedrevcountprogressr   r   mfnodemfrevdiffr   fnoderesultsr   r   r(   s                            @@r,   r   -wraprepo.<locals>.shallowrepository._prefetch   s   ,,L !IIo|D	#!%		94"J
 ")!} 	""C~~c*HT$Z4467<<>6<<>*u IIKE))+KeGKK 4yHww++An,=X+NHOOAd|3ic46A"33C8))+ V, V88A!D||~::DDDDi'&&t,LL&E"""$1 $4 ##D)))$/ CNO;-4D#e*-;O  ))')> CHI5-4D#e*-5I  ))'2 	 P
 Js   K?Lc                V   > [         TU ]  5         U R                  R                  5         g rr   )rl   closer   )r[   ro   s    r,   r   )wraprepo.<locals>.shallowrepository.closeB  s    GMO%%'r.   r   )FN)NFNN)NNN)__name__
__module____qualname____firstlineno__r   propertycacher&   r_   rg   rm   rs   r	   unfilteredmethodr   r   r   r   r   __static_attributes____classcell__)ro   r(   s   @r,   shallowrepositoryrV      s    				A 
	A 
			 
			'	> 
	#	#	H 
$	H( BF	&	7I	3V	( 	(r.   r   rY   s   includepatterns   excludepatternr   r.   )ro   r
   rd   rk   rS   r1   
configlistincludepatternexcludepatternhasattrr   root)r(   r   s   ` r,   wraprepor      s    t(DNN t(l 'DNDD'',,+TD '',,+TD 4)**,;;DAd11!KKIIsD$"5"5t7J7J
 2r.   )#
__future__r   r   mercurial.i18nr   mercurial.noder   r   	mercurialr   r   r	   r
   r   r   r   mercurial.utilsr    r   r   r   r   r   r   r   r   r   r   r-   r9   r@   rK   rS   r   r   r.   r,   <module>r      sV    # 	  '   %   ' '$
)/&RI
r.   