
    6h                       S SK Jr  S SKrS SKrS SKrS SKrS SKrS SKrS SKJr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  SSKJrJrJrJr  SS	KJrJrJrJrJrJrJr J!r!J"r#  SS
K$J%r%  \RL                  " S5      r'Sr(SCS jr)S r*\+" \'S\*5      r,S r-SDS jr.S r/\/" 5       u  r0r1S r2S r3S r4\+" \'SS5      =(       d    \4" 5       r5Sr6Sr7S r8Sr9Sr:S\:S-   -  S-
  r;S r<S r=S  r>\+" \'S!\>5      r>S" r?S# r@/ S$QrAS%rBS&rCS'rD\R                  " S(5      rFS) rGS* rH\R                  " S+S,9 " S- S.5      5       rJ\R                  " S+S/S09 " S1 S5      5       rK\R                  " S+S/S09 " S2 S3\K5      5       rL\R                  " S+S/S09 " S4 S5\K5      5       rMS6 rNS7 rOS8 rP " S9 S:5      rQ " S; S<\Q5      rR " S= S>5      rS " S? S@\#R                  5      rU " SA SB\Q5      rVg)E    )annotationsN)	GeneratorIteratorListOptional   )_)attr)hex)INDEX_HEADERKIND_CHANGELOGKIND_FILELOGKIND_MANIFESTLOG)		changelogerrorfilelogmanifestpolicypycompatrevlogutilvfs)hashutilparsersi@B BaseStoreEntryc                    Uc  gU R                   (       a  U" U R                  5      $ U R                  (       a*  UR                  U R                  R	                  S5      5      $ [
        R                  " SU -  5      e)zparses a fncache entry and returns whether the entry is tracking a path
matched by matcher or not.

If matcher is None, returns TrueT   /s   cannot process entry %r)
is_filelog	target_idis_manifestlogvisitdirrstripr   ProgrammingError)entrymatchers     1/usr/lib/python3/dist-packages/mercurial/store.py_match_tracked_entryr'   :   sf      u''			 6 6t <==

 
 !;e!C
DD    c                f    U R                  SS5      R                  SS5      R                  SS5      $ )a)  
>>> _encodedir(b'data/foo.i')
'data/foo.i'
>>> _encodedir(b'data/foo.i/bla.i')
'data/foo.i.hg/bla.i'
>>> _encodedir(b'data/foo.i.hg/bla.i')
'data/foo.i.hg.hg/bla.i'
>>> _encodedir(b'data/foo.i\ndata/foo.i/bla.i\ndata/foo.i.hg/bla.i\n')
'data/foo.i\ndata/foo.i.hg/bla.i\ndata/foo.i.hg.hg/bla.i\n'
   .hg/   .hg.hg/   .i/   .i.hg/   .d/   .d.hg/replacepaths    r&   
_encodedirr4   Q   s/     	Wj)		#		#r(   	encodedirc                v    SU ;  a  U $ U R                  SS5      R                  SS5      R                  SS5      $ )z
>>> decodedir(b'data/foo.i')
'data/foo.i'
>>> decodedir(b'data/foo.i.hg/bla.i')
'data/foo.i/bla.i'
>>> decodedir(b'data/foo.i.hg.hg/bla.i')
'data/foo.i.hg/bla.i'
r*   r/   r.   r-   r,   r+   r0   r2   s    r&   	decodedirr7   f   s<     dY'	F	#	W	%r(   c               #     #    S V s/ s H  n [        U 5      PM     nn [        S5       Sh  vN   [        SS5       Sh  vN   U Sh  vN   gs  sn f  N( N N7f)zcharacters that are problematic for filesystems

* ascii escapes (0..31)
* ascii hi (126..255)
* windows specials

these characters will be escaped by encodefunctions
z\:*?"<>|    N~      )ordrange)xwinreserveds     r&   	_reservedr@   x   sR      $//;a3q6;K/RyS# 0s=   AAAAA A	A
AAAAc                   ^^^	 Sn [         R                  n[        [        U[	        S5      5      5      n[        [	        [        S5      [        S5      S-   5      5      nU Vs0 s H  oDU_M     snm[        5        H  nSU-  TU" U5      '   M     U[        U 5      /-    H$  nX" U5      R                  5       -   TU" U5      '   M&     0 m	TR                  5        H
  u  pVUT	U'   M     U	4S jmU4S jU4S	 j4$ s  snf )
a  
>>> enc, dec = _buildencodefun()

>>> enc(b'nothing/special.txt')
'nothing/special.txt'
>>> dec(b'nothing/special.txt')
'nothing/special.txt'

>>> enc(b'HELLO')
'_h_e_l_l_o'
>>> dec(b'_h_e_l_l_o')
'HELLO'

>>> enc(b'hello:world?')
'hello~3aworld~3f'
>>> dec(b'hello~3aworld~3f')
'hello:world?'

>>> enc(b'the\x07quick\xADshot')
'the~07quick~adshot'
>>> dec(b'the~07quick~adshot')
'the\x07quick\xadshot'
   _      A   Zr      ~%02xc              3     >#    SnU[        U 5      :  a;  [        SS5       H  n TXX-       v   X-  n  O   [        eU[        U 5      :  a  M:  g g ! [         a     M=  f = f7f)Nr   r      )lenr=   KeyError)sildmaps      r&   decode_buildencodefun.<locals>.decode   sm     #a&j1a[qQU|,,FA	 !  #a&j   s-   !A"AA"A"
AA"AA"c           
        > SR                  [        [        U 5      5       Vs/ s H  nTXUS-       PM     sn5      $ s  snf )Nr(   r   )joinr=   rI   rK   ccmaps     r&   <lambda>!_buildencodefun.<locals>.<lambda>   s5    #((c!fF1Dq1u.FGFs   >c                D   > SR                  [        T" U 5      5      5      $ Nr(   )rR   list)rK   rO   s    r&   rV   rW      s    #((4q	?+r(   )	r   bytechrrZ   mapr=   r<   r@   loweritems)
exchrasciistrcapitalsr>   kvrU   rO   rN   s
          @@@r&   _buildencodefunre      s    0 	ADCeCj)*HE#d)SY]34H"#(QqD(#D[ 1T!W Q DGMMO+T!W ! D

Q  	H+ / $s   "C9c                *    [        [        U 5      5      $ )zr
>>> encodefilename(b'foo.i/bar.d/bla.hg/hi:world?/HELLO')
'foo.i.hg/bar.d.hg/bla.hg.hg/hi~3aworld~3f/_h_e_l_l_o'
)_encodefnamer5   rK   s    r&   encodefilenameri      s    
 	!%%r(   c                *    [        [        U 5      5      $ )zr
>>> decodefilename(b'foo.i.hg/bar.d.hg/bla.hg.hg/hi~3aworld~3f/_h_e_l_l_o')
'foo.i/bar.d/bla.hg/hi:world?/HELLO'
)r7   _decodefnamerh   s    r&   decodefilenamerl      s    
 \!_%%r(   c                 Z  ^ [         R                  n [        S5       Vs0 s H  o" U5      U " U5      _M     snm[        5        H  nSU-  TU " U5      '   M     [        [	        S5      [	        S5      S-   5       H"  nU " U5      R                  5       TU " U5      '   M$     U4S jnU$ s  snf )z
>>> f = _buildlowerencodefun()
>>> f(b'nothing/special.txt')
'nothing/special.txt'
>>> f(b'HELLO')
'hello'
>>> f(b'hello:world?')
'hello~3aworld~3f'
>>> f(b'the\x07quick\xADshot')
'the~07quick~adshot'
rC   rF   rD   rE   r   c                   > SR                  [        R                  " U 5       Vs/ s H  nTU   PM
     sn5      $ s  snf rY   )rR   r   iterbytestrrS   s     r&   lowerencode)_buildlowerencodefun.<locals>.lowerencode   s5    xx(*>*>q*AB*AQa*ABCCBs   ;)r   r[   r=   r@   r<   r]   )r`   r>   rp   rU   s      @r&   _buildlowerencodefunrr      s     D&+Cj1jDGT!Wj1D[ 1T!W 3t9c$i!m,QT!W -D  2s   B(rp   )s   auxs   cons   prns   nul)s   coms   lptc                   [        U 5       H  u  p#U(       d  M  U(       a%  US   S;   a  S[        USS 5      -  USS -   nX0U'   O}UR                  S5      nUS:X  a  [        U5      nUS:X  a  USS [        ;   d%  US	:X  aB  USS	 S
::  a9  USS	 S:  a0  USS [
        ;   a#  S[        USS 5      -  nUSS U-   USS -   nX0U'   US   S;   d  M  USS S[        USS 5      -  -   X'   M     U $ )a  
Encodes filenames containing names reserved by Windows or which end in
period or space. Does not touch other single reserved characters c.
Specifically, c in '\:*?"<>|' or ord(c) <= 31 are *not* encoded here.
Additionally encodes space or period at the beginning, if dotencode is
True. Parameter path is assumed to be all lowercase.
A segment only needs encoding if a reserved name appears as a
basename (e.g. "aux", "aux.foo"). A directory or file named "foo.aux"
doesn't need encoding.

>>> s = b'.foo/aux.txt/txt.aux/con/prn/nul/foo.'
>>> _auxencode(s.split(b'/'), True)
['~2efoo', 'au~78.txt', 'txt.aux', 'co~6e', 'pr~6e', 'nu~6c', 'foo~2e']
>>> s = b'.com1com2/lpt9.lpt4.lpt1/conprn/com0/lpt0/foo.'
>>> _auxencode(s.split(b'/'), False)
['.com1com2', 'lp~749.lpt4.lpt1', 'conprn', 'com0', 'lpt0', 'foo~2e']
>>> _auxencode([b'foo. '], True)
['foo.~20']
>>> _auxencode([b' .foo'], True)
['~20.foo']
r      . rF   r   N   .   rH      9   1   )	enumerater<   findrI   _winres3_winres4)r3   	dotencoderL   nrM   ecs         r&   
_auxencoder      s   , $13q1v;&12.AGtABwFQ1Ra5H,QaFdNaFdNbqEX% AaF+aFRK!AB%'QR5E>fx#af+55DG-  . Kr(   x      rH   c                   [        [        R                  " U 5      R                  5       5      n[	        U SS  5      R                  S5      n[        X15      nUS   n[        R                  R                  U5      u  pg/ nSn	US S  H_  n
U
S [         nUS   S;   a  US S S-   nU	S:X  a  [        U5      nOU	S-   [        U5      -   nU[        :  a    OUR                  U5        Un	Ma     SR                  U5      n[        U5      S:  a  US-  nSU-   U-   U-   n[        [        U5      -
  nUS:  a  US U nSU-   U-   U-   U-   nU$ )	N   r   rv   r   rt   rB   r   s   dh/)r   r   sha1digestrp   splitr   osr3   splitext_dirprefixlenrI   _maxshortdirslenappendrR   _maxstorepathlen)r3   r   r   lepartsbasename_rootextsdirssdirslenpdtdirsres	spaceleftfillers                    r&   _hashencoder   )  sU   t$++-.F	T!"X		$	$T	*Br%ERyH!!(+JEEH3BZn}R5E>#2Aq=AA1s1v%A##Q  99UD
4y1}
4-&
 3
&C 3s8+I1}*9%tmf$v-3Jr(   c                    [        U 5      n [        U 5      R                  S5      nSR                  [	        X!5      5      n[        U5      [        :  a  [        X5      nU$ )a	  encodes path with a length limit

Encodes all paths that begin with 'data/', according to the following.

Default encoding (reversible):

Encodes all uppercase letters 'X' as '_x'. All reserved or illegal
characters are encoded as '~xx', where xx is the two digit hex code
of the character (see encodefilename).
Relevant path components consisting of Windows reserved filenames are
masked by encoding the third character ('aux' -> 'au~78', see _auxencode).

Hashed encoding (not reversible):

If the default-encoded path is longer than _maxstorepathlen, a
non-reversible hybrid hashing of the path is done instead.
This encoding uses up to _dirprefixlen characters of all directory
levels of the lowerencoded path, but not more levels than can fit into
_maxshortdirslen.
Then follows the filler followed by the sha digest of the full path.
The filler is the beginning of the basename of the lowerencoded path
(the basename is everything after the last path separator). The filler
is as long as possible, filling in characters from the basename until
the encoded path has _maxstorepathlen characters (or all chars of the
basename have been taken).
The extension (e.g. '.i' or '.d') is preserved.

The string 'data/' at the beginning is replaced with 'dh/', if the hashed
encoding was used.
r   )r5   rg   r   rR   r   rI   r   r   )r3   r   efr   s       r&   _hybridencoder   I  sQ    > T?D	d		!	!$	'B
))Jr-
.C
3x""$*Jr(   c                   [        U 5      n[        U 5      [        :  a  [        US5      $ [	        U5      R                  S5      nSR                  [        US5      5      n[        U5      [        :  a  [        US5      $ U$ )NTr   )r5   rI   r   r   rg   r   rR   r   )r3   der   r   s       r&   _pathencoder   p  sn    	4B
4y##2t$$	b				%B
))Jr4(
)C
3x""2t$$Jr(   
pathencodec                    [        U S5      $ NF)r   fs    r&   _plainhybridencoder   ~  s    E""r(   c                     U R                  5       R                  nS[        R                  ) -  SU-  :X  a  S nU$ ! [         a    S n U$ f = f)Ni  )statst_moder   umaskOSError)r   modes     r&   	_calcmoder     sV    xxz!!TZZKUT\2D K  Ks   7; A
A)	   bookmarks
   narrowspec   data   meta   00manifest.d   00manifest.i   00changelog.d   00changelog.i
   phaseroots   obsstore   requires)   .i   .idx   .d   .dat   .n   .nd   .sda)r   r   r   r   )r   r   s   .*undo\.[^/]+\.(nd?|i)$c                d    U[         R                  :w  a  gU R                  [        5      (       a  gg)NFT)r   S_IFREGendswithREVLOG_FILES_EXT)r   kindsts      r&   	is_revlogr     s'    t||zz"##r(   c                :    U R                  [        5      (       a  ggNTF)r   r   r   s    r&   is_revlog_filer     s    zz"##r(   T)slotsc                      \ rS rSrSr\R                  " 5       r\R                  " SS9r\R                  " SS9r	Sr
S r\S 5       rS rS	rg)
	StoreFilei  za file matching a store entryNdefaultFc                8   U R                   c`  Uc&  SnX R                  -  n[        R                  " U5      e UR	                  U R                  5      R
                  U l         U R                   $ U R                   $ ! [         a    SU l          U R                   $ f = f)Ns1   calling vfs-less file_size without prior call: %sr   )
_file_sizeunencoded_pathr   r#   r   st_sizeFileNotFoundError)selfr   msgs      r&   	file_sizeStoreFile.file_size  s    ??"{J***,,S11$"%((4+>+>"?"G"G t % $"#$s   *A: :BBc                    U R                   S L$ Nr   r   s    r&   has_sizeStoreFile.has_size  s    d**r(   c                   ^ ^^^ T R                  S5      mU UUU4S jnU" 5       n[        U5        T R                  UT4$ )zfreturn data "stream" information for this file

(unencoded_file_path, content_iterator, content_size)
Nc               3    >#    TR                  TR                  5      n TR                  U 5       nS v   TS::  a  UR                  T5      v   O[        R
                  " UTS9 S h  vN   S S S 5        g  N! , (       d  f       g = f7f)N   limit)rR   r   openreadr   filechunkiter)r3   fpr   sizer   	volatiless     r&   
get_stream(StoreFile.get_stream.<locals>.get_stream  sn     88D//0D%
5=''$-'#11"DAAA &%
 B &%s.   -B7A7'A5(A7,	B5A77
BB)r   nextr   )r   r   r   r   rK   r   s   ```  @r&   r   StoreFile.get_stream  sB    
 ~~d#	B 	B LQ##Q--r(   r   )__name__
__module____qualname____firstlineno____doc__r
   ibr   r   is_volatileoptionalr   propertyr   r   __static_attributes__ r(   r&   r   r     sQ    'WWYN&J''%(K H
 + +.r(   r   F)r   initc                  @    \ rS rSrSrSrS	S jr     S
S jrS rSr	g)r   i  z]An entry in the store

This is returned by `store.walk` and represent some data in the store.Tc                    [         er   )NotImplementedErrorr   s    r&   filesBaseStoreEntry.files  s    !!r(   Nc                t    Uc   eU R                  5        Vs/ s H  ofR                  X#5      PM     sn$ s  snf )u   return a list of data stream associated to files for this entry

return [(unencoded_file_path, content_iterator, content_size), …]
)r   r   )r   repor   r   max_changesetpreserve_file_countr   s          r&   get_streamsBaseStoreEntry.get_streams  s3     6:jjlClS,lCCCs   5c                    U R                   (       aL  U R                  5        H7  nUR                  (       d  M  U" UR                  UR                  5      5        M9     gg)zUse a VolatileManager to preserve the state of any volatile file

This is useful for code that need a consistent view of the content like stream clone.
N)maybe_volatiler   r   rR   r   )r   r   r   r   s       r&   preserve_volatiles!BaseStoreEntry.preserve_volatiles  sB    
 ZZ\===chhq'7'789 " r(   r   returnzList[StoreFile]NNNNF)
r   r   r   r   r   r	  r   r  r
  r   r   r(   r&   r   r     s0    N N"
 !D:r(   c                     ^  \ rS rSrSrSr\R                  " 5       r\R                  " 5       r	\R                  " SS9r
\R                  " SS9r\R                  " SS9r  S	U 4S jjrS
S jrSrU =r$ )SimpleStoreEntryi  zA generic entry in the storeFr   Nc                `   > [         TU ]  5         Xl        X l        X0l        S U l        X l        g r   )super__init___entry_path_is_volatiler   _filesr	  )r   
entry_pathr   r   	__class__s       r&   r  SimpleStoreEntry.__init__'  s.     	%'#)r(   c                    U R                   c/  [        U R                  U R                  U R                  S9/U l         U R                   $ )N)r   r   r   )r  r   r  r   r  r   s    r&   r   SimpleStoreEntry.files4  sB    ;;#'#3#3"oo $ 1 1DK {{r(   )r  r   r  r  r	  )FNr  )r   r   r   r   r   r   r
   r   r	  r  r  r   r  r  r   r   __classcell__r  s   @r&   r  r    sb    &IWWYN'')K775)L&JWWT"F
 	*	 	r(   r  c                  P  ^  \ rS rSrSrSr\R                  " SS9r\R                  " SS9r	\R                  " SS9r
\R                  " SS9r\R                  " SS9r\R                  " SS9rU 4S jr\S 5       r\S 5       r\S	 5       rS
 rSS jr     SU 4S jjrS rSrU =r$ )RevlogStoreEntryi@  zA revlog entry in the storeTNr   c                   > [         TU ]  5         Xl        X0l        X l        SU;   d   X$45       eU H&  nUR                  [        5      (       d  M  SU l          O	   SU l        X@l        S U l	        g )Nr   TF)
r  r  revlog_typer   _path_prefixr   REVLOG_FILES_VOLATILE_EXTr	  _detailsr  )r   r!  path_prefixr   detailsr   r  s         r&   r  RevlogStoreEntry.__init__M  sr     	&"'7+!77C||566&*# 
 #(Dr(   c                (    U R                   [        :H  $ r   )r!  r   r   s    r&   is_changelogRevlogStoreEntry.is_changelogb  s    >11r(   c                (    U R                   [        :H  $ r   )r!  r   r   s    r&   r    RevlogStoreEntry.is_manifestlogf  s    #333r(   c                (    U R                   [        :H  $ r   )r!  r   r   s    r&   r   RevlogStoreEntry.is_filelogj  s    <//r(   c                     U R                   S-   $ )z&unencoded path of the main revlog filer   )r"  r   s    r&   main_file_pathRevlogStoreEntry.main_file_pathn  s      5((r(   c                4   U R                   c  / U l         [        U R                  [        S9 H]  nU R                  U-   nU R                  U   nUR                  [        5      n[        X#U5      nU R                   R                  U5        M_     U R                   $ )N)key)	r  sortedr$  _ext_keyr"  r   r#  r   r   )r   r   r3   r   volatiler   s         r&   r   RevlogStoreEntry.filesr  s    ;;DKdmm:((3. MM#.	 <<(ABdx8""1% ; {{r(   c                  >^^ [        S U R                  5        5       5      nU(       aV  UbB  Ub?  [        S U R                  R	                  5        5       5      (       d  SU R                  ;   a  [
        TU ]  UUUUUS9$ U(       d  U R                  5        Vs/ s H6  nUR                  R                  S5      (       a  M%  UR                  X#5      PM8     nnU R                  U5      R                  5       n	U	R                  U5      n
UR                  U
5        U$ 0 nU R                  5        H   nUR                  S 5      XR                  '   M"     U R                  5        Vs/ s H6  nUR                  R                  S5      (       a  M%  UR                  X#5      PM8     nnU R                  S-   nS m U" U5      mTR                  [         R"                  5      n[$        R&                  R)                  U5      (       a3  X   mUU4S jnU" 5       n[+        U5        S mUR-                  XT45        OU R                  U5      R                  5       n	U	R                  USS	9n
U
 HV  u  nnmUR/                  US
5      T:w  d  M  [1        S5      nUUR/                  US
5      TU4-  n[2        R4                  " U5      e   UR                  U
5        Tb  TR7                  5         U R                  5       n[9        U5      [9        U5      :X  d   UUU R                  U R:                  45       eU$ s  snf s  snf ! Tb  TR7                  5         f f = f)Nc              3  8   #    U  H  oR                   v   M     g 7fr   )r   .0r   s     r&   	<genexpr>/RevlogStoreEntry.get_streams.<locals>.<genexpr>  s     9Lq

Ls   c              3  B   #    U  H  oR                  S 5      v   M     g7f)r   Nr   )r;  rc   s     r&   r<  r=    s     E0D1::g&&0Ds   r   )r  r   r   r  r  )r   r   r   c               3     >#    Tn  U R                  S5        S v   TS::  a  U R                  T5      v   O[        R                  " U TS9 S h  vN   U R	                  5         g  N! U R	                  5         f = f7f)Nr   r   r   )seekr   r   r   close)r   
index_filer   s    r&   r   0RevlogStoreEntry.get_streams.<locals>.get_stream  sd     #B#
"
5="$''$-/'+'9'9"D'III
 J
s/   A;AA& A$A& A;$A& &A88A;T)force_inliner   s(   expected %d bytes but %d provided for %s)allr   anyr$  keysr  r  r   r   r   get_revlog_instance
get_revlogextendr   r"  r   r   r   	revlogmodr   is_inline_indexr   r   getr	   r   AbortrB  rI   r   )r   r  r   r   r  r  	pre_sizedr   streamrl	rl_streamname_to_size
index_pathheaderr   rK   namer   r   rC  r   r  s                      @@r&   r  RevlogStoreEntry.get_streams  s    9DJJL99	L$E0B0B0DEEE%7&#+$7 '   % %A''00@ -S,%  
 ))$/::<B}5IMM)$MA-.[[->L))* 
 ZZ\
!##,,U3 )ALL(! 	 
 &&.

"	#ZJ__\%6%67F//77#/
# LQ!
zd34--d3>>@NN=tNL	%.MD!T#''a0D8 KL|//a8$DD#kk#..	 &/
 i(%  "

6{c%j( 	
NN	+
 	
( E
T %  " &s,   $L+L+$$L0L05C
L5 AL5 5Mc                H   U R                   (       a   [        R                  " UR                  5      $ U R                  (       a6  U R                  n[
        R                  " UR                  UR                  US9$ [        R                  " UR                  U R                  5      $ )zbObtain a revlog instance from this store entry

An instance of the appropriate class is returned.
)tree)	r)  r   svfsr    r   r   manifestrevlognodeconstantsr   )r   r  mandirs      r&   rI  $RevlogStoreEntry.get_revlog_instance  ss    
 &&tyy11  ^^F**""DIIF  ??499dnn==r(   )r$  r  r"  r	  r!  r   r  r  )r   r   r   r   r   r   r
   r   r!  r   r	  r"  r$  r  r  r   r)  r    r   r0  r   r  rI  r   r  r  s   @r&   r  r  @  s    %I''$'K%IWWT*N774(Lwwt$HWWT"F* 2 2 4 4 0 0)$ ![z> >r(   r  c                    [         R                  " [        5      nU  H  u  p#[        U5      u  pEX1U   U'   M     [	        UR                  5       5      $ )zgroup files per revlog prefix

The returns a two level nested dict. The top level key is the revlog prefix
without extension, the second level is all the file "suffix" that were
seen for this revlog and arbitrary file data as value.
)collectionsdefaultdictdict_split_revlog_extr4  r^   )
files_datarevlogsuvaluerW  r   s         r&   _gather_revlogri    sK     %%d+G%a(	"c  '--/""r(   c                t    U R                  [        5      (       a  SnOSnU R                  U5      nU SU XS 4$ )z8split the revlog file prefix from the variable extension   -ru   N)r   REVLOG_FILES_LONG_EXTrfind)filenamecharidxs      r&   rd  rd    sA    .//
..
CDS>8D>))r(   c                    U R                  S5      (       a  SU 4$ U R                  S5      (       a  SU 4$ U R                  S5      (       a  SU 4$ U R                  S5      (       a  SU 4$ S	U 4$ )
zFa key to order revlog suffix

important to issue .i after other entry.r   r   r   
   r      r   2   (   r?  )r   s    r&   r5  r5    sq    
 ||E3x	f		Cy	e		Cy	e		CyCyr(   c                      \ rS rSrSrS rS rSS jrSS jrSS jr	 S SS	 jjr
 S SS
 jjr S SS jjrS rS rS rS rS rSrg)
basicstorei  z&base class for local repository storesc                    U" U5      nUR                   U l        [        U5      U l        U R                  Ul        X0l        [
        R                  " U[        5      U l        U R                  U l	        g r   )
baser3   r   
createmoderawvfsvfsmod	filtervfsr5   r   openerr   r3   vfstyper   s       r&   r  basicstore.__init__  sP    dmHH	#C.##C3hhr(   c                8    U R                   S-   [        U5      -   $ Nr   )r3   r5   r   r   s     r&   rR   basicstore.join$  s    yy4)A,..r(   Nc                v   U R                   nU(       a  USU-   -  n[        U R                   5      S-   n/ nU R                  R                  U5      (       a  U/nU R                  R                  nU(       a  UR                  5       n	U" U	SS9 H  u  pnU	S-   U
-   n[        XU5      (       a@  [        R                  " XS 5      nUR                  [        U5      UR                  45        M_  U[        R                  :X  d  Mu  U(       d  M~  UR                  U5        M     U(       a  M  UR                  5         U$ )z%yields (revlog_type, unencoded, size)r   r   T)r   N)r3   rI   r{  isdirreaddirpopr   r   pconvertr   r7   r   r   S_IFDIRsort)r   relpathrecurseundecodabler3   striplenrM   visitr  r   r   r   r   r   r   s                  r&   _walkbasicstore._walk'  s    yyD7N"Dtyy>A%;;T""FEkk))GIIK#*14#8KARTAB "-- MM"Y-8)A,

!;<-''R( $9 % 	
r(   c                B    [         R                   " U R                  UUS9$ )N)
trypendingconcurrencychecker)r   r   )r   r  r  s      r&   r   basicstore.changelog>  s"    ""HH!1
 	
r(   c                    [         R                  " UR                  U R                  5      n[         R                  " U R                  XU5      $ r   )r   r\  r]  r   manifestlog)r   r  storenarrowmatch	rootstores       r&   r  basicstore.manifestlogE  s8    ++D,>,>I	##DHHd?OPPr(   c           	   #  &  #    S[         S4S[        S4/nU Hu  u  pEnU R                  USUS9n[        U5       HO  u  pUR	                  SS5      S   n
U(       a   SU;   a  U
R                  SS5      S   n
U
S-  n
[        UUU
U	S	9v   MQ     Mw     g
7f)a  Like walk, but excluding the changelog and root manifest.

When [undecodable] is None, revlogs names that can't be
decoded cause an exception. When it is provided, it should
be a list and the filenames that can't be decoded are added
to it instead. This is very rarely needed.r   Fr   Tr  r   r   r   r%  r!  r   r&  N)r   r   r  ri  r   rsplitr  )r   r%   r  r   base_dirrl_typestrip_filenamer   r   r&  revlog_target_ids              r&   data_entriesbasicstore.data_entriesI  s      lE*&-
 26-H~JJx;JGE#1%#8#)<<a#8#; !dfn'7'>'>tQ'G'J$$,$& & '.#	  $9 26s   BBc           	   #  0  #    U(       a,  U R                   R                  S5      (       a  [        SSS9v   U(       a,  U R                   R                  S5      (       a  [        SSS9v   [        U R	                  SS5      5      n[
        R                  " [        5      n[
        R                  " [        5      nU Hj  u  pgUR                  S5      (       a  [        U5      u  pXtU   U	'   M1  UR                  S5      (       a  [        U5      u  pXuU   U	'   M]  [        USUS	9v   Ml     U[        4U[        4/n
[        U5      S
::  d   e[        U5      S
::  d   eU
 H5  u  p[        UR                  5       5       H  u  p[        UUSUS9v   M     M7     g 7f)Nr   T)r  r   r   r(   Fs   00changelogs
   00manifest)r  r   r   r   r  )r   existsr  reversedr  ra  rb  rc  
startswithrd  r   r   rI   r4  r^   r  )r   phaseobsolescencer   
changelogsmanifestlogsrg  rK   rW  r   top_rldatar!  r   r&  s                  r&   top_entriesbasicstore.top_entriesd  s     TXX__]33"(  
 DHHOOK88"&  
 C/0 ,,T2
"..t4DA||N++-a0	()4 %m,,-a0	*+T"3'&  %   +,(
 < A%%%:!###!'D#)$**,#7& & +!#	  $8 "(s   FFc              #  t   #    U R                  U5       Sh  vN   U R                  X#S9 Sh  vN   g N N7f)zreturn files related to data storage (ie: revlogs)

yields instance from BaseStoreEntry subclasses

if a matcher is passed, storage files of only those tracked paths
are passed with matches the matcher
N)r  r  )r  r  )r   r%   r  r  s       r&   walkbasicstore.walk  s:      $$W---##%#KKK 	.Ks   848688c                    [         $ r   _datar   s    r&   copylistbasicstore.copylist  s    r(   c                    g r   r   r   trs     r&   writebasicstore.write      r(   c                    g r   r   r   s    r&   invalidatecachesbasicstore.invalidatecaches  r  r(   c                    g r   r   r   fns     r&   markremovedbasicstore.markremoved  r  r(   c                    SR                  SU45      nU R                  R                  US-   5      (       a  gUR                  S5      (       d  US-   nU R                  R                  U5      $ )!Checks if the store contains pathr   r   r   T)rR   r   r  r   r   r3   s     r&   __contains__basicstore.__contains__  sY    yy'4)88??4%<((}}T""$;Dxxt$$r(   rz  r~  r3   r{  r   r   )r  zmanifest.manifestlogNNr  z%Generator[BaseStoreEntry, None, None])FF)NFF)r   r   r   r   r   r  rR   r  r   r  r  r  r  r  r  r  r  r  r   r   r(   r&   rw  rw    sq    0/.
Q
 )-	.8 ).0	.0f 7<L	.L	%r(   rw  c                  V   ^  \ rS rSrS rSU 4S jjr S	 S
U 4S jjjrS rS rSr	U =r
$ )encodedstorei  c                    U" US-   5      nUR                   U l        [        U5      U l        U R                  Ul        X0l        [
        R                  " U[        5      U l        U R                  U l	        g )N   /store)
ry  r3   r   rz  r{  r|  r}  ri   r   r~  r  s       r&   r  encodedstore.__init__  sV    dY&'HH	#C.##C8hhr(   c                  > [         T
U ]  X5      n/ nU H#  u  pg [        U5      nUR                  X45        M%     U$ ! [         a<    Uc$  [	        S5      U-  n	[
        R                  " U	5      eUR                  U5         Mn  f = f)Ns   undecodable revlog name %s)r  r  rl   rJ   r	   r   StorageErrorr   )r   r  r  r  oldnewf1rh  f2r   r  s             r&   r  encodedstore._walk  s    gmG-IB#B' JJ{#  
  &9:R?C,,S11&&r*s   >ABBc              #  f   >#    [         TU ]  US9nU H  n[        XA5      (       d  M  Uv   M     g 7f)Nr  )r  r  r'   )r   r%   r  entriesr$   r  s        r&   r  encodedstore.data_entries  s4      '&;&?E#E33 s   !1	1c                8    U R                   S-   [        U5      -   $ r  )r3   ri   r  s     r&   rR   encodedstore.join  s    yy4."333r(   c                J    SS/[          Vs/ s H  nSU-   PM
     sn-   $ s  snf )Nr   r      store/r  r  s     r&   r  encodedstore.copylist  s)    -.1OA)a-1OOO1Os    r  r   r  r  )r   r   r   r   r  r  r  rR   r  r   r  r  s   @r&   r  r    s5    " )-	. 4P Pr(   r  c                  h    \ rS rSrS r\S 5       rSS jrSS jrS r	S r
S	 rS
 rS rS rS rSrg)fncachei  c                h    Xl         [        5       U l        S U l        SU l        [        5       U l        g r   )r   set_ignoresr  _dirtyaddls)r   r   s     r&   r  fncache.__init__  s'    U
r(   c                    U R                   S L$ r   )r  r   s    r&   	is_loadedfncache.is_loaded  s    ||4''r(   Nc                J    U R                   (       d  U R                  U5        gg)zread the fncache file if not already read.

If the file on disk is corrupted, raise. If warn is provided,
warn and keep going instead.N)r  _load)r   warns     r&   ensureloadedfncache.ensureloaded  s    
 ~~JJt r(   c           	        SU l          U R                  SSS9n[        5       U l        Sn[        [        R                  " UR                  [        5      S5       HX  nX4-  n UR                  S5      nU R                  R                  [        USUS-    5      R                  5       5        X5S-   S nMZ     U(       a<  [        S	5      nU(       a  U" US-   5        O[         R"                  " U[        S
5      S9eU R%                  X!5        UR'                  5         g! [         a    [        5       U l         gf = f! [         a     M  f = f)z&fill the entries from the fncache fileF   fncache   rb)r   Nr(      
r   s$   fncache does not ends with a newlines3   use 'hg debugrebuildfncache' to rebuild the fncache)hint)r  r   r   r  r  iter	functoolspartialr   fncache_chunksizerindexupdater7   
splitlines
ValueErrorr	   r   rO  _checkentriesrB  )r   r  r   chunkrT   r   r   s          r&   r  fncache._load  s0   	*51B ui''1BCSIAJELL'##IeGa!en$=$H$H$JK!eg J ;<CS5[!kk/  	2$

?  	5DL	   s$   D !AD9D65D69
EEc                   SU R                   ;   aw  UR                  S5        [        U5       HV  u  p4UR                  S5      (       a  M  [	        S5      US-   -  nU(       a  U" US-   5        MB  [
        R                  " U5      e   gg)z-make sure there is no empty string in entriesr(   r   r  s!   invalid entry in fncache, line %dr   N)r  rA  r{   r"   r	   r   rO  )r   r   r  r   liner   s         r&   r  fncache._checkentries"  sm    $,,GGAJ$R={{5))>?1q5IAQY#kk!n, ) r(   c                   U R                   (       a  U R                  (       d   eU R                  U R                  -  U l        [	        5       U l        UR                  S5        U R                  SSSS9nU R                  (       a6  UR                  [        SR                  U R                  5      S-   5      5        UR                  5         SU l         U R                  (       a  UR                  S5        U R                  SSSS9nU R                  (       a6  UR                  [        SR                  U R                  5      S-   5      5        UR                  5         S U l        [	        5       U l        g g )Nr  s   wbT)r   
atomictempr  Fs   ab)r  r  r  r  r  	addbackupr   r  r5   rR   rB  )r   r  r   s      r&   r  fncache.write.  s    ;;>>!><<$**4DLDJLL$*5TBB||5::dll#;e#CDEHHJDK::LL$*5TBBzz5::djj#9E#ABCHHJDLDJ r(   c                :    U R                   R                  U5        g r   )r  addr  s     r&   	addignorefncache.addignoreC  s    "r(   c                    XR                   ;   a  g U R                  (       d  U R                  5         XR                  ;  a  U R                  R                  U5        g g r   )r  r  r  r  r  r  r  s     r&   r  fncache.addF  s>    ~~JJL\\!JJNN2 "r(   c                   U R                   (       d  U R                  5         XR                  ;   a  U R                  R                  U5        g  U R                  R                  U5        SU l        g ! [         a     g f = fNT)r  r  r  remover  r  rJ   r  s     r&   r  fncache.removeN  sa    ~~JJLJJb!	LL#DK 		s   "A1 1
A>=A>c                    XR                   ;   a  gU R                  (       d  U R                  5         XR                  ;   $ r  )r  r  r  r  r  s     r&   r  fncache.__contains__Z  s,    ~~JJL\\!!r(   c                    U R                   (       d  U R                  5         [        U R                  U R                  -  5      $ r   )r  r  r  r  r  r   s    r&   __iter__fncache.__iter__a  s*    ~~JJLDLL4::-..r(   )r  r  r  r  r   r   )r   r   r   r   r  r   r  r  r  r  r  r  r  r  r  r  r   r   r(   r&   r  r    sI     ( ($L
-*
"/r(   r  c                  4    \ rS rSrS rSS jrS	S jrS rSrg)
_fncachevfsig  c                t    [         R                  R                  X5        X l        X0l        U[
        L U l        g r   )r|  proxyvfsr  r  encoder   uses_dotencode)r   r   fncr  s       r&   r  _fncachevfs.__init__h  s+      + #$3r(   c                   U R                  U5      nUS;  a  UR                  S5      (       d  UR                  S5      (       a  [        U5      (       a  U R                  R                  (       + =(       aG    U R
                  R                  U5      =(       a%    U R
                  R                  U5      R                  nU(       d  U R                  R                  U5        U R
                  " XR/UQ70 UD6$ )N)   rr     data/   meta/)
r  r  r   r  r  r   r  r   r   r  )r   r3   r   argskwencodednotloads          r&   __call___fncachevfs.__call__n  s    ++d#%**dooh.G.Gt$$ ,,000  ( 3HHMM'*22    &xx3333r(   c                   ^  U 4S jU 5       nU(       a,  T R                   R                  " T R                  U5      /UQ76 $ T R                   R                  " U/UQ76 $ )Nc              3  F   >#    U  H  nTR                  U5      v   M     g 7fr   )r  )r;  r   r   s     r&   r<  #_fncachevfs.join.<locals>.<genexpr>  s     37a4;;q>>7s   !)r   rR   r  )r   r3   insidefs   `  r&   rR   _fncachevfs.join  sI    37388==T!2=W==88==000r(   c                    UR                  S5      (       d  UR                  S5      (       a  U R                  R                  U5        gg)z1generic hook point to lets fncache steer its stewr%  r&  N)r  r  r  r  s     r&   register_file_fncachevfs.register_file  s7    ??8$$(A(ALLT" )Br(   )r  r  r   N)r$  )r3   zOptional[bytes]r0  bytesr  r5  )	r   r   r   r   r  r+  rR   r3  r   r   r(   r&   r  r  g  s    44(1#r(   r  c                  \    \ rS rSrS rS rS r S SS jjrS rS r	S	 r
S
 rS rS rSrg)fncachestorei  c                L   U(       a  [         nO[        nX@l        U" US-   5      nUR                  U l        U R                  S-   U l        [        U5      U l        U R                  Ul        XPl        [        U5      nX`l	        [        XVU5      U l        U R                  U l        g )Nr  r   )r   r   r  ry  r3   pathsepr   rz  r{  r  r  r   r~  )r   r3   r  r   r  r   r!  s          r&   r  fncachestore.__init__  s     F'FdY&'HH	yy4'#C.cls0hhr(   c                >    U R                   U R                  U5      -   $ r   )r9  r  r  s     r&   rR   fncachestore.join  s    ||dkk!n,,r(   c                L    U R                   R                  U5      R                  $ r   )r{  r   r   r  s     r&   getsizefncachestore.getsize  s    {{%---r(   Nc              #    #    S U R                    5       n[        U5      nU H  u  pVUR                  S5      (       a  [        nUR	                  SS5      S   nOQUR                  S5      (       a4  [
        nUR	                  SS5      S   n	U	R                  SS5      S   S-   nO U5       e[        UUUUS9n
[        X5      (       d  M  U
v   M     g 7f)Nc              3  N   #    U  H  n[        U5      (       d  M  US 4v   M     g 7fr   )r   r:  s     r&   r<  ,fncachestore.data_entries.<locals>.<genexpr>  s     FLqN14E!TLs   %%r%  r   r   r&  r   r  )	r  ri  r  r   r   r   r  r  r'   )r   r%   r  r   	by_revlogr   r&  r  r  tmpr$   s              r&   r  fncachestore.data_entries  s      GDLLF"5)	(OF  **&#)<<a#8#; ""8,,*ll4+A.#&::dA#6q#9D#@  %f$u$"#*	E $E33'  )s   CC		Cc                F    SnSS/U Vs/ s H  nSU-   PM
     sn-   $ s  snf )N)r   r   r   r   s   dhr  r   r   r   r   r   r   r   r   r   r  r   )r   r   r   s      r&   r  fncachestore.copylist  s2    
 -.1KA)a-1KKK1Ks   c                :    U R                   R                  U5        g r   )r  r  r  s     r&   r  fncachestore.write  s    2r(   c                X    S U R                   l        [        5       U R                   l        g r   )r  r  r  r  r   s    r&   r  fncachestore.invalidatecaches  s    # Ur(   c                :    U R                   R                  U5        g r   )r  r  r  s     r&   r  fncachestore.markremoved  s    Br(   c                j    U R                  U5      n U R                  U5        g! [         a     gf = fr   )r  r>  r   )r   r   r   s      r&   _existsfncachestore._exists  s5    [[^	LL  		s   % 
22c                <   SR                  SU45      nUS-   nX R                  ;   a  U R                  U5      (       a  gUR                  S5      (       d  US-  nU R                   H3  nUR	                  U5      (       d  M  U R                  U5      (       d  M3    g   g)r  r   r   r   TF)rR   r  rO  r   r  )r   r3   r_   s      r&   r  fncachestore.__contains__  s    yy'4)5La}}T""DLDA||D!!dll1oo  r(   )rz  r  r  r~  r3   r9  r{  r   r  r  )r   r   r   r   r  rR   r>  r  r  r  r  r  rO  r  r   r   r(   r&   r7  r7    sB    "-. )-	.:L$# r(   r7  )r$   r   )r  zIterator[int])W
__future__r   ra  r  r   rer   typingr   r   r   r   i18nr	   
thirdpartyr
   TYPE_CHECKINGnoder   revlogutils.constantsr   r   r   r    r   r   r   r   r   r   r   rL  r   r   r|  utilsr   	importmodr   r  r'   r4   getattrr5   r7   r@   re   rg   rk   ri   rl   rr   rp   r}   r~   r   r   r   r   r   r   r   r   r   r  r   rl  r#  compileEXCLUDEDr   r   rK   r   r   r  r  ri  rd  r5  rw  r  r  r  r  r7  r   r(   r&   <module>ra     s`   #   	 	      
  
 
 
 


9
%  E.$ G[*5	$7t -. l&&2 g}d3M7K7M ,-`  )*Q. @$N g|[9#		   , 
 ::12 d,. ,. ,.^ d!: !:  !:H d!~ !  !H dk>~ k>  k>\#*"a% a%H&P: &PR/ /D&#&// &#Rf: fr(   