
    6hVN                    0   % S SK Jr  S SKrS SKrS SKrS SKJrJrJr  SSKJ	r	  SSK
Jr  \R                  (       a  S SKrSSKJrJrJrJrJr  SSKJr  \R.                  rS	rS
rS.S jrS/S jrSSS\/r\R:                   " S S5      5       rSSSSSS.rSSSSSSS.SSSSSSS.SSSSSSS.SSSSSSSS.SSSSSSSS.SS0SS0S.r S\!S '   \ S   \ S!'   1 S"kr"S# r#\#\#\#\#\#\#S$.r$S% r%S0S& jr&S' r'S( r(\RR                  " S)5      r* S1S* jr+ " S+ S,5      r,S- r-g)2    )annotationsN)DictUnioncast   )_)attr)errorrequirementssslutilurlutil)
stringutils   clonebundles.manifests   peer-bundle-cache://c                Z   U R                   R                  [        5      nUR                  5        Vs/ s H  o"R	                  SS5      PM     nn/ nU H@  n[        XS   5      n[        U5      S:X  a  US-   nO	SXRS   4-  nUR                  U5        MB     SR                  U5      $ s  snf )z>get the bundle manifest to be served to a client from a server    r   r      
s   %s %s
    )	vfstryreadCB_MANIFEST_FILE
splitlinessplitalter_bundle_urllenappendjoin)reporaw_texteentries	new_linesr   lines          8/usr/lib/python3/dist-packages/mercurial/bundlecaches.pyget_manifestr$   *   s    xx 01H)1)<)<)>?)>AwwtQ)>G?ItqT*q6Q;;Dd+D  88I @s   B(c                    U$ )za function that exist to help extension and hosting to alter the url

This will typically be used to inject authentication information in the url
of cached bundles. )r   r   s     r#   r   r   :   s	    
 Jr   s   http://s   https://s   largefile://c                     \ rS rSr\R
                  " 5       r\R
                  " 5       r\R
                  " 5       r\R
                  " 5       r	\R
                  " 5       r
\R
                  " 5       r\S 5       r\S 5       rSS jrS rSrg)	
bundlespecJ   c                X    [         R                  " U R                  U R                  5      $ N)collectionsChainMap_explicit_params_default_optsselfs    r#   paramsbundlespec.paramsW   s!    ##D$9$94;M;MNNr   c                    U R                   $ r+   )r2   r0   s    r#   contentoptsbundlespec.contentopts[   s     {{r   c                N    U(       d  XR                   ;  a  X R                   U'   gg)zGSet a bundle parameter value.

Will only overwrite if overwrite is trueN)r.   )r1   keyvalue	overwrites       r#   	set_parambundlespec.set_param`   s%     #8#88).!!#& 9r   c                $   SU R                   U R                  4-  /n[        U R                  R	                  5       5       H=  u  p#[        U[        5      (       a  U(       a  SOSnOUnUR                  SX$4-  5        M?     SR                  U5      $ )Ns   %s-%ss   yess   nos   %s=%s   ;)	compressionversionsortedr.   items
isinstanceboolr   r   )r1   partsparam	raw_valuer9   s        r#   as_specbundlespec.as_specg   s    T--t||<<= &t'<'<'B'B'D EE)T**"+!LLUN23 !F yyr   r&   NT)__name__
__module____qualname____firstlineno__r	   ibr?   wirecompressionr@   wireversionr.   r/   propertyr2   r5   r;   rH   __static_attributes__r&   r   r#   r(   r(   J   sy    '')KggiOggiG'')Kwwy GGIMO O  / r   r(   s   01   02s   03   s1)   v1   v2   v3   packed1   bundle2TF)   changegroup
   cg.version   obsolescence   phases   tagsfnodescache   revbranchcacherW   )r[   r\   r]   r^      streamr_   r`      v3-expr\   )rV   rW   rX      streamv2   streamv3-exprY   rZ   z,Dict[bytes, Dict[bytes, Union[bool, bytes]]]_bundlespeccontentoptsrZ   >      gzip   none   bzip2c                    [         R                  " U5      nUc'  [        S5      nX0U4-  n[        R                  " U5      eU$ )z'make a boolean out of a parameter values'   parameter %s should be a boolean ('%s'))r   	parseboolr   r
   InvalidBundleSpecification)r8   r9   bmsgs       r#   
param_boolrn      sD    U#Ay:;U|..s33Hr   )r]   s   obsolescence-mandatoryr^   r[   r_   r`   c                   SU ;  a  U 0 4$ 0 nU R                  SS5      u  p#[        S5      nUR                  S5       H  nSU;  a  XE-  n[        R                  " U5      eUR                  SS5      u  px[        R                  U5      n[        R                  U5      n[        R                  U5      n	U	b  U	" Xx5      nXU'   M     X!4$ )zrparse bundlespec parameter section

input: "comp-version;params" string

return: (spec; {param_key: param_value})
r>   r   s:   invalid bundle specification: missing "=" in parameter: %s   =)r   r   r
   rk   urlrequnquotebundle_spec_param_processingget)
sr2   r@   paramstrerrprm   r8   r9   processs
             r#   _parseparamsrz      s     1}"uFa(G
I
JC^^D!q='C22377WWT1%
nnS!u%.2237C'Es " ?r   c                   U(       a(  SU;  a"  [         R                  " [        S5      U-  5      eUR                  SS5      S   nSU;   a  UR                  SS5      u  pEU[        R
                  R                  ;  a"  [         R                  " [        S5      U-  5      e[        U5      u  pVU[        ;  a"  [         R                  " [        S5      U-  5      eOU(       a   e[        U5      u  pU[        R
                  R                  ;   aR  UnSn[        R                  U R                  ;   a  S	nO [        R                  U R                  ;   a  S	nU[        ;  a  S	nO:U[        ;   a  US
:X  a  SnOSnUnO"[         R                  " [        S5      U-  5      eUS:X  a,  U[        ;  a"  [         R                  " [        S5      U-  5      eSU;   a  [        [!        ["        US   5      R                  S5      5      nU[        R$                  -
  nSSKJn	  U	R+                  U R,                  5      n
X-
  nU(       a:  [         R                  " [        S5      SR/                  [1        U5      5      -  5      eSU;   a  US   S	:X  a  SnUS   S:X  a  Sn[        R3                  U0 5      R5                  5       nUS:X  d  US:X  a  S	n[        R
                  R7                  U5      nUR9                  5       u  pN[        U   S   n[;        XNX_Xl5      $ )a  Parse a bundle string specification into parts.

Bundle specifications denote a well-defined bundle/exchange format.
The content of a given specification should not change over time in
order to ensure that bundles produced by a newer version of Mercurial are
readable from an older version.

The string currently has the form:

   <compression>-<type>[;<parameter0>[;<parameter1>]]

Where <compression> is one of the supported compression formats
and <type> is (currently) a version string. A ";" can follow the type and
all text afterwards is interpreted as URI encoded, ";" delimited key=value
pairs.

If ``strict`` is True (the default) <compression> is required. Otherwise,
it is optional.

Returns a bundlespec object of (compression, version, parameters).
Compression will be ``None`` if not in strict mode and a compression isn't
defined.

An ``InvalidBundleSpecification`` is raised when the specification is
not syntactically well formed.

An ``UnsupportedBundleSpecification`` is raised when the compression or
bundle type/version is not recognized.

Note: this function will likely eventually return a more complex data
structure, including bundle2 part information.
   -sC   invalid bundle specification; must be prefixed with compression: %sr>   r   r   s   %s compression is not supporteds%   %s is not a recognized bundle versionrV   rW   rY   rg   rh   s+   %s is not a recognized bundle specifications4   compression engine %s is not supported on v1 bundless   requirements   ,)	localrepos+   missing support for repository features: %ss   , ra   rc   rb   rd   r\   )r
   rk   r   r   r   compenginessupportedbundlenamesUnsupportedBundleSpecificationrz   re   requirementsmodGENERALDELTA_REQUIREMENTr   REVLOGV2_REQUIREMENT_bundlespecv1compenginessetr   bytesSTREAM_IGNORABLE_REQUIREMENTS r~   gathersupportedrequirementsuir   rA   rt   copyforbundlename
bundletyper(   )r   specstrictpre_argsr?   r@   r2   r   relevant_reqsr~   supported_reqmissing_reqsr5   enginerP   rQ   s                   r#   parsebundlespecr      s   B $d"..9 	
 	
 zz$"1%Hx#zz$2d..CCC6645C  'w/0066:;gE  1 z#D)4##888KG774;L;LL 559J9JJ"::++z!%&G66@ADH 
 %K/GG22EF
 	
 & 4vo'>?EEdKL?HHH 	 	 !==dggF$466@A**VL123  F )%!G)	)%G(,,Wb9>>@K+O!;++K8F#)#4#4#6 K(1-@KgF r   c                $   / nUR                  5        H  nUR                  5       nU(       d  M  SUS   0nUSS  H  nUR                  SS5      u  px[        R                  R	                  U5      n[        R                  R	                  U5      nXU'   US:X  d  Ma   [        X5      n	U	R                  US'   U	R                  US'   M     UR                  U5        M     U$ ! [        R                   a     M  [        R                   a     M  f = f)	zParses the raw text of a clone bundles manifest.

Returns a list of dicts. The dicts have a ``URL`` key corresponding
to the URL and other keys are the attributes for the entry.
   URLr   r   Nrp   
   BUNDLESPECs   COMPRESSIONs   VERSION)r   r   r   rq   rr   r   r?   r@   r
   rk   r   r   )
r   ru   mr"   fieldsattrsrawattrr8   r9   r(   s
             r#   parseclonebundlesmanifestr   q  s    	A#abzG tQ/JC++%%c*CKK''.E#J
 m#!0!=J,6,B,BE.)(2(:(:E*% "& 	
1 4 H 77 ;; s   )C!!D8DDc                    U R                   S:X  a  U R                  S:X  a  gU R                   S:X  a1  U R                  S:X  a!  U R                  R                  SS 5      S;   a  gg)Ns   UNrU   TrT   ra   )rW   rb   F)rP   rQ   r5   rt   )r(   s    r#   isstreamclonespecr     s`    !!U*z/E/E/N 	""e+""e+""&&y$7;MMr   s,   ^[a-z0-9]+:[0-9a-f]+(,[a-z0-9]+:[0-9a-f]+)*$c           	        / nU GH  nUR                  S5      nU(       dS  [        [         Vs/ s H  ovR                  U5      PM     sn5      (       d   U R                  R                  SU-  5        Mo  UR                  S5      nU(       aC   [        XSS9n	U(       a0  [        U	5      (       d   U R                  R                  SU-  5        M  O'U(       a   U R                  R                  S
U-  5        M  SU;   a6  [        R                  (       d!  U R                  R                  SU-  5        GM-  SU;   aa   [        R                   " US   5      nU R                  R%                  5       nUb*  US-  U:  a!  U R                  R                  SU-  5        GM  SU;   GaO  [&        R)                  US   5      (       d!  U R                  R                  SU-  5        GM  Sn0 nUS   R+                  S5       H  nUR+                  S5      u  nnUU;  a  UUU'   O-UU   U:w  a$  U R                  R                  SUU4-  5        Sn  O[,        R.                  R0                  R                  U5      nUc  M~  [3        U5      U" 5       R4                  S-  :w  a$  U R                  R                  SUU4-  5        Sn  O-US-  nM     US:X  a  U R                  R                  SU-  5        US:X  a  GM  UR7                  U5        GM     U$ s  snf ! [        R                   a>  n
U R                  R                  [        R                  " U
5      S-   5         Sn
A
GMT  Sn
A
f[        R                   a@  n
U R                  R                  S	U[        R                  " U
5      4-  5         Sn
A
GM  Sn
A
ff = f! [        R"                   a#    U R                  R                  SU-  5         GM  f = f)a]  Remove incompatible clone bundle manifest entries.

Accepts a list of entries parsed with ``parseclonebundlesmanifest``
and returns a new list consisting of only the entries that this client
should be able to apply.

There is no guarantee we'll be able to apply all returned entries because
the metadata we use to filter on may be missing or wrong.
r   s8   filtering %s because not a supported clonebundle scheme
r   T)r   s(   filtering %s because not a stream clone
r   Ns1   filtering %s because unsupported bundle spec: %s
s?   filtering %s because cannot determine if a stream clone bundle
s
   REQUIRESNIs'   filtering %s because SNI not supported
s   REQUIREDRAMs0   filtering %s due to a bad REQUIREDRAM attribute
gQ?s8   filtering %s as it needs more than 2/3 of system memory
s   DIGESTs+   filtering %s due to a bad DIGEST attribute
r   r}      :s+   filtering %s due to conflicting %s digests
   s$   filtering %s due to a bad %s digest
r   s-   filtering %s due to lack of supported digest
)rt   anySUPPORTED_CLONEBUNDLE_SCHEMES
startswithr   debugr   r   r
   rk   r   forcebytestrr   r   hassnir   	sizetoint
ParseErrorestimatememorydigest_regexmatchr   urlmoddigesthandlerdigest_algorithmsr   digest_sizer   )r   r    streamclonerequestedpullbundles
newentriesentryr   schemer   r(   r   requiredram	actualram	supportedseendigest_entryalgodigestdigesters                      r#   filterclonebundleentriesr     s    Jii32OP2O^^F#2OP$
 $
 GGMML yy',TE
 (0A*0M0MGGMMDsJ  "GGMM"$'( E!'..GGMMEKLU""nnU>-BC ..0I$T)9K)GP %%eI&677CcI ID %i 0 6 6t <+11$7ft#!'DJ$Z6)GGMMG+& !"I!//AAEEdK#v;(*"8"81"<<GGMM@C;N !"IQ	) !=, >GGMMICO A~% G J E Q* 33 j55a85@A77 "%(**A*A!*D$EF , ## H3N 	s;   L
?L9N3N0 2MN004N++N032O*)O*c                  H    \ rS rSrSrS rS rS rS rS r	S r
S	 rS
 rSrg)clonebundleentryi  zRepresents an item in a clone bundles manifest.

This rich class is needed to support sorting since sorted() in Python 3
doesn't support ``cmp`` and our comparison is complex enough that ``key=``
won't work.
c                    Xl         X l        g r+   )r9   prefers)r1   r9   r   s      r#   __init__clonebundleentry.__init__%  s    
r   c                   U R                    Hr  u  p#U R                  R                  U5      nUR                  R                  U5      nUb
  Uc  XC:X  a    gUb
  Uc  XS:X  a    gUb  Uc  M]  XE:X  a  Md  XC:X  a    gXS:X  a    gMt     g)Nr   r   )r   r9   rt   )r1   otherprefkey	prefvalueavaluebvalues         r#   _cmpclonebundleentry._cmp)  s    "&,,GZZ^^G,F[[__W-F !fn9L !fn9L ~  "" 7 #/> r   c                *    U R                  U5      S:  $ Nr   r   r1   r   s     r#   __lt__clonebundleentry.__lt__K      yy!##r   c                *    U R                  U5      S:  $ r   r   r   s     r#   __gt__clonebundleentry.__gt__N  r   r   c                *    U R                  U5      S:H  $ r   r   r   s     r#   __eq__clonebundleentry.__eq__Q      yy1$$r   c                *    U R                  U5      S:*  $ r   r   r   s     r#   __le__clonebundleentry.__le__T  r   r   c                *    U R                  U5      S:  $ r   r   r   s     r#   __ge__clonebundleentry.__ge__W  r   r   c                *    U R                  U5      S:g  $ r   r   r   s     r#   __ne__clonebundleentry.__ne__Z  r   r   )r   r9   N)rK   rL   rM   rN   __doc__r   r   r   r   r   r   r   r   rS   r&   r   r#   r   r     s0     D$$%%%%r   r   c                   ^ U R                  SS5      mT(       d  [        U5      $ S nT Vs/ s H
  o2" U5      PM     snm[        U4S jU 5       5      nU Vs/ s H  oUR                  PM     sn$ s  snf s  snf )Ns   uis   clonebundleprefersc                    SU ;  a,  [        S5      n[        R                  " [        S5      U -  US9eU R                  SS5      $ )Nrp   s3   each comma separated item should be key=value pairss&   invalid ui.clonebundleprefers item: %s)hintr   )r   r
   Abortr   )rx   r   s     r#   _split&sortclonebundleentries.<locals>._splitc  sH    q=KLD++;<q@t  wwtQr   c              3  <   >#    U  H  n[        UT5      v   M     g 7fr+   )r   ).0vr   s     r#   	<genexpr>)sortclonebundleentries.<locals>.<genexpr>m  s     AA#Aw//s   )
configlistlistrA   r9   )r   r    r   rx   rB   ir   s         @r#   sortclonebundleentriesr   ^  sq    mmE#89GG}  #**'Qvay'*GAAAE"#UGGU## + $s   A2A7)returnr   )r   r   r   r   rJ   )FF).
__future__r   r,   retypingr   r   r   i18nr   
thirdpartyr	   TYPE_CHECKINGr   r
   r   r   r   r   r   r   utilsr   rq   r   CLONEBUNDLESCHEMEr$   r   r   ru   r(   _bundlespeccgversionsre   __annotations__r   rn   rs   rz   r   r   r   compiler   r   r   r   r&   r   r#   <module>r     s   #  	     
  	+ +   	!  $  $  $ R   !      !  !  	u 	u]1H D 1d &<E%B z " 8   )"!  <GT!H  zzIJ <Arj>% >%B$r   