
    6hg                   &   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JrJrJ	r	J
r
JrJrJrJrJrJrJr  SSKJr  SSKJr  SSK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&  SS
K'J(r)  \RT                  (       a  S SKJ+r+  \!RX                  " S5      r-\$R\                  r.Sr/S:S jr0S r1 " S S5      r2 " S S5      r3S;S jr4S r51 Skr6 " S S5      r7 \-Rp                  r9 " S S\&Rv                  5      r< S<         S=S jjr=S>S jr>      S?S jr?S@S jr@S rA " S  S!\&Rv                  5      rB " S" S#\$R                  5      rDS$rE " S% S&\F5      rG " S' S(\&R                  5      rI\S)   rJ\\<\B4   rK " S* S+\&R                  5      rM " S, S-\&R                  5      rO " S. S/\&R                  5      rQ " S0 S1\&R                  5      rR " S2 S3\&R                  5      rS " S4 S5\B5      rT " S6 S7\S5      rU " S8 S9\I5      rVg! \: a    \7r9 GN,f = f)A    )annotationsN)Callable
CollectionDictIterableIteratorListOptionalSetTupleUnioncast   )_)MatcherT)binhexnullrev)	encodingerrormatchmdiffpathutilpolicypycompatrevlogutil)
repository)	constants)
ByteStringparsersi  c              #  Z  #    U(       a  USS  S:w  a  [        S5      eS nUR                  5        Hv  nUb  X#:  a  [        S5      eUnUR                  S5      u  pE[        U5      nUSS  nU[        ;   a  US S nUS-  nOSnUSU -  :w  a  [        S	5      eU[        U5      U4v   Mx     g 7f)
N   
"   Manifest did not end in a newline.#   Manifest lines not in sorted order.    r             Invalid manifest line)
ValueError
splitlinessplitlen_manifestflagsr   )nodelendataprevlfnnlflagss           4/usr/lib/python3/dist-packages/mercurial/manifest.py_parser9   F   s      RS	U">??D__CDDwwu~V"#N"#2A!GBEW566Q s   B)B+c                    / n/ nU  H7  u  p4nUR                  U5        UR                  SU[        U5      U4-  5        M9     [        U5        SR                  U5      $ )N   %s %s%s
r(   )appendr   _checkforbiddenjoin)itfileslinesr4   r5   fls         r8   _textrC   a   sZ    EEbQ 	]aQ_45	  E88E?r(   c                  6    \ rS rSrSS jrSS jrS	S jr\rSrg)
lazymanifestitern   c                    SU l         Xl        g Nr   )poslmselfrJ   s     r8   __init__lazymanifestiter.__init__o   s    r(   c                    U $ N rL   s    r8   __iter__lazymanifestiter.__iter__s       r(   c                l    U R                   R                  U R                  5      u  pUS:X  a1  [        U[        5      (       d   eU =R                  S-  sl        US   $ [        U[        5      (       d   eU =R                  S-  sl        UR                  SU5      nXU $ ! [         a    [        ef = f)Nr#   r   r   r'   )	rJ   _getrI   
IndexErrorStopIteration
isinstancetuplebytesfind)rL   r1   rI   zeroposs       r8   nextlazymanifestiter.nextv   s    	 TXX.ID "9dE****HHMH7N$&&&&A))GS)    	 	 s   'B" "B3rJ   rI   NrJ   _LazyManifestreturnNonerd   rE   rd   r\   	__name__
__module____qualname____firstlineno__rM   rS   r_   __next____static_attributes__rQ   r(   r8   rE   rE   n   s    ! Hr(   rE   c                  6    \ rS rSrSS jrSS jrS	S jr\rSrg)
lazymanifestiterentries   c                    Xl         SU l        g rH   ra   rK   s     r8   rM    lazymanifestiterentries.__init__   s    r(   c                    U $ rP   rQ   rR   s    r8   rS    lazymanifestiterentries.__iter__   rU   r(   c                    U R                   R                  U R                  5      u  pUS:X  a.  [        U[        5      (       d   eU =R                  S-  sl        U$ [        U[        5      (       d   eUR                  SU5      nUR                  SU5      nUS:X  d  US:X  d  XC:  a  [        R                  " S5      eXS-
  U nU[        ;   a  XC-
  S-
  nO	XC-
  S-
  nSnUSU R                   R                  -  :w  a  [        R                  " S5      e[        XR                   R                  U R                     US-   U5      nU =R                  S-  sl        XU Xu4$ ! [         a    [        ef = f)Nr#   r   r'   r$   r*   r)   r(   )rJ   rW   rI   rX   rY   rZ   r[   r\   r]   r   StorageErrorr/   _nodelen	unhexlify	extrainfo)rL   r1   rI   r^   nlposr7   hlenhashvals           r8   r_   lazymanifestiterentries.next   s]   	 TXX.ID "9dE****HHMHK$&&&&))GS)		%%b=ERK5?$$%=>>QY'N"?Q&D?Q&DE1tww''''$$%=>>''##DHH-w{D
 	A!722/  	 	 s   'E   E1ra   Nrb   rd   rp   )rd   Tuple[bytes, bytes, bytes]rh   rQ   r(   r8   rp   rp      s    38 Hr(   rp   c                V    [        XX#-    5      nU(       a  U[        US-  /5      -  nU$ )N   )r   r\   )r1   extrarI   lengthss        r8   ry   ry      s0    Ds|$%A	UEDL>""Hr(   c                    X:  X:  -
  $ rP   rQ   )abs     r8   _cmpr      s    Eaer(   >   r(      l   t   xc                     \ rS rSrSr    S     SS jjrSS jr    SS jrSS jrSS jr	SS	 jr
S S
 jrS!S jrS"S jrS#S jrS$S jrS%S jrS&S jrS'S jr S(     S)S jjrS*S jrS+S jrS+S jrS,S jrS-S jrSrg).rc      a  A pure python manifest backed by a byte string.  It is supplimented with
internal lists as it is modified, until it is compacted back to a pure byte
string.

``data`` is the initial manifest data.

``positions`` is a list of offsets, one per manifest entry.  Positive
values are offsets into ``data``, negative values are offsets into the
``extradata`` list.  When an entry is removed, its entry is dropped from
``positions``.  The values are encoded such that when walking the list and
indexing into ``data`` or ``extradata`` as appropriate, the entries are
sorted by filename.

``extradata`` is a list of (key, hash, flags) for entries that were added or
modified since the manifest was created or compacted.
Nc                    Xl         UcI  U R                  U5      U l        S/[        U R                  5      -  U l        X l        / U l        SU l        g US S  U l        US S  U l        US S  U l        X l        X`l        g )Nr   F)rx   	findlines	positionsr.   rz   r1   	extradatahasremovals)rL   r0   r1   r   rz   r   r   s          r8   rM   _LazyManifest.__init__   sv      !^^D1DNS3t~~#66DNIDN$D&q\DN&q\DN&q\DNI*r(   c                   U(       d  / $ UR                  S5      nUS:X  d	  USS  S:w  a  [        S5      eS/nUS UR                  S5       nU[        U5      S-
  :  au  US:w  ao  UR                  US-   5        XS-   UR                  SUS-   5       nXT:  a  [        S5      eUnUR                  SUS-   5      nU[        U5      S-
  :  a  US:w  a  Mo  U$ )Nr$   r#   r%   r   r'   r   r&   )r]   r+   r.   r<   )rL   r1   rI   r   r2   nextss         r8   r   _LazyManifest.findlines   s    Iii"9RS	U*BCCC	(dii()CIM!cRiS1W%q499WcAg#>?E| !GHHD))E37+C CIM!cRi r(   c                r    U R                   U   nUS:  a  U R                  U4$ U R                  U* S-
     S4$ )Nr   r   r#   )r   r1   r   )rL   indexrI   s      r8   rW   _LazyManifest._get   sA     nnU#!899c>!~~sdQh'++r(   c                    US:  a+  U R                   XR                   R                  SUS-   5       $ U R                  U* S-
     S   $ )Nr   r'   r   )r1   r]   r   )rL   rI   s     r8   _getkey_LazyManifest._getkey  sE    !899S99>>'37#CDD~~sdQh'**r(   c                    Sn[        U R                  5      S-
  nX#::  aR  X#-   S-  nU R                  U   nU R                  U5      n[        X5      nUS:X  a  U$ US:  a  US-
  nOUS-   nX#::  a  MR  g)Nr   r   r)   r#   r.   r   r   r   rL   keyfirstlastmidpointnextpos	candidaters           r8   bsearch_LazyManifest.bsearch  s    4>>"Q&m*HnnX.GW-IS$AAvq5#a<D$qLE m r(   c                    Sn[        U R                  5      S-
  nX#::  aT  X#-   S-  nU R                  U   nU R                  U5      n[        X5      nUS:X  a  US4$ US:  a  US-
  nOUS-   nX#::  a  MT  US4$ )Nr   r   r)   TFr   r   s           r8   bsearch2_LazyManifest.bsearch2  s     4>>"Q&m*HnnX.GW-IS$AAv $''q5#a<D$qLE m u~r(   c                *    U R                  U5      S:g  $ Nr#   )r   rL   r   s     r8   __contains___LazyManifest.__contains__,  s    ||C B&&r(   c                ,   [        U[        5      (       d  [        S5      eU R                  U5      nUS:X  a  [        eU R                  U5      u  p4US:X  a!  [        U[        5      (       d   eUS   US   4$ [        U[        5      (       d   eUR                  SU5      nUR                  SU5      nSUs=::  a  [        U R                  5      ::  d   e   e[        U R                  5      [        U R                  5      :X  d   eUS:X  d  US:X  d  Xe:  a  [        R                  " S5      eXe-
  S-
  nX6S-
  U nU[        ;   a  US-  nOS	nUSU R                  -  :w  a  [        R                  " S5      e[        X0R                  U   US-   U5      n	X4$ )
Ns'   getitem: manifest keys must be a bytes.r#   r   r)   r'   r$   r   r*   r(   )rZ   r\   	TypeErrorr   KeyErrorrW   r[   r]   r.   r   rz   r   rw   r/   rx   ry   )
rL   r   needler1   rI   r^   r{   r|   r7   r}   s
             r8   __getitem___LazyManifest.__getitem__/  s   #u%%FGGc"R<NIIf%	"9dE****GT!W%%$&&&&))GS)		%)F1c$..1111114>>"c$..&9999b=ERK5?$$%=>>"QY'N"AIDE1t}}$$$$%=>>D.."8'A+tLr(   c                n   U R                  U5      u  p#U(       d  [        eU R                  U   nU R                  S U U R                  US-   S  -   U l        U R                  S U U R                  US-   S  -   U l        US:  a2  U R                  S U S-   U R                  US-   S  -   U l        SU l        g g )Nr   r   r'   T)r   r   r   rz   r1   r   )rL   r   r   foundcurs        r8   __delitem___LazyManifest.__delitem__L  s    c*NnnV$04>>&1*,3OO04>>&1*,3OO!8 		$3'1DIIcAgi4HHDI#D	 r(   c                   [        U[        5      (       d  [        S5      e[        U[        5      (       a  [	        U5      S:w  a  [        S5      eUS   n[        U[        5      (       a  [	        U5      S;  a  [        S5      eUS   n[        U[        5      (       a  [	        U5      S:  a  [        SU5      eU R                  U5      u  pVU(       ar  U R                  U   nUS:  a  XUS   4U R                  U* S-
  '   g U R                  R                  XUS   45        [	        U R                  5      * U R                  U'   g U R                  R                  XUS   45        U R                  S U [	        U R                  5      * /-   U R                  US  -   U l        U R                  S U S/-   U R                  US  -   U l	        g )	Ns-   setitem: manifest keys must be a byte string.r)   s1   Manifest values must be a tuple of (node, flags).r          s-   node must be a 20-byte or 32-byte byte stringr   s'   flags must a 0 or 1 byte string, got %r)
rZ   r\   r   r[   r.   r   r   r   r<   rz   )rL   r   valuer}   r7   r   r   rI   s           r8   __setitem___LazyManifest.__setitem__Y  s   #u%%LMM%''3u:?D  ('5))S\-ILMMa%''3u:>FNNc*..(CQw,/%(+Ctax( %%sU1X&>?*-dnn*=)=v& NN!!3q":;w'''()..)* N w'1#-vw0GG Nr(   c                    [        U R                  U R                  U R                  U R                  U R
                  U R                  5      $ rP   )_lazymanifestrx   r1   r   rz   r   r   rR   s    r8   copy_LazyManifest.copy|  s;    MMIINNNNNN
 	
r(   c                   [        U R                  5      S:X  a  U R                  (       d  g / nSnSnS/[        U R                  5      -  U l        U[        U R                  5      :  Ga<  U R                  U   S:  Ga  U R                  U   nUn X0R                  U'   US-  nU[        U R                  5      :X  d  U R                  U   S:  a  OdU R                  (       a.  U R
                  R                  SX@R                  U   5      S:w  a  O%X0R                  U   U-
  -  nU R                  U   nM  U R
                  R                  SU5      nUS:w  a  US-  nX6U-
  -  nUR                  U R
                  XV 5        GO	U[        U R                  5      :  a  U R                  U   S:  a  U R                  U   nU R                  U* S-
     nUR                  U R                  U5      5        X0R                  U'   Sn[        US   5      S:  a  Sn[        US   5      U:  a!  [        US   US-      5      U R                  U'   U[        US   5      -  nUS-  nU[        U R                  5      :  a  U R                  U   S:  a  M  U[        U R                  5      :  a  GM<  S	R                  U5      U l        S
U l        / U l        g )Nr   r   s   
 r#   r$   r      r   r(   F)r.   r   r   r   rz   r1   r]   r<   _packordr>   )	rL   r3   ioffsetr   last_cutend_cuttr|   s	            r8   _compact_LazyManifest._compact  sz   t~~!#D,<,<s4>>22#dnn%%~~a A%nnQ'
 (.NN1%FAC//4>>!3Dq3H (( IINN9c>>!;LM nnQ/#55F..+C% & ))..4b=qLGC-'845#dnn--$..2Ca2G..+Ctax0AHHTZZ]+(.NN1% D1Q4y2~!1Q4y4',/!TAX,?q)c!B%j(FFA #dnn--$..2Ca2GC #dnn%%^ HHQK	 r(   c                h    US   n[        U5      S;   d   eUS   S-   [        U5      -   US   -   S-   $ )Nr   r   r   r'   r)   r$   )r.   r   )rL   dr5   s      r8   r   _LazyManifest._pack  sB    aD1v!!!tg~A&1-55r(   c                :    U R                  5         U R                  $ rP   )r   r1   rR   s    r8   text_LazyManifest.text  s    yyr(   c                    0 nU R                  5        H5  u  pEnXA;  a	  XV4S4X4'   M  X   nXV4U:w  a	  XV4U4X4'   M(  U(       d  M1  SX4'   M7     UR                  5        H  u  pGnX@;  d  M  SXv44X4'   M     U$ )z2Finds changes between the current manifest and m2.Nr(   N)iterentries)rL   m2cleandifffne1r7   e2s           r8   r   _LazyManifest.diff  s     !--/MBE|;3V;"$ "{BDHU#DH 0  ^^-MBE~&3 . r(   c                    [        U 5      $ rP   )rp   rR   s    r8   r   _LazyManifest.iterentries  s    &t,,r(   c                    [        U 5      $ rP   rE   rR   s    r8   iterkeys_LazyManifest.iterkeys      %%r(   c                    [        U 5      $ rP   r   rR   s    r8   rS   _LazyManifest.__iter__  r   r(   c                ,    [        U R                  5      $ rP   )r.   r   rR   s    r8   __len___LazyManifest.__len__  s    4>>""r(   c                    [        U R                  S5      nU R                  5        H  u  p4nU" U5      (       d  M  XE4X#'   M     U$ r   )r   rx   r   )rL   filterfncr4   r5   rB   s         r8   
filtercopy_LazyManifest.filtercopy  sB    $---((*HA"{{u + r(   )rx   r1   r   rz   r   r   )NNNF)r0   intr1   r\   r   bool)r1   r\   rd   z	List[int])r   r   rd   z4Tuple[Union[bytes, Tuple[bytes, bytes, bytes]], int]rg   )r   r\   rd   r   )r   r\   rd   zTuple[int, bool]r   r\   rd   r   r   r\   rd   Tuple[bytes, bytes]r   r\   rd   re   )r   r\   r   r   )rd   rc   rd   re   )r   r   rd   r\   rd   r    F)r   rc   r   r   rd   ZDict[bytes, Optional[Tuple[Tuple[Optional[bytes], bytes], Tuple[Optional[bytes], bytes]]]]r   rf   rd   r   )r   zCallable[[bytes], bool]rd   rc   )ri   rj   rk   rl   __doc__rM   r   rW   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rS   r   r   rn   rQ   r(   r8   rc   rc      s    * !++ + +."	,	,	=	,+
$(' :$!F	
9v6

 05(,
8-&&#r(   rc   c                  r   \ rS rSrS!S"S jjrS#S jrS$S jrS%S jrS&S jr\r	S'S jr
S(S jrS)S	 jrS*S
 jrS+S jrS+S jrS,S jrS-S.S jjr\S/S j5       rS/S jrS0S jrS1S jrS2S jrS3S jr  S4       S5S jjrS6S jrS-S7S jjrS#S jrS8S jrS9S jrS9S jrS:S jr S;S jr!      S<S jr"S r#g)=manifestdicti  c                0    Xl         [        X5      U l        g rP   )rx   r   _lm)rL   r0   r1   s      r8   rM   manifestdict.__init__  s     /r(   c                &    U R                   U   S   $ rH   r  r   s     r8   r   manifestdict.__getitem__  s    xx}Qr(   c                     U R                   U   $ rP   r  r   s     r8   r]   manifestdict.find
  s    xx}r(   c                ,    [        U R                  5      $ rP   r.   r  rR   s    r8   r   manifestdict.__len__  s    488}r(   c                2    [        U R                  5      S:g  $ rH   r  rR   s    r8   __nonzero__manifestdict.__nonzero__  s     488}!!r(   c                $    X#4U R                   U'   g rP   r  )rL   r   noder7   s       r8   setmanifestdict.set  s    r(   c                B    X R                  U5      4U R                  U'   g rP   )r7   r  )rL   r   r  s      r8   r   manifestdict.__setitem__  s    jjo-r(   c                &    Uc  gXR                   ;   $ NFr  r   s     r8   r   manifestdict.__contains__  s    ;hhr(   c                    U R                   U	 g rP   r  r   s     r8   r   manifestdict.__delitem__"  s    HHSMr(   c                6    U R                   R                  5       $ rP   )r  rS   rR   s    r8   rS   manifestdict.__iter__%      xx  ""r(   c                6    U R                   R                  5       $ rP   )r  r   rR   s    r8   r   manifestdict.iterkeys(  r  r(   c                4    [        U R                  5       5      $ rP   listr   rR   s    r8   keysmanifestdict.keys+      DMMO$$r(   Nc                   Ub[  [         R                  " US 5      n[        UR                  U5      5      nU R                  U5       Vs1 s H  oDU;  d  M
  UiM     sn$ U  Vs1 s H  oDU;  d  M
  UiM     sn$ s  snf s  snf )7Set of files in this manifest that are not in the otherc                    g rP   rQ   )pathmsgs     r8   <lambda>)manifestdict.filesnotin.<locals>.<lambda>1  s    tr(   )matchmodbadmatchr  walk)rL   r   r   sm2r4   s        r8   
filesnotinmanifestdict.filesnotin.  ss    %%e-CDEbggen%C#yy/@/!C<A/@@/4aB;4// A/s   		A9A9#	A>0A>c                .    [         R                  " U 5      $ rP   r   dirsrR   s    r8   _dirsmanifestdict._dirs6      }}T""r(   c                    U R                   $ rP   r6  rR   s    r8   r5  manifestdict.dirs:      zzr(   c                    XR                   ;   $ rP   r:  )rL   dirs     r8   hasdirmanifestdict.hasdir=  s    jj  r(   c                   ^  UR                  5       n[        U5      S:  =(       aC    UR                  5       =(       d,    UR                  5       =(       a    [	        U 4S jU 5       5      $ )zfChecks whether we can correctly and quickly iterate over matcher
files instead of over manifest files.d   c              3  ,   >#    U  H	  oT;   v   M     g 7frP   rQ   ).0r   rL   s     r8   	<genexpr>.manifestdict._filesfastpath.<locals>.<genexpr>F  s     &BEbTzEs   )r@   r.   isexactprefixall)rL   r   r@   s   `  r8   _filesfastpathmanifestdict._filesfastpath@  sN     5zC 
MMO DB3&BE&B#B	
r(   c              #    #    UR                  5       (       a  [        U 5       Sh  vN   g[        UR                  5       5      nU R	                  U5      (       a  [        U5       H  nX0;   d  M
  Uv   M     gU  H,  nX2;   a  UR                  U5        U" U5      (       d  M(  Uv   M.     UR                  S5        [        U5       H-  nU R                  U5      (       a  M  UR                  US5        M/     g N7f)zGenerates matching file names.

Equivalent to manifest.matches(match).iterkeys(), but without creating
an entirely new manifest.

It also reports nonexistent files by marking them bad with match.bad().
Nr(   )
alwaysiterr  r@   rJ  sortedremovediscardr?  badrL   r   fsetr   s       r8   r/  manifestdict.walkI  s      <<>>Dz!!5;;=! u%%Tl:H # BzBRyy  	S,B;;r??		"d# / "s"   $C;C9AC;0/C;#;C;"C;c                   UR                  5       (       a  U R                  5       $ U R                  U5      (       aR  [        U R                  5      nU R
                  nUR                  5        H  nXC;   d  M
  X4   UR
                  U'   M     U$ [        U R                  5      nU R
                  R                  U5      Ul        U$ )z6generate a new manifest filtered by the match argument)rM  r   rJ  r  rx   r  r@   r   )rL   r   mrJ   r   s        r8   _matchesmanifestdict._matchesm  s    <<>>99;u%%T]]+ABkkm8 "AEE"I $ H'##E*r(   c                    U(       a1  U R                  U5      nUR                  U5      nUR                  XS9$ U R                  R                  UR                  U5      $ )"  Finds changes between the current manifest and m2.

Args:
  m2: the manifest to which this manifest should be compared.
  clean: if true, include files unchanged between these manifests
         with a None value in the returned dictionary.

The result is returned as a dict with filename as key and
values of the form ((n1,fl1),(n2,fl2)), where n1/n2 is the
nodeid in the current/other manifest and fl1/fl2 is the flag
in the current/other manifest. Where the file does not exist,
the nodeid will be None and the flags will be the empty
string.
r   )rX  r   r  )rL   r   r   r   m1s        r8   r   manifestdict.diff~  sM    2 u%BU#B7727++xx}}RVVU++r(   c                T    U[         ;  a  [        S5      eX   U4U R                  U'   g )N   Invalid manifest flag set.)r/   r   r  )rL   r   flags      r8   setflagmanifestdict.setflag  s)    ~%9::	4r(   c                L     U R                   U   S   $ ! [         a    Us $ f = frH   r  r   )rL   r   defaults      r8   getmanifestdict.get  s.    	88C=## 	N	s    ##c                H     U R                   U   S   $ ! [         a     gf = f)Nr   r(   re  r   s     r8   r7   manifestdict.flags  s,    	88C=## 		s    
!!c                n    [        U R                  5      nU R                  R                  5       Ul        U$ rP   )r  rx   r  r   )rL   r   s     r8   r   manifestdict.copy  s&    'r(   c                D    S U R                   R                  5        5       $ )Nc              3  *   #    U  H	  oS S v   M     g 7fNr)   rQ   rD  xs     r8   rE  %manifestdict.items.<locals>.<genexpr>       65!"15   r  r   rR   s    r8   itemsmanifestdict.items      6txx33566r(   c                D    S U R                   R                  5        5       $ )Nc              3  *   #    U  H	  oS S v   M     g 7fro  rQ   rp  s     r8   rE  )manifestdict.iteritems.<locals>.<genexpr>  rs  rt  ru  rR   s    r8   	iteritemsmanifestdict.iteritems  rx  r(   c                6    U R                   R                  5       $ rP   ru  rR   s    r8   r   manifestdict.iterentries  s    xx##%%r(   c                6    U R                   R                  5       $ rP   )r  r   rR   s    r8   r   manifestdict.text  s    xx}}r(   c                    / nSnSnS/nSn[         R                  " U5      n[        U5      n[        U5      [        :  a  U H  u  p[        XU5      u  p{U
(       d#  U R                  U	   u  pSU	[        U5      U4-  nOX{:X  a  [        [        S5      U	-  5      eSnUb-  XG::  a(  XW:  a#  X[:  a  UnU(       a  UR                  U5        M  M  Ub"  UR                  XESR                  U5      45        UnUnU/nM     Ub"  UR                  XESR                  U5      45        [        X5      u  nnUU4$ [        U R                  5       5      n[        R                   " [         R                  " U5      [         R                  " U5      5      nUU4$ )zGiven a base manifest text as a bytearray and a list of changes
relative to that text, compute a delta that can be used by revlog.
Nr(   r   r;   s!   failed to remove %s from manifest)r   bufferr"  r.   FASTDELTA_TEXTDIFF_THRESHOLD_msearchr  r   AssertionErrorr   r<   r>   _addlistdelta	bytearrayr   r   textdiff)rL   basechangesdeltadstartdenddlinestartaddbufr4   todeleteendhrB   r3   	deltatext	arraytexts                    r8   	fastdeltamanifestdict.fastdelta  s    T"w-w<66  '%f7
 HHQKEA%CFB7A|,BCaG  A%&/dmz"Q  )fCHHUO%DE"FDCE/  '2 !fCHHUO<=#0#= Iy )## "$))+.ID!4;;y#9I )##r(   )r  rx   r(   )r0   r   r1   r    )r   r\   rd   r\   r   r   rd   r   )r   r\   r  r\   r7   r\   rd   re   )r   r\   r  r\   rd   re   r   r   rd   Iterator[bytes]rd   zList[bytes]rP   )rd   
Set[bytes]rd   zpathutil.dirsr>  r\   rd   r   )r   r   rd   r   r   r   rd   r  )r   r   rd   r  r  )r   r  r   Optional[MatcherT]r   r   rd   r   )r   r\   ra  r\   rd   re   )r   r\   rd   Optional[bytes]rd   r  )rd   zIterator[Tuple[bytes, bytes]])rd   z$Iterator[Tuple[bytes, bytes, bytes]]r   )r  r    r  Iterable[Tuple[bytes, bool]]rd   zTuple[ByteString, ByteString])$ri   rj   rk   rl   rM   r   r]   r   r  __bool__r  r   r   r   rS   r   r#  r1  propertycacher6  r5  r?  rJ  r/  rX  r   rb  rg  r7   r   rv  r|  r   r   r  rn   rQ   r(   r8   r  r    s    0 "
 H$.
##%0 # #!
"$H( %)	,, ", 	,

,>(

77&7$7$)E7$	&7$r(   r  c                z  ^ ^	 SU	U 4S jjnU(       d  X"4$ [        T 5      m	U(       d  T	nX#:  ag  X#-   S-  nUnUS:  a%  T US-
  U S:w  a  US-  nUS:  a  T US-
  U S:w  a  M  U" US5      n[        T Xg 5      U:  a  U" US-   S5      S-   nOUnX#:  a  Mg  U" US5      nT X' nX:X  a  U" US-   S5      nX'S-   4$ X"4$ )	zreturn a tuple (start, end) that says where to find s within m.

If the string is found m[start:end] are the line containing
that string.  If start == end the string was not found and
they indicate the proper sorted insertion point.
c                Z   > U T:  a#  TX S-    U:w  a  U S-  n U T:  a  TX S-    U:w  a  M  U $ )Nr   rQ   )r   r   lenmrW  s     r8   advance_msearch.<locals>.advance  s?    $h1QQ<1,FA $h1QQ<1,r(   r)   r   r   r$   r'   (   )r   r   r   r\   )r.   r\   )
rW  r   lohir  midr  r  r   r  s
   `        @r8   r  r    s     
 xq6D
'w1naiAeai%0E9QJE aiAeai%0E9eU#5" r5)A-B B ' "e
CbIEzcBh&!G}xr(   c                    U  HE  nSU;   d  SU;   d  M  [         R                  " [        S5      [        R                  " U5      -  5      e   g)z'Check filenames for illegal characters.r$      s)   '\n' and '\r' disallowed in filenames: %rN)r   rw   r   r   bytestr)r3   r4   s     r8   r=   r=   %  sH    A:!$$@A""1%&  r(   c                    Sn[        5       nU H#  u  pEnX0X$ -  nU(       a  U[        U5      -  nUnM%     X0US  -  nSR                  S U 5       5      nXs4$ )Nr   r(   c           	   3  p   #    U  H,  u  pn[         R                  " S X[        U5      5      U-   v   M.     g7f)s   >lllN)structpackr.   )rD  r  r  contents       r8   rE   _addlistdelta.<locals>.<genexpr>C  s2      #$E 	GUW6@#$s   46)r  r>   )addlistrq  currentposition
newaddlistr  r  r  r  s           r8   r  r  1  s{     OJ Go44
)G,,J  ! /*++J #$ I   r(   c                L    SU ;   a  U R                  SS5      u  pUS-   U4$ SU 4$ )N   /r   r(   )r-   )r4   r>  subpaths      r8   _splittopdirr  J  s3    qywwtQ'Tz7""Avr(   c                    g rP   rQ   )r   s    r8   r+  r+  R  s    $r(   c                     \ rS rSr% S\S'   S\S'   S\S'   S\S	'   S\S
'   S;S<S jjrS=S jrS>S jrS?S jr    S@S jr	SAS jr
SBS jrSCS jr\rSCS jr\R                   SDS j5       rSDS jrSDS jrSES jr  SFS jrSGS jr\rSHS jrSIS jrSHS jrSJS jrSKSLS jjrSMS  jrSMS! jrSNS" jrSOS# jr SPS$ jr!SQS% jr"S>S& jr#SRS' jr$SSS( jr% SK     STS) jjr&\'SUS* j5       r(SUS+ jr)SVS, jr*SWS- jr+SWS. jr,SXS/ jr-SXS0 jr.      SYS1 jr/  SZ       S[S2 jjr0S\S3 jr1      S]S4 jr2S^S5 jr3S^S6 jr4      S_S7 jr5          S`S8 jr6 SK   SaS9 jjr7S:r8g)btreemanifestiU  r\   _dirzDict[bytes, treemanifest]r6  r   _dirtyDict[bytes, bytes]_files_flagsc                @   X l         Xl        U R                  R                  U l        U R                  R                  U l        [        U l        [        U l        SU l	        0 U l
        0 U l        0 U l        0 U l        U(       a  S nU R                  X45        SU l	        g g )NFc                    [        S5      e)Ns4   treemanifest constructor only accepts flat manifests)r  )subdirsubms     r8   readsubtree*treemanifest.__init__.<locals>.readsubtreen  s    $K r(   T)r  nodeconstantsnullid_noder0   rx   _noop	_loadfunc	_copyfuncr  r6  	_lazydirsr  r  parse)rL   r  r>  r   r  s        r8   rM   treemanifest.__init__\  s    	*''..
**22
  	
 
 JJt)DK r(   c                     U R                   U-   $ rP   r  )rL   r)  s     r8   _subpathtreemanifest._subpathv  s    yy4r(   c                (   U R                   nU R                  nU R                  R                  5        HB  u  nu  pEnU(       a!  U" U" U5      U5      R	                  5       X'   M1  U" U" U5      U5      X'   MD     U R                  R                  5         g rP   )r6  r  r  rv  r   clear)rL   selfdirsr  r   r  r  docopys          r8   _loadalllazytreemanifest._loadalllazyy  sx    ::--.2nn.B.B.D*A*6)'!*d;@@B)'!*d;	 /E
 	r(   c                &   U R                   R                  U5      nUbs  Uu  p4nU(       a4  U" U R                  U5      U5      R                  5       U R                  U'   O%U" U R                  U5      U5      U R                  U'   U R                   U	 g g rP   )r  rg  r  r   r6  )rL   r   vr  r  r  s         r8   	_loadlazytreemanifest._loadlazy  s|    NNq!=()%Dv +DMM!,<d C H H J

1 +DMM!,<d C

1q! r(   c                    U(       d  g US:X  d  US:X  a  U R                  5         g [        [        [           U5      nU R                  nU H  nU" US-   5        M     U$ )N   all   thisr  )r  r   r   r\   r  )rL   visitloadlazyks       r8   _loadchildrensetlazy!treemanifest._loadchildrensetlazy  s[     F?ew.SZ'>>AQX r(   c                   / nUR                   R                  5        HB  u  pEUR                   R                  U5      nUb  US   US   :w  d  M1  UR                  U5        MD     UR                   R                  5        H'  u  pEXAR                   ;  d  M  UR                  U5        M)     U H%  nUR	                  U5        UR	                  U5        M'     g)a=  load items in t1 and t2 if they're needed for diffing.

The criteria currently is:
- if it's not present in _lazydirs in either t1 or t2, load it in the
  other (it may already be loaded or it may not exist, doesn't matter)
- if it's present in _lazydirs in both, compare the nodeid; if it
  differs, load it in both
Nr   )r  rv  rg  r<   r  )rL   t1t2
toloadlazyr   v1v2s          r8   _loaddifflazytreemanifest._loaddifflazy  s     
\\'')EA!!!$BzRUbe^!!!$ * \\'')EA$!!!$ * ALLOLLO r(   c                    U R                  5         [        U R                  5      nU R                  5         U R                  R                  5        H  nXR                  5       -  nM     U$ rP   )_loadr.   r  r  r6  valuesr   )rL   sizerW  s      r8   r   treemanifest.__len__  sO    

4;;""$AIIKD %r(   c                ,    U R                  5       (       + $ rP   _isemptyrR   s    r8   r  treemanifest.__nonzero__  s    ==?""r(   c                j   U R                  5         U R                  (       d@  U R                  (       a0  [        S U R                  R	                  5        5       5      (       a  gU R                  5         U R                  (       + =(       d*    [        S U R                  R	                  5        5       5      $ )Nc              3  J   #    U  H  oR                  5       (       + v   M     g 7frP   r  rD  rW  s     r8   rE  (treemanifest._isempty.<locals>.<genexpr>  s     M9LA::<//9Ls   !#Fc              3  @   #    U  H  oR                  5       v   M     g 7frP   r  r  s     r8   rE  r    s     $O;NaZZ\\;Ns   )r  r  r6  anyr  r  rI  rR   s    r8   r  treemanifest._isempty  sn    

;;JJ3M9J9J9LMMM::~O$O4::;L;L;N$O!OOr(   c                    SU R                   [        U R                  5      [        U R                  [
        L 5      U R                  [        U 5      4-  $ )Ns;   <treemanifest dir=%s, node=%s, loaded=%r, dirty=%r at 0x%x>)r  r   r  r   r  r  r  idrR   s    r8   __repr__treemanifest.__repr__  sH     K		DJJT^^u,-4		
r(   c                    U R                   $ )zuThe directory that this tree manifest represents, including a
trailing '/'. Empty string for the repo root directory.r  rR   s    r8   r>  treemanifest.dir  s     yyr(   c                @    U R                   (       a   eU R                  $ )zThis node of this instance. nullid for unsaved instances. Should
be updated when the instance is read or written from a revlog.
r  r  rR   s    r8   r  treemanifest.node  s     ;;zzr(   c                    Xl         SU l        g r  )r  r  rL   r  s     r8   setnodetreemanifest.setnode  s    
r(   c              #    #    U R                  5         U R                  5         [        [        R                  " U R
                  R                  5       U R                  R                  5       5      5       H]  u  pXR                  ;   a1  U R                  U5      X R                  R                  US5      4v   ME  UR                  5        S h  vN   M_     g  N	7fr   )r  r  rO  	itertoolschainr6  rv  r  r  r  rg  r   rL   pr5   s      r8   r   treemanifest.iterentries  s      	

OODJJ,,.0A0A0CD
DA KKmmA&;;??1c+BBB==?**
 +s   C	CC
Cc              #  ~  #    U R                  5         U R                  5         [        [        R                  " U R
                  R                  5       U R                  R                  5       5      5       HC  u  pXR                  ;   a  U R                  U5      U4v   M+  UR                  5        S h  vN   ME     g  N	7frP   )	r  r  rO  r  r  r6  rv  r  r  r  s      r8   rv  treemanifest.items  s     

OODJJ,,.0A0A0CD
DA KKmmA&))779$$
 %s   B/B=1B;2
B=c              #  <  #    U R                  5         U R                  5         [        [        R                  " U R
                  U R                  5      5       H>  nXR                  ;   a  U R                  U5      v   M'  U R
                  U    S h  vN   M@     g  N	7frP   )r  r  rO  r  r  r6  r  r  )rL   r  s     r8   r   treemanifest.iterkeys  sl     

	

DKK@AAKKmmA&&::a=((	 B )s   BBB
Bc                4    [        U R                  5       5      $ rP   r!  rR   s    r8   r#  treemanifest.keys  r%  r(   c                "    U R                  5       $ rP   )r   rR   s    r8   rS   treemanifest.__iter__  s    }}r(   c                    Uc  gU R                  5         [        U5      u  p#U(       a?  U R                  U5        X R                  ;  a  gU R                  U   R	                  U5      $ XR
                  ;   $ r  )r  r  r  r6  r   r  rL   r4   r>  r  s       r8   r   treemanifest.__contains__  s`    9

#ANN3**$::c?//88##r(   Nc                    U R                  5         [        U5      u  p4U(       a@  U R                  U5        X0R                  ;  a  U$ U R                  U   R	                  XB5      $ U R
                  R	                  X5      $ rP   )r  r  r  r6  rg  r  )rL   r4   rf  r>  r  s        r8   rg  treemanifest.get   s`    

#ANN3**$::c?&&w88;;??1..r(   c                    U R                  5         [        U5      u  p#U(       a/  U R                  U5        U R                  U   R	                  U5      $ U R
                  U   $ rP   )r  r  r  r6  r   r  r"  s       r8   r   treemanifest.__getitem__,  sL    

#ANN3::c?..w77;;q>!r(   c                >   U R                  5         [        U5      u  p#U(       a?  U R                  U5        X R                  ;  a  gU R                  U   R	                  U5      $ XR
                  ;   d  XR                  ;   a  gU R                  R                  US5      $ r   )r  r  r  r6  r7   r  r  rg  r"  s       r8   r7   treemanifest.flags6  su    

#ANN3**$::c?((11NN"a::o;;??1c**r(   c                    U R                  5         [        U5      u  p#U(       a/  U R                  U5        U R                  U   R	                  U5      $ U R
                  U   U R                  R                  US5      4$ r   )r  r  r  r6  r]   r  r  rg  r"  s       r8   r]   treemanifest.findD  s`    

#ANN3::c?''00;;q>4;;??1c#:::r(   c                j   U R                  5         [        U5      u  p#U(       a_  U R                  U5        U R                  U   R	                  U5        U R                  U   R                  5       (       a  U R                  U	 O)U R                  U	 XR                  ;   a  U R                  U	 SU l        g NT)	r  r  r  r6  r   r  r  r  r  r"  s       r8   r   treemanifest.__delitem__N  s    

#ANN3JJsO''0zz#''))JJsOAKKKKNr(   c                   Uc   eU[         ;  a  [        S5      eU R                  5         [        U5      u  pEU(       ar  U R	                  U5        X@R
                  ;  a2  [        U R                  U R                  U5      5      U R
                  U'   U R
                  U   R                  XRU5        O-[        U5      S;   d   eX R                  U'   X0R                  U'   SU l        g)z+Set both the node and the flags for path f.Nr`  r   T)r/   r   r  r  r  r6  r  r  r  r  r.   r  r  r  )rL   r4   r  r7   r>  r  s         r8   r  treemanifest.set^  s    &9::

#ANN3**$".&&c(:#

3 JJsOu5t9(((!KKN"KKNr(   c                   Uc   eU R                  5         [        U5      u  p4U(       aq  U R                  U5        X0R                  ;  a2  [	        U R
                  U R                  U5      5      U R                  U'   U R                  U   R                  XB5        O[        U5      S;   d   eX R                  U'   SU l
        g )Nr   T)r  r  r  r6  r  r  r  r   r.   r  r  )rL   r4   r5   r>  r  s        r8   r   treemanifest.__setitem__r  s    }}

#ANN3**$".&&c(:#

3 JJsO''3
 q6X%%%KKNr(   c                    U R                   [        La   U R                   [        sol         U" U 5        g U R                  [        La   U R                  [        so l        U" U 5        g g rP   )r  r  r  )rL   lfcfs      r8   r  treemanifest._load  sM    >>&!%BtH^^5(!%BtH )r(   c                   U[         ;  a  [        S5      eU R                  5         [        U5      u  p4U(       aq  U R	                  U5        X0R
                  ;  a2  [        U R                  U R                  U5      5      U R
                  U'   U R
                  U   R                  XB5        OX R                  U'   SU l        g)z/Set the flags (symlink, executable) for path f.r`  TN)r/   r   r  r  r  r6  r  r  r  rb  r  r  )rL   r4   r7   r>  r  s        r8   rb  treemanifest.setflag  s    &9::

#ANN3**$".&&c(:#

3 JJsO##G3"KKNr(   c                ,  ^  [        T R                  T R                  5      nT R                  Ul        T R                  Ul        T R
                  [        L a,  U 4S jnT R                  [        L a
  U" U5        U$ X!l         U$ T R
                  Ul        U$ )Nc           
       > TR                  5         TR                  R                  5        VVVVs0 s H  u  nu  p#oAX#S4_M     snnnnU l        U R                  nTR                  R                  5        H  u  pUR	                  5       XQ'   M     [
        R	                  TR                  5      U l        [
        R	                  TR                  5      U l        g s  snnnnf r-  )r  r  rv  r6  r   dictr  r  )r   r   r5   r   r   sdirsr  rL   s          r8   r  $treemanifest.copy.<locals>._copyfunc  s    

8<8L8L8N8N9A!d|O8N  JJ,,.DA vvxEH /99T[[199T[[1s   C
)r  r  r  r  r  r  r  r  )rL   r   r  s   `  r8   r   treemanifest.copy  s|    D..		:ZZ
kk>>U"	2 ~~&$
  "+  "^^DNr(   c                   ^ ^^ U(       aH  UR                  5       (       d3  T R                  U5      nUR                  U5      nUR                  U5      $ [        5       mUUU 4S jmT" T U5        T$ )r'  c                >  > U R                   UR                   :X  a#  U R                  (       d  UR                  (       d  g U R                  5         UR                  5         TR                  X5        U R                  R                  5        HL  u  p#X!R                  ;   a  UR                  U   nT" X45        M-  TR                  UR                  5       5        MN     U R                   H4  nXQR                  ;  d  M  TR                  U R                  U5      5        M6     g rP   )r  r  r  r  r6  rv  updater   r  addr  )	r  r  r   r]  r   r   _filesnotinr@   rL   s	         r8   rC  ,treemanifest.filesnotin.<locals>._filesnotin  s    xx288#BIIbiiHHJHHJr&)=!B'LL/ * iiYY&IIbkk"o.  r(   )rM  rX  r1  r  )rL   r   r   r]  rC  r@   s   `   @@r8   r1  treemanifest.filesnotin  sZ     u%BU#B==$$	/" 	D"r(   c                .    [         R                  " U 5      $ rP   r4  rR   s    r8   _alldirstreemanifest._alldirs  r8  r(   c                    U R                   $ rP   )rG  rR   s    r8   r5  treemanifest.dirs  s    }}r(   c                   U R                  5         [        U5      u  p#U(       a?  U R                  U5        X R                  ;   a  U R                  U   R	                  U5      $ gUS-   nX@R                  ;   =(       d    X@R
                  ;   $ )NFr  )r  r  r  r6  r?  r  )rL   r>  topdirr  dirslashs        r8   r?  treemanifest.hasdir  so    

%c*NN6"#zz&)0088:::%C^^)CCr(   c              #    #    UR                  5       (       a  [        U 5       Sh  vN   g[        UR                  5       5      nU R	                  U5       H  nX2;   a  UR                  U5        Uv   M     UR                  S5        [        U5       H-  nU R                  U5      (       a  M  UR                  US5        M/     g N7f)zhGenerates matching file names.

It also reports nonexistent files by marking them bad with match.bad().
Nr(   )
rM  rN  r  r@   _walkrP  rQ  rO  r?  rR  rS  s       r8   r/  treemanifest.walk  s     
 <<>>Dz!!5;;=!**U#BzBH	 $ 	S,B;;r??		"d#  "s   $CCBC.Cc              #    #    UR                  U R                  SS 5      nU(       d  gU R                  5         U R                  U5      n[	        [        U R                  5      [        U R                  5      -   5       Hp  nX0R                  ;   a&  U R                  U5      nU" U5      (       a  Uv   M6  M8  U(       a  USS U;   d  MJ  U R                  U   R                  U5       Sh  vN   Mr     g N	7f)z5Recursively generates matching file names for walk().Nr#   )
visitchildrensetr  r  r  rO  r"  r6  r  r  rP  )rL   r   r  r  fullps        r8   rP  treemanifest._walk  s     &&tyy"~6 	

))%0TZZ(4+<<=AKKa(<<K   #2%#zz!}225999 > :s   CC5!C5)C3*
C5c                n    UR                  5       (       a  U R                  5       $ U R                  U5      $ )zCrecursively generate a new manifest filtered by the match argument.)rM  r   _matches_inner)rL   r   s     r8   rX  treemanifest._matches  s*    <<>>99;""5))r(   c                l   UR                  5       (       a  U R                  5       $ UR                  U R                  S S 5      nUS:X  a  U R                  5       $ [	        U R
                  U R                  5      nU(       d  U$ U R                  5         U R                   Hy  nUS:w  a  XB;  a  M  U R                  U5      nU" U5      (       d  M0  U R                  U   UR                  U'   X@R                  ;   d  M]  U R                  U   UR                  U'   M{     U R                  U5      nU R                  R                  5        HM  u  pgU(       a  US S U;  a  M  UR                  U5      nUR                  5       (       a  M?  XR                  U'   MO     UR                  5       (       d  SUl        U$ )Nr#   r  r  T)rM  r   rS  r  r  r  r  r  r  r  r  r6  rv  rW  r  r  )	rL   r   r  retr   rT  r>  r  rW  s	            r8   rW  treemanifest._matches_inner  sY   <<>>99;&&tyy"~6F?99;4--tyy9J

++B BOMM"%E <<![[_CJJrN[[ !%R

2 " ))%0))+ICSb.##E*A::<<!"		# , ||~~CJ
r(   c                    [        5       erP   )FastdeltaUnavailable)rL   r  r  s      r8   r  treemanifest.fastdeltaB  s     #$$r(   c                V  ^ ^^	^
 U(       aG  UR                  5       (       d2  T R                  U5      nUR                  U5      nUR                  UTS9$ 0 m
[        T R                  5      m	UU	U
U 4S jn/ nU" T X5        U(       a$  UR                  5       u  pxU" XxU5        U(       a  M$  T
$ )r[  r\  c                P  > U R                   UR                   :X  a#  U R                  (       d  UR                  (       d  gU R                  5         UR                  5         TR                  X5        U R                  R                  5        H3  u  p4UR                  R                  UT5      nUR                  XE45        M5     UR                  R                  5        H)  u  p5X0R                  ;  d  M  UR                  TU45        M+     U R                  R                  5        H  u  pgU R                  R                  US5      nUR                  R                  US5      n	UR                  R                  US5      n
Xy:w  d  X:w  a  Xx4X44TU R                  U5      '   M}  T(       d  M  STU R                  U5      '   M     UR                  R                  5        HI  u  piX`R                  ;  d  M  UR                  R                  US5      n
SX44TUR                  U5      '   MK     g)z]compares two tree manifests and append new tree-manifests which
needs to be compared to stackNr(   r   )r  r  r  r  r6  rv  rg  r<   r  r  r  )r  r  stackr   r]  r   r   n1fl1n2fl2r   	emptytreeresultrL   s              r8   _iterativediff)treemanifest.diff.<locals>._iterativediffg  s    xx288#BIIbiiHHJHHJr&)XX\\!Y/bX& * )HH$LL)R1 * ))//+iimmB,YY]]2t,iimmB,8sz02y2).DF2;;r?+U.2F2;;r?+ , ))//+YY&))--C0C/:RI.FF2;;r?+ ,r(   )rM  rX  r   r  r  pop)rL   r   r   r   r]  rh  stacklsr  r  rf  rg  s   `  `     @@r8   r   treemanifest.diffG  s    2 u%BU#B772U7++ !3!34		G 	G> tR)[[]FB27+ g r(   c                    U R                   (       + =(       a1    UR                   (       + =(       a    U R                  UR                  :H  $ rP   r  )rL   r   s     r8   unmodifiedsincetreemanifest.unmodifiedsince  s+    ;;Kryy=KTZZ2885KKr(   c                   U R                   n[        U R                  U5       Hd  u  pEnUS:X  a  US-   nXRS4X4'   M  SU;   a   XPU'   U(       a  U R                  XF5        M=  M?  XPR                  U'   U(       d  MV  X`R
                  U'   Mf     g )Nr   r  F)r  r9   rx   rb  r  r  )rL   r   r  selflazyr4   r5   rB   s          r8   r  treemanifest.parse  s    
 >>t}}d3HA"TzH  !u5
 QLL' 
 "#A2%'KKN' 4r(   c                T    U R                  5         [        U R                  5       5      $ )z3Get the full data of this manifest as a bytestring.)r  rC   r   rR   s    r8   r   treemanifest.text  s    

T%%'((r(   c                   U R                  5         U R                  nU R                  R                  5        VVs/ s H  u  p#USS US   S4PM     nnnU R                   Vs/ s H!  o"SS U R                  U   R
                  S4PM#     nnU R                   Vs/ s H  ofU R                  U   U" U5      4PM     nn[        [        XW-   U-   5      5      $ s  snnf s  snf s  snf )zGet the full data of this directory as a bytestring. Make sure that
any submanifests have been written first, so their nodeids are correct.
Nr#   r   r   )	r  r7   r  rv  r6  r  r  rC   rO  )rL   r7   r   r  lazydirsr5  r4   r@   s           r8   dirtexttreemanifest.dirtext  s     	



59^^5I5I5KL5KTQQsVQqT4(5KL=AZZHZ3BA,,d3ZH8<D1T[[^U1X.DVDL83455 MHDs   C"(C!C!c                "   ^^ UU4S jnX0l         g )Nc                B   > U R                  T" 5       T5        SU l        g r  )r  r  )r   gettextr  s    r8   _load_for_read)treemanifest.read.<locals>._load_for_read  s    GGGI{+AHr(   )r  )rL   r{  r  r|  s    `` r8   readtreemanifest.read  s    
	 (r(   c                  ^ U R                  5         UR                  5         UR                  5         [        U R                  5      mU4S jnUR                  U R                  S S 5      nU R                  U5      nUS:X  d  US:X  a  S nU R                  R                  5        HK  u  pxU(       a  US S U;  a  M  U" X5      n	U" X'5      n
XR                  R                  :X  a  XpU" XX5        MM     g )Nc                   > U R                   R                  U5      nU(       a  US   $ U R                  R                  UT5      nUc   eUR                  $ rH   )r  rg  r6  r  )rW  r   ldtreerf  s       r8   getnode+treemanifest.writesubtrees.<locals>.getnode  sK    #B!u77;;q),D###::r(   r#   r  r  )	r  r  r  rS  r  r  r6  rv  r  )rL   r]  r   writesubtreer   r  r  r   r  subp1subp2rf  s              @r8   writesubtreestreemanifest.writesubtrees  s     	





 !3!34		 &&tyy"~6))%0GuEzz'')GA3Bu,BNEBNE**111$ue3 *r(   c              #  d  #    U(       a$  UR                  U R                  SS 5      (       d  gU(       a  U" U R                  SS 5      (       a  U v   U R                  5         U R                  5         U R                  R                  5        H  u  p#UR                  US9 Sh  vN   M     g N	7f)zReturns an iterator of the subtrees of this manifest, including this
manifest itself.

If `matcher` is provided, it only returns subtrees that match.
Nr#   )matcher)visitdirr  r  r  r6  rv  walksubtrees)rL   r  r   r  s       r8   r  treemanifest.walksubtrees  s      7++DIIcrN;;'$))CR.11J

zz'')GA(((999 *9s   B"B0$B.%
B0)r  r  r6  r  r  r  r  r  r  rx   r  )r(   r(   )r>  r\   r   r\   )r)  r\   rd   r\   r   )r   r\   rd   re   )r  zUnion[Set[bytes], bytes]rd   zOptional[Set[bytes]])r  r  r  r  r   r  rg   )r  r\   rd   re   )rd   z9Iterator[Tuple[bytes, Union[bytes, treemanifest], bytes]])rd   z2Iterator[Tuple[bytes, Union[bytes, treemanifest]]]r  r  )r4   r\   rd   r   rP   )r4   r\   rf  r  rd   r  )r4   r\   rd   r\   r4   r\   rd   r   )r4   r\   rd   re   )r4   r\   r  r\   r7   r\   rd   re   )r4   r\   r5   r\   rd   re   )r4   r\   r7   r\   rd   re   rd   r  )r   r  r   r  rd   r  r  r  r  )r   r   rd   r  )r  r    r  r  rd   ztuple[ByteString, ByteString]r  )r   r  r   r  r   r   rd   r   )r   r  rd   r   )r   r\   r  &Callable[[bytes, bytes], treemanifest]rd   re   r   )r{  zCallable[[], ByteString]r  r  rd   re   )
r]  r  r   r  r  zHCallable[[Callable[[treemanifest], None], bytes, bytes, MatcherT], None]r   r   rd   re   )r  r  rd   zIterator[treemanifest])9ri   rj   rk   rl   __annotations__rM   r  r  r  r  r  r   r  r  r  r   	strmethodr  r>  r  r  r   rv  r|  r   r#  rS   r   rg  r   r7   r]   r   r  r   r  rb  r   r1  r  rG  r5  r?  r/  rP  rX  rW  r  r   rn  r  r   rw  r~  r  r  rn   rQ   r(   r8   r  r  U  s?   
K$$L4 "-	 ,# HP 

 


+	B+	% I)%$
/"+; (&"4 =A'9	> # #	D$2:$*'R%%)E%	&% %)	EE "E 	E

ENL(( <( 
	(6)
	6	()	( <	( 
		((4(4 (4
	(4 (4 
(4V -1:):	: :r(   r  c                     ^  \ rS rSrSrSrU 4S jrU 4S jrS rU 4S jr	U 4S jr
U 4S	 jrU 4S
 jrU 4S jrU 4S jrSU 4S jjrSU 4S jjrSrU =r$ )manifestfulltextcachei  zFile-backed LRU cache for the manifest cache

File consists of entries, up to EOF:

- 20 bytes node, 4 bytes length, <length> manifest data

These are written in reverse cache order (oldest to newest).

s   manifestfulltextcachec                N   > [         TU ]  U5        SU l        SU l        S U l        g r  )superrM   r  _read_opener)rL   max	__class__s     r8   rM   manifestfulltextcache.__init__  s%    
r(   c                6  > U R                   (       d  U R                  c  g  U R                  U R                  5       n[        TU ]  n UR                  S5      n[        U5      S:  a  O^ [        R                  " SUR                  S5      5      S   n[        UR                  U5      5      n[        U5      U:w  a  O
U" X55        M  S S S 5        SU l         SU l        g ! [        R                   a     M.  f = f! , (       d  f       N8= f! [         a     NGf = f)NTr      >L   r   F)r  r  _filer  r   r~  r.   r  unpackr   r  OSErrorr  )rL   fpr  r  r  r   r  s         r8   r~  manifestfulltextcache.read  s    ::-	djj)Rg)772;D4y2~%}}UBGGAJ?B &bggdm4E5zT)$  *( 
 "<<  *)   		sR   D -C:+)C4C:D C73C:6C77C::
DD D 
DDc           	     J   U R                   (       a  U R                  c  g  U R                  U R                  SSSS9 nU R                  R                  n UR
                  U R                  ;   ao  UR                  UR
                  5        UR                  [        R                  " S[        UR                  5      5      5        UR                  UR                  5        X R                  L a  OUR                  nM  S S S 5        g ! , (       d  f       g = f! [         a     g f = f)N   wT)
atomictemp
checkambigr  )r  r  r  _headr2   r   _cachewriter  r  r.   r   r  )rL   r  r  s      r8   r  manifestfulltextcache.write4  s    {{dll2	

DTd  zzxx4;;.*UC

O!DE,zz)99D 	    		 		s/   D B>D;D 
DD D 
D"!D"c                b   > U R                   (       d  U R                  5         [        TU ]  5       $ rP   )r  r~  r  r   rL   r  s    r8   r   manifestfulltextcache.__len__P  s     zzIIKw  r(   c                d   > U R                   (       d  U R                  5         [        TU ]  U5      $ rP   )r  r~  r  r   rL   r  r  s     r8   r   "manifestfulltextcache.__contains__U  s#    zzIIKw#A&&r(   c                b   > U R                   (       d  U R                  5         [        TU ]  5       $ rP   )r  r~  r  rS   r  s    r8   rS   manifestfulltextcache.__iter__Z  s!    zzIIKw!!r(   c                   > U R                   (       d  U R                  5         U R                  R                  U5      U R                  Ln[
        TU ]  U5      nU(       a  SU l        U$ r-  )r  r~  r  rg  r  r  r   r  )rL   r  setdirtyr   r  s       r8   r   !manifestfulltextcache.__getitem___  sL    zzIIK;;??1%TZZ7#A&DKr(   c                t   > U R                   (       d  U R                  5         [        TU ]  X5        SU l        g r-  )r  r~  r  r   r  )rL   r  r  r  s      r8   r   !manifestfulltextcache.__setitem__i  s'    zzIIKA!r(   c                t   > U R                   (       d  U R                  5         [        TU ]  U5        SU l        g r-  )r  r~  r  r   r  r  s     r8   r   !manifestfulltextcache.__delitem__o  s'    zzIIKAr(   c                `   > U R                   (       d  U R                  5         [        TU ]  XS9$ )N)rf  )r  r~  r  rg  )rL   r  rf  r  s      r8   rg  manifestfulltextcache.getu  s$    zzIIKw{1{..r(   c                l   > [         TU ]  5         U(       a  SU l        U R                  5         SU l        g )NTF)r  r  r  r  r  )rL   clear_persisted_datar  s     r8   r  manifestfulltextcache.clearz  s&    DKJJL
r(   )r  r  r  rP   r   )ri   rj   rk   rl   r   r  rM   r~  r  r   r   rS   r   r   r   rg  r  rn   __classcell__r  s   @r8   r  r    sK     %E88!
'
"
/
 r(   r     c                      \ rS rSrSrSrg)r]  i  z;Exception raised when fastdelta isn't usable on a manifest.rQ   N)ri   rj   rk   rl   r   rn   rQ   r(   r8   r]  r]    s    Er(   r]  c                  n   \ rS rSrSr   S&S jrS rS r\S 5       r	S'S(S	 jjr
S
 r  S)   S*S jj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S rS rS rSSS\R:                  SS4S jr     S+S jrS r S r!S r"S  r#S! r$     S,S" jr%\S# 5       r&\&RN                  S$ 5       r&S%r(g)-manifestrevlogi  zfA revlog that stores manifest texts. This is responsible for caching the
full-text manifest contents.
NFc           
     X   Xl         SnSnSn[        USS5      n	U	b6  U	R                  SU5      nU	R                  SS5      nU	R                  SS5      nU=(       d    UU l        [	        U5      U l        U(       a  U R                  (       d   USU	-  45       eS	n
U(       a  S
U-   U
-   n
X0l        U(       a  X@l        O	SU 0U l        [        R                  " U[        R                  U R                  4U
[        U5      (       + S[        US9U l        U R                  R                  U l        g)a  Constructs a new manifest revlog

`indexfile` - used by extensions to have two manifests at once, like
when transitioning between flatmanifeset and treemanifests.

`treemanifest` - used to indicate this is a tree manifest revlog. Opener
options can also be used to make this a tree manifest revlog. The opener
option takes precedence, so if it is set to True, we ignore whatever
value is passed in to the constructor.
r  FoptionsN   manifestcachesize   treemanifests   persistent-nodemaps
   opts is %rs
   00manifests   meta/r(   T)targetradixr  mmaplargeindexupperboundcomppersistentnodemap)r  getattrrg  _treeondiskr  _fulltextcacher  _dirlogcacher   revlog_constantsKIND_MANIFESTLOGr   MAXCOMPRESSION_revlogr   )rL   r  openerr  dirlogcacher  	cachesizeoptiontreemanifestr  optsr  s              r8   rM   manifestrevlog.__init__  s   $ + 	"!vy$/!5yAI!%/5!A $)> F-=3I>##AdMD,@%AA#tOe+E	  +!$dD}}$55tyyA:~)/	
 \\''
r(   c                    U R                   $ )zreturn an actual revlog instance if any

This exist because a lot of code leverage the fact the underlying
storage is a revlog for optimization, so giving simple way to access
the revlog instance helps such code.
)r  rR   s    r8   
get_revlogmanifestrevlog.get_revlog  s     ||r(   c                $  ^^ [        US5      (       d  gUR                  U R                  l        UR	                  UR
                  5      c  g[        R                  " U5      m[        R                  " U 5      mUU4S jnUR                  U5        g)z1Persist the manifestfulltextcache on lock release	_wlockrefNc                   > U (       d  g T" 5       nT" 5       nUb  Uc  g UR                   R                  S5      ULa  g UR                  R                  5         g r   )manifestlog
getstorager  r  )successreporL   manifestrevlogrefreporefs      r8   persistmanifestcacheEmanifestrevlog._setupmanifestcachehooks.<locals>.persistmanifestcache  sR    9D$&D|t|**3/t;%%'r(   )	hasattr	wcachevfsr  r  _currentlockr  weakrefref
_afterlock)rL   r  r  r  r  s      @@r8   _setupmanifestcachehooks'manifestrevlog._setupmanifestcachehooks  sn    t[))&*nn#T^^,4++d##KK-	( 	,-r(   c                    U R                   $ rP   )r  rR   s    r8   fulltextcachemanifestrevlog.fulltextcache  s    """r(   c                    U R                   R                  5         U R                  R                  US9  U R                  U 0U l        g N)r  )r  clearcachesr  r  r  r  rL   r  s     r8   r  manifestrevlog.clearcaches  s;      "!!7K!L!YY-r(   c                    U(       a  U R                   (       d   eXR                  ;  aC  [        U R                  U R                  UU R                  U R                   S9nX R                  U'   U R                  U   $ )N)r  )r  r  r  r  r  )rL   r   mfrevlogs      r8   dirlogmanifestrevlog.dirlog  sp    ####%%%%""!!!--H $,a   ##r(   c
                    X@R                   ;  a
  [        5       e[        U5        [        R                  " [        U5       V
s/ s H  oS4PM     sn
[        U5       V
s/ s H  oS4PM     sn
5      nUR                  U R                   U   U5      u  pU R                  R                  U5      U4n[        R                  " U5      nU R                  R                  XX4X^5      nU R                  R                  U5      nUb  XR                   U'   U$ s  sn
f s  sn
f ! [         a    U R                  (       aY  U(       d   S5       eU	(       d   S5       eU" U R                  U5      nU" U R                  U5      nU R                  XUUUXS9nSn NUR!                  5       nU R                  R                  XX4U5      nU R                  R                  U5      n[#        U5      n Nf = f)a  add some manifest entry in to the manifest log

input:

  m:           the manifest dict we want to store
  transaction: the open transaction
  p1:          manifest-node of p1
  p2:          manifest-node of p2
  added:       file added/changed compared to parent
  removed:     file removed compared to parent

tree manifest input:

  readtree:    a function to read a subtree
  match:       a filematcher for the subpart of the tree manifest
FTs,   readtree must be set for treemanifest writess/   match must be specified for treemanifest writesr   N)r  r]  r=   heapqmergerO  r  r  revr   r  addrevisionr  r  r  _addtreer   r  )rL   rW  transactionlinkp1p2addedremovedreadtreer   rq  workr  r  
cachedeltar   r  r5   r]  r   s                       r8   rB  manifestrevlog.add  s   8)	,+++*,, E";;%+E]3]U]3$*7O4OqTO4D
 $%;;t/A/A"/Et#L I))"-y8J;;y)D,,**4RC !!#&A,  $-q!G 44 $ 	, P!PPxPPPudii,dii,MMD"b( "  !	vvxll..t$BOLL%%c*%dO	'	,s9   AD DD D
,BD 
D A2G&AG&%G&c                  ^ ^^^ T R                   S:w  a<  UR                  U5      (       d  UR                  U5      (       a  UR                  5       $ UUU U4S jnUR                  XEX5        UR	                  5       n	S n
T R                   S:w  aG  XR	                  5       :X  a  UR                  5       n
O#XR	                  5       :X  a  UR                  5       n
U
(       dV  T R
                  R                  U	TTUR                  5       UR                  5       5      nT R
                  R                  U5      n
UR                  U
5        U
$ )Nr(   c                r   > TR                  U R                  5       5      nUR                  U TTUUS S TUS9	  g )Nr  r   )r  r>  rB  )	r  r  r  r   sublogr	  r  rL   r  s	        r8   r  -manifestrevlog._addtree.<locals>.writesubtree_  sC    [[,FJJ!  
r(   )r  rn  r  r  rw  r  r  r  )rL   rW  r  r	  r]  r   r  r   r  r   r5   r  s   ` ``  `     r8   r  manifestrevlog._addtreeW  s     99b!!Q%6%6r%:%:668O	 	 	
4yy{99zz|#GGI%GGI,,**k4BGGIC !!#&A 	
		!r(   c                ,    [        U R                  5      $ rP   )r.   r  rR   s    r8   r   manifestrevlog.__len__  s    4<<  r(   c                6    U R                   R                  5       $ rP   )r  rS   rR   s    r8   rS   manifestrevlog.__iter__  s    ||$$&&r(   c                8    U R                   R                  U5      $ rP   )r  r  r  s     r8   r  manifestrevlog.rev  s    ||%%r(   c                8    U R                   R                  U5      $ rP   )r  r  rL   r  s     r8   r  manifestrevlog.node  s    ||  %%r(   c                8    U R                   R                  U5      $ rP   )r  lookuprL   r   s     r8   r"  manifestrevlog.lookup  s    ||""5))r(   c                8    U R                   R                  U5      $ rP   )r  
parentrevsr  s     r8   r&  manifestrevlog.parentrevs  s    ||&&s++r(   c                8    U R                   R                  U5      $ rP   )r  parentsr  s     r8   r)  manifestrevlog.parents      ||##D))r(   c                8    U R                   R                  U5      $ rP   )r  linkrevr  s     r8   r-  manifestrevlog.linkrev      ||##C((r(   c                6    U R                   R                  5       $ rP   )r  	checksizerR   s    r8   r1  manifestrevlog.checksize  s    ||%%''r(   c                8    U R                   R                  U5      $ rP   )r  revisionr  s     r8   r4  manifestrevlog.revision  s    ||$$T**r(   c                8    U R                   R                  U5      $ rP   )r  rawdatar  s     r8   r7  manifestrevlog.rawdata  r+  r(   c                8    U R                   R                  X5      $ rP   )r  revdiff)rL   rev1rev2s      r8   r:  manifestrevlog.revdiff  s    ||##D//r(   c                8    U R                   R                  X5      $ rP   )r  cmp)rL   r  r   s      r8   r?  manifestrevlog.cmp  s    ||++r(   c                8    U R                   R                  U5      $ rP   )r  deltaparentr  s     r8   rB  manifestrevlog.deltaparent  s    ||'',,r(   c           
     @    U R                   R                  UUUUUUUS9$ )N)
nodesorderrevisiondataassumehaveparentrevisions	deltamodesidedata_helpers
debug_info)r  emitrevisions)rL   nodesrE  rF  rG  rH  rI  rJ  s           r8   rK  manifestrevlog.emitrevisions  s5     ||))!%&?-! * 
 	
r(   c	                B    U R                   R                  UUUUUUUUS9$ )N)alwayscacheaddrevisioncbduplicaterevisioncbrJ  delta_base_reuse_policy)r  addgroup)	rL   deltas
linkmapperr  rO  rP  rQ  rJ  rR  s	            r8   rS  manifestrevlog.addgroup  s8     ||$$#' 3!$; % 	
 		
r(   c                8    U R                   R                  U5      $ rP   )r  rawsizer  s     r8   rX  manifestrevlog.rawsize  r/  r(   c                8    U R                   R                  U5      $ rP   )r  getstrippoint)rL   minlinks     r8   r[  manifestrevlog.getstrippoint  s    ||))'22r(   c                8    U R                   R                  X5      $ rP   )r  strip)rL   r\  r  s      r8   r_  manifestrevlog.strip  s    ||!!'77r(   c                6    U R                   R                  5       $ rP   )r  r@   rR   s    r8   r@   manifestrevlog.files  s    ||!!##r(   c                    [        U[        5      (       d  [        R                  " S5      eU R                  R
                  " XR                  40 UD6$ )Ns"   expected manifestrevlog to clone())rZ   r  r   ProgrammingErrorr  clone)rL   tr
destrevlogkwargss       r8   re  manifestrevlog.clone  sA    *n55(()NOO||!!"&8&8CFCCr(   c                <    U R                   R                  UUUUUS9$ )N)exclusivefilessharedfilesrevisionscounttrackedsize
storedsize)r  storageinfo)rL   rk  rl  rm  rn  ro  s         r8   rp  manifestrevlog.storageinfo  s/     ||'')#)#! ( 
 	
r(   c                .    U R                   R                  $ rP   r  r  rR   s    r8   r  manifestrevlog.opener  s    ||"""r(   c                $    XR                   l        g rP   rs  r#  s     r8   r  rt    s    #r(   )r  r  r  r  r   r  r  )r(   NFr   r  r   rd   re   )NN)r  Iterable[bytes]r  rw  )FNNNN)FFFFF))ri   rj   rk   rl   r   rM   r  r  propertyr  r  r  rB  r  r   rS   r  r  r"  r&  r)  r-  r1  r4  r7  r:  r?  rB  r   CG_DELTAMODE_STDrK  rS  rX  r[  r_  r@   re  rp  r  setterrn   rQ   r(   r8   r  r    sB    =(~.8 # #.
$. J J !JX(T!'&&*,*)(+*0,- "'--
2   $
,)38$D 
  # # ]]$ $r(   r  )manifestctxtreemanifestctxc                  z    \ rS rSrSrS rS r\S 5       r S       SS jjr	S r
SSS jjrSS	 jrSS
 jrSrg)r  i  a  A collection class representing the collection of manifest snapshots
referenced by commits in the repository.

In this situation, 'manifest' refers to the abstract concept of a snapshot
of the list of files in the given commit. Consumers of the output of this
class do not care about the implementation details of the actual manifests
they receive (i.e. tree or flat or lazily loaded, etc).c                P   UR                   U l         SnSn[        USS 5      nUb$  UR                  SU5      nUR                  SU5      nXPl        X0l        U R                  R                  U5        X@l        0 U l        [        R                  " U5      U R                  S'   X`l
        g )NFr  r  r  r  r(   )r  r  rg  _treemanifests
_rootstorer  _narrowmatch_dirmancacher   lrucachedict
_cachesize)rL   r  r  	rootstorenarrowmatchusetreemanifestr  r  s           r8   rM   manifestlog.__init__  s    !//	vy$/"hhHO!5yAI-#006' !%!2!29!=##r(   c                &    U R                  SU5      $ )zWRetrieves the manifest instance for the given node. Throws a
LookupError if not found.
r(   )rg  r  s     r8   r   manifestlog.__getitem__%  s     xxT""r(   c                j    U R                   S L =(       d    U R                   R                  5       (       + $ rP   )r  rM  rR   s    r8   narrowedmanifestlog.narrowed+  s*    %%-K1B1B1I1I1KLLr(   c                z   X R                   R                  US5      ;   a  U R                   U   U   $ U R                  R                  5       (       d9  U R                  R	                  USS 5      (       d  [        U R                  X5      $ U(       aq  U R                  R                  (       a4  U(       a   U R                  U5      R                  U5        [        XU5      nOn[        R                  " [        S5      U-  5      eU(       a  U R                  R                  U5        U R                  (       a  [        U SU5      nO[!        X5      nX R                  R"                  :w  aT  U R                   R                  U5      nU(       d.  [$        R&                  " U R(                  5      nXPR                   U'   XEU'   U$ )zRetrieves the manifest instance for the given node. Throws a
LookupError if not found.

`verify` - if True an exception will be thrown if the node is not in
           the revlog
rQ   Nr#   s9   cannot ask for manifest directory '%s' in a flat manifestr(   )r  rg  r  rM  r  excludeddirmanifestctxr  r  r  r  r  r|  r   Abortr   r  r{  r  r   r  r  )rL   r  r  verifyrW  mancaches         r8   rg  manifestlog.get/  si    $$((r22$$T*400  ''))$$--d3Bi88-d.@.@$MM** OOD)--d3#D5kk$ 	  ##D)""#D#t4+%%,,,((,,T2H,,T__=*2!!$'TNr(   c                8    U R                   R                  U5      $ rP   )r  r  )rL   r  s     r8   r  manifestlog.getstorage`  s    %%d++r(   c                j    U R                   R                  5         U R                  R                  US9  g r  )r  r  r  r  r  s     r8   r  manifestlog.clearcachesc  s*    !##9M#Nr(   c                8    U R                   R                  U5      $ rP   )r  r  r  s     r8   r  manifestlog.revg  s    ""4((r(   c                H    U R                   R                  R                  US9$ )N)r  )r  r  update_caches)rL   r  s     r8   r  manifestlog.update_cachesj  s     &&444MMr(   )r  r  r  r  r  r  N)T)r  r\   r  r\   r  r   rd   AnyManifestCtxr   rv  r   r   )ri   rj   rk   rl   r   rM   r   rx  r  rg  r  r  r  r  rn   rQ   r(   r8   r  r    sh    ?$,# M M 8<//!&/04/	/b,O)Nr(   r  c                  N    \ rS rSr% S\S'   S rSS jrSS jrSS jrSS	 jr	S
r
g)memmanifestctxin  r  _manifestdictc                X    Xl         [        UR                  R                  5      U l        g rP   )_manifestlogr  r  r0   r  )rL   r  s     r8   rM   memmanifestctx.__init__q  s!    ')+*C*C*K*KLr(   c                8    U R                   R                  S5      $ r   r  r  rR   s    r8   _storagememmanifestctx._storageu        ++C00r(   c                v    [        U R                  5      nU R                  5       R                  5       Ul        U$ rP   r  r  r~  r   r  rL   memmfs     r8   r   memmanifestctx.copyx  .    t001"iik..0r(   c                    U R                   $ rP   )r  rR   s    r8   r~  memmanifestctx.read}      !!!r(   Nc                ^    U R                  5       R                  U R                  UUUUUUUS9$ )Nr  )r  rB  r  )rL   r  r	  r
  r  r  r  r   s           r8   r  memmanifestctx.write  s>    }}"" # 	
 		
r(   )r  r  rd   r  rd   r  r  rP   ri   rj   rk   rl   r  rM   r  r   r~  r  rn   rQ   r(   r8   r  r  n  s"    M1
"

r(   r  c                      \ rS rSr% SrS\S'   S rSS jrSS jrSS jr	\
SS	 j5       rSS
 jrSSS jjrSSS jjr SSS.     SS jjjrSSS.     S S jjrSS.SS jjrS!S jrSrg)"r{  i  zpA class representing a single revision of a manifest, including its
contents, its parent revs, and its linkrev.
zOptional[manifestdict]_datac                *    Xl         S U l        X l        g rP   )r  r  r  )rL   r  r  s      r8   rM   manifestctx.__init__  s    '

r(   c                8    U R                   R                  S5      $ r   r  rR   s    r8   r  manifestctx._storage  r  r(   c                    U R                   $ rP   r  rR   s    r8   r  manifestctx.node  r<  r(   c                v    [        U R                  5      nU R                  5       R                  5       Ul        U$ rP   r  r  s     r8   r   manifestctx.copy  r  r(   c                T    U R                  5       R                  U R                  5      $ rP   r  r)  r  rR   s    r8   r)  manifestctx.parents      }}&&tzz22r(   c                D   U R                   Gc  U R                  R                  nU R                  UR                  :X  a&  [        UR                  5      U l         U R                   $ U R                  5       nU R                  UR                  ;   a.  [        R                  " UR                  U R                     5      nO>UR                  U R                  5      n[        U5      nXBR                  U R                  '   [        UR                  U5      U l         U R                   $ rP   )r  r  r  r  r  r  r0   r  r  r   r  r4  r  )rL   ncstorer   r  s        r8   r~  manifestctx.read  s    ::""00BzzRYY&)"**5
 zz ::!4!44#++E,?,?

,KLD >>$**5D )$I6?''

3)"**d;
zzr(   Fc                "   [         R                  " SSSS9  U R                  5       nUR                  U R                  5      nUR                  U5      nU[        :w  a$  XBR                  U5      ;   a  U R                  5       $ U R                  5       $ )zCalls either readdelta or read, based on which would be less work.
readdelta is called if the delta is against the p1, and therefore can be
read quickly.

If `shallow` is True, nothing changes since this is a flat manifest.
sJ   "readfast" is deprecated use "read_any_fast_delta" or "read_delta_parents"   6.9r)   
stacklevel)
r   nouideprecwarnr  r  r  rB  r   r&  	readdeltar~  rL   shallowr  r   rB  s        r8   readfastmanifestctx.readfast  s{     	Y	

 IIdjj!''*'!k5E5Ea5H&H>>##yy{r(   c                .   [         R                  " SSSS9  U R                  5       nUR                  U R                  5      n[
        R                  " UR                  UR                  U5      U5      5      n[        UR                  R                  U5      $ )zReturns a manifest containing just the entries that are present
in this manifest, but not in its p1 manifest. This is efficient to read
if the revlog delta is already p1.

Changing the value of `shallow` has no effect on flat manifests.
sN   "readfast" is deprecated use "read_any_fast_delta" or "read_delta_new_entries"r  r)   r  )r   r  r  r  r  r   	patchtextr:  rB  r  r  r0   rL   r  r  r   r   s        r8   r  manifestctx.readdelta  sw     	]	

 IIdjj!OOEMM%*;*;A*>BCE//77;;r(   Nr  c               V   U R                  5       nUR                  U R                  5      nUR                  U5      nUc  U4nU[        :w  aL  XQ;   aG  [
        R                  " UR                  XT5      5      nU[        UR                  R                  U5      4$ SU R                  5       4$ )+see `imanifestrevisionstored` documentationN)r  r  r  rB  r   r   r  r:  r  r  r0   r~  )rL   valid_basesr  r  r   rB  r   s          r8   read_any_fast_deltamanifestctx.read_any_fast_delta  s     IIdjj!''*&.K'!k&@k =>AU0088!<  diik""r(   Tr  exactc               h   U R                  5       nUR                  U R                  5      nUR                  U5      nUR	                  U5       Vs/ s H  of[
        Ld  M  UPM     nnU(       dZ  XW;   aU  [        R                  " UR                  UR                  U5      U5      5      n[        UR                  R                  U5      $ U(       a  [        U5      S:X  a  U R                  5       $ [        U5      S:X  aJ  US   n[        R                  " UR                  Xd5      5      n[        UR                  R                  U5      $ Uu  p[        R                  " UR                  X5      5      n[        R                  " UR                  X5      5      n[        UR                  R                  U5      n[        UR                  R                  U5      n[        UR                  R                  5      nUR                  5        H$  u  pnX;  a  M  Uc  M  UR                  XU5        M&     U$ s  snf )4see `interface.imanifestrevisionbase` documentationsr   r   )r  r  r  rB  r&  r   r   r  r:  r  r  r0   r.   r~  r   r  )rL   r  r  r  r   rB  r  r)  r   r
  r  d1d2mdr4   new_nodenew_flags                    r8   read_delta_parentsmanifestctx.read_delta_parents  s    IIdjj!''*#..q1F1g5E11F/e.?.?.BA FGA 3 3 ; ;Q??#g,!+99;\Q
Aa 34A 3 3 ; ;Q??FBr!56Br!56Be11992>Be11992>Be1199:B)+)9%X;'FF11	 *:
 I- Gs   H/ H/c               X   U R                   R                  (       a  U R                  USS9$ U R                  5       nUR	                  U R
                  5      n[        R                  " UR                  UR                  U5      U5      5      n[        UR                  R                  U5      $ )r  Tr  )r  r  r  r  r  r  r   r  r:  rB  r  r  r0   r  s        r8   read_delta_new_entries"manifestctx.read_delta_new_entries	  s     %%**7$*GGIIdjj!OOEMM%*;*;A*>BCE//77;;r(   c                @    U R                  5       R                  U5      $ rP   r~  r]   r   s     r8   r]   manifestctx.find)	      yy{$$r(   )r  r  r  r  rg   r  rd   r   r  r   )r  r   rd   r  rP   )r  Optional[Collection[int]]r  r   rd   z"Tuple[Optional[int], manifestdict])r  r   r  r   rd   r  r   )ri   rj   rk   rl   r   r  rM   r  r  r   r  r)  r~  r  r  r  r  r  r]   rn   rQ   r(   r8   r{  r{    s     "!1
 3 3 &<& 26# 	#.# 	#
 
,#0 	    	 
 
 D 9> <%r(   r{  c                  R    \ rS rSr% S\S'   SS jrSS jrSS jrSS jrSS	 jr	S
r
g)memtreemanifestctxi-	  r  _treemanifestc                P    Xl         X l        [        UR                  5      U l        g rP   )r  r  r  r  r  )rL   r  r>  s      r8   rM   memtreemanifestctx.__init__0	  s     '	)+*C*CDr(   c                8    U R                   R                  S5      $ r   r  rR   s    r8   r  memtreemanifestctx._storage5	  r  r(   c                    [        U R                  U R                  S9nU R                  R	                  5       Ul        U$ Nr>  )r  r  r  r  r   r  s     r8   r   memtreemanifestctx.copy8	  s4    "4#4#4$))D"00557r(   c                    U R                   $ rP   )r  rR   s    r8   r~  memtreemanifestctx.read=	  r  r(   Nc                n   ^  U 4S jnT R                  5       R                  T R                  UUUUUUUUS9	$ )Nc                V   > TR                   R                  X5      R                  5       $ rP   r  rg  r~  )r>  r  rL   s     r8   r  *memtreemanifestctx.write.<locals>.readtreeA	  s#    $$((388::r(   r  )r  rB  r  )	rL   r  r	  r
  r  r  r  r   r  s	   `        r8   r  memtreemanifestctx.write@	  sI    	; }}"" # 

 
	
r(   )r  r  r  r  r  rd   r  r  rP   r  rQ   r(   r8   r  r  -	  s"    E
1
"
r(   r  c                      \ rS rSr% S\S'   S rSS jrSS jrSS jrSS jr	\
SS	 j5       rSSS jjr SS
S.     S S jjjrS!S jrSS jrS
SS.     S"S jjrS
S.   SS jjrSSS jjrS#S jrSrg)$r|  iQ	  zOptional[treemanifest]r  c                6    Xl         X l        S U l        X0l        g rP   )r  r  r  r  )rL   r  r>  r  s       r8   rM   treemanifestctx.__init__T	  s    '	

r(   c                <   U R                   R                  nUR                  5       (       dM  UR                  U R                  S S 5      (       d*  [        U R                   R                  U R                  5      $ U R                   R                  U R                  5      $ r   )r  r  rM  r  r  excludedmanifestrevlogr  r  )rL   r  s     r8   r  treemanifestctx._storageb	  s|    ''44!!##''		#277-%%33TYY    ++DII66r(   c                  ^ ^ T R                   Gc  T R                  5       mT R                  T R                  R                  R
                  :X  a0  [        T R                  R                  5      T l         T R                   $ TR                  (       at  [        T R                  R                  T R                  S9nU U4S jnU 4S jnUR                  X#5        UR                  T R                  5        UT l         T R                   $ T R                  TR                  ;   a.  [        R                  " TR                  T R                     5      nO?TR                  T R                  5      n[        U5      nUTR                  T R                  '   [        T R                  R                  T R                  US9T l         T R                   $ )Nr  c                 :   > TR                  T R                  5      $ rP   )r4  r  )rL   r  s   r8   r{  %treemanifestctx.read.<locals>.gettextt	  s     >>$**55r(   c                T   > TR                   R                  XSS9R                  5       $ )NF)r  r  )r>  r  rL   s     r8   r  )treemanifestctx.read.<locals>.readsubtreew	  s*      ,,0050INNPPr(   )r>  r   )r  r  r  r  r  r  r  r  r  r~  r  r  r   r  r4  r  )rL   rW  r{  r  r   r  r  s   `     @r8   r~  treemanifestctx.readk	  sN   ::MMOEzzT..<<CCC)$*;*;*I*IJ
6 zz3 "" !2!2!@!@diiP6Q
 w,		$**%
 zz ::!4!44#++E,?,?

,KLD >>$**5D )$I6?E''

3)%%33
 zzr(   c                    U R                   $ rP   r  rR   s    r8   r  treemanifestctx.node	  r<  r(   c                    [        U R                  U R                  S9nU R                  5       R	                  5       Ul        U$ r  )r  r  r  r~  r   r  r  s     r8   r   treemanifestctx.copy	  s4    "4#4#4$))D"iik..0r(   c                T    U R                  5       R                  U R                  5      $ rP   r  rR   s    r8   r)  treemanifestctx.parents	  r  r(   Fc                8   [         R                  " SSSS9  U R                  5       nU(       ap  UR                  U R                  5      n[
        R                  " UR                  UR                  U5      U5      5      n[        UR                  R                  U5      $ UR                  UR                  U R                  5      5      nU R                  R                  U R                  UR                  U5      5      R!                  5       nU R!                  5       n[#        U R                  R                  U R                  S9nUR%                  U5      R'                  5        H4  u  n	u  u  pu  pU(       d  M  XU	'   U(       d  M#  UR)                  X5        M6     U$ )r  sO   "readdelta" is deprecated use "read_any_fast_delta" or "read_delta_new_entries"r  r)   r  r  )r   r  r  r  r  r   r  r:  rB  r  r  r0   r  rg  r  r  r~  r  r   rv  rb  )rL   r  r  r   r   r0m0r]  r  r4   n0fl0rb  rc  s                 r8   r  treemanifestctx.readdelta	  s9   ^	

 		$**%Ae.?.?.BA FGA 3 3 ; ;Q?? ""599TZZ#89B""&&tyy%**R.AFFHBBd//==499MB-/WWR[->->-@))IRy2qEs

1*	 .A
 Ir(   Nr  c               d   U R                  5       nUR                  U R                  5      nUR                  U5      nUc  U4nU[        :g  =(       a    XQ;   nU(       aU  U(       a  XPR                  5       4$ UR                  U R                  5      nS[        UR                  R                  U5      4$ U(       a  SU R                  US94$ UR                  U5       Vs/ s H  nU[        Ld  M  X;   d  M  UPM     n	nU	(       a  [        U	5      n
O[        U5      n
SU R                  U
S94$ s  snf )r  Nr  )r  r  r  rB  r   _read_storage_delta_shallowr4  r  r  r0   _read_storage_slow_deltar&  r  )rL   r  r  r  r   rB  can_use_deltar   r  r)  	best_bases              r8   r  #treemanifestctx.read_any_fast_delta	  s,    IIdjj!''*&.K#w.M;3M#%E%E%GHHNN4::.l5+>+>+F+FJKK d;;;MNN #--a00' ,-,< 0  
  #GI #K 0Id;;;KLLs   D-/D-6D-c                   U R                  5       nUR                  U R                  5      n[        R                  " UR                  UR                  U5      U5      5      n[        UR                  R                  U5      $ rP   )
r  r  r  r   r  r:  rB  r  r  r0   )rL   r  r   r   s       r8   r  +treemanifestctx._read_storage_delta_shallow	  s\    IIdjj!OOEMM%*;*;A*>BCE//77;;r(   c                $   U R                  5       nUc*  UR                  UR                  U R                  5      5      nU R                  R                  U R                  UR                  U5      5      R                  5       nU R                  5       n[        U R                  R                  U R                  S9nUR                  U5      R                  5        H4  u  nu  u  pxu  pU	(       d  M  XU'   U
(       d  M#  UR                  Xj5        M6     U$ r  )r  rB  r  r  r  rg  r  r  r~  r  r  r   rv  rb  )rL   r  r  r  r]  r  r4   r  r  rb  rc  s              r8   r   (treemanifestctx._read_storage_slow_delta	  s    <$$UYYtzz%:;D""499ejj.>?DDFYY[$++99tyyI)+):):)<%A%	9Br13JJq&	 *=
 	r(   Tr  c                  U R                  5       nUR                  U R                  5      nUR                  U5       Vs/ s H  oU[        Ld  M  UPM     nnU(       d  U R                  XaS9S   $ [        U5      S:X  aR  U(       a;  UR                  U R                  5      n[        UR                  R                  U5      $ U R                  5       $ [        U5      S:X  a`  US   nU(       aE  [        R                  " UR                  XT5      5      n[        UR                  R                  U5      $ U R                  US9$ Uu  pU(       a  [        R                  " UR                  X5      5      n
[        R                  " UR                  X5      5      n[        UR                  R                  U
5      n
[        UR                  R                  U5      n[        UR                  R                  5      nU
R!                  5        H$  u  pnX;  a  M  Uc  M  UR#                  XU5        M&     U$ U R$                  R'                  U R(                  UR+                  U5      5      R                  5       nU R$                  R'                  U R(                  UR+                  U	5      5      R                  5       nU R                  5       nUR-                  U5      n
UR-                  U5      n[/        U R$                  R                  U R(                  S9nU
R!                  5        H$  u  pnX;  a  M  Uc  M  UR#                  XU5        M&     U$ s  snf )r  r  r   r   r  r  )r  r  r  r&  r   r  r.   r4  r  r  r0   r~  r   r  r:  r   r   r  r  rg  r  r  r   r  )rL   r  r  r  r   r  r)  r   r
  r  r  r  r  r4   r  r  r]  r   mcs                      r8   r  "treemanifestctx.read_delta_parents	  s    IIdjj!#..q1F1g5E11F++G+EaHH\QNN4::.#E$7$7$?$?CCyy{"\Q
AOOEMM!$78#E$7$7$?$?CC44!4<<FB__U]]2%9:__U]]2%9:!%"5"5"="=rB!%"5"5"="=rB!%"5"5"="=>-/^^-=)A{ +qH5	 .>
 	&&**499ejjnEJJL&&**499ejjnEJJLYY[WWR[WWR[!%%33		 .0^^-=)A{ +qH5	 .>
 	[ Gs   MMc                   U R                   R                  (       a  U R                  USS9$ U R                  5       nUR	                  U R
                  5      nUR                  U5      4nU R                  XAS9S   $ )r  Tr  r  r   )r  r  r  r  r  r  rB  r  )rL   r  r  r   basess        r8   r  &treemanifestctx.read_delta_new_entries+
  sr     %%**7$*GGIIdjj!""1%''''?BBr(   c                   [         R                  " SSSS9  U R                  5       nUR                  U R                  5      nUR                  U5      nU[        :w  a#  XBR                  U5      ;   a  U R                  US9$ U(       a9  [        UR                  R                  UR                  U R                  5      5      $ U R                  5       $ )zCalls either readdelta or read, based on which would be less work.
readdelta is called if the delta is against the p1, and therefore can be
read quickly.

If `shallow` is True, it only returns the entries from this manifest,
and not any submanifests.
sK   "readdelta" is deprecated use "read_any_fast_delta" or "read_delta_parents"r  r)   r  r  )r   r  r  r  r  rB  r   r&  r  r  r  r0   r4  r~  r  s        r8   r  treemanifestctx.readfast<
  s     	Z	

 IIdjj!''*'!k5E5Ea5H&H>>'>22##++U^^DJJ-G  99;r(   c                @    U R                  5       R                  U5      $ rP   r  r   s     r8   r]   treemanifestctx.findV
  r  r(   )r  r  r  r  r  r  rg   r  r  r   )r  r   rd   AnyManifestDictrP   )r  r  r  r   rd   z%Tuple[Optional[int], AnyManifestDict]r  )r  r   r  r   rd   r2  r   )ri   rj   rk   rl   r  rM   r  r~  r  r   r  r)  r  r  r  r   r  r  r  r]   rn   rQ   r(   r8   r|  r|  Q	  s    !!7B
 3 36 26,M 	,M.,M 	,M
 
/,M\<" 	6 6 	6
 
6r "'CC	C"4%r(   r|  c                  H   ^  \ rS rSr% SrS\S'   S\S'   U 4S jrS rSrU =r	$ )	excludeddiriZ
  a  Stand-in for a directory that is excluded from the repository.

With narrowing active on a repository that uses treemanifests,
some of the directory revlogs will be excluded from the resulting
clone. This is a huge storage win for clients, but means we need
some sort of pseudo-manifest to surface to internals so we can
detect a merge conflict outside the narrowspec. That's what this
class is: it stands in for a directory whose node is known, but
whose contents are unknown.
r  r  r  c                j   > [         TU ]  X5        X0l        X0R                  S'   SU R                  S'   g )Nr(   r   )r  rM   r  r  r  )rL   r  r>  r  r  s       r8   rM   excludeddir.__init__i
  s1    ,
  CCr(   c                    U $ rP   rQ   rR   s    r8   r   excludeddir.copyv
  rU   r(   r  )
ri   rj   rk   rl   r   r  rM   r   rn   r  r  s   @r8   r4  r4  Z
  s%    	   r(   r4  c                  8    \ rS rSrSrS rS rS	S
S jjrS rSr	g)r  iz
  zBcontext wrapper for excludeddir - see that docstring for rationalec                (    Xl         X l        X0l        g rP   )r  r  r  )rL   r  r>  r  s       r8   rM   excludeddirmanifestctx.__init__}
  s    *	
r(   c                X    [        U R                  U R                  U R                  5      $ rP   )r4  r  r  r  rR   s    r8   r~  excludeddirmanifestctx.read
  s    4--tyy$**EEr(   c                "    U R                  5       $ rP   )r~  )rL   r  s     r8   r  excludeddirmanifestctx.readfast
  s    yy{r(   c                H    [         R                  " SU R                  -  5      e)Ns.   attempt to write manifest from excluded dir %sr   rd  r  )rL   argss     r8   r  excludeddirmanifestctx.write
  s!    $$=		I
 	
r(   )r  r  r  Nr   )r  r   )
ri   rj   rk   rl   r   rM   r~  r  r  rn   rQ   r(   r8   r  r  z
  s    L
F
r(   r  c                  <    \ rS rSrSrS rS rS rS rS r	S r
S	rg
)r	  i
  aD  Stand-in for excluded treemanifest revlogs.

When narrowing is active on a treemanifest repository, we'll have
references to directories we can't see due to the revlog being
skipped. This class exists to conform to the manifestrevlog
interface for those directories and proactively prevent writes to
outside the narrowspec.
c                    Xl         X l        g rP   )r  r  )rL   r  r>  s      r8   rM   excludedmanifestrevlog.__init__
  s    *	r(   c                H    [         R                  " SU R                  -  5      e)Ns(   attempt to get length of excluded dir %srA  rR   s    r8   r   excludedmanifestrevlog.__len__
  !    $$7$))C
 	
r(   c                H    [         R                  " SU R                  -  5      e)Ns'   attempt to get rev from excluded dir %srA  r  s     r8   r  excludedmanifestrevlog.rev
  s!    $$6B
 	
r(   c                H    [         R                  " SU R                  -  5      e)Ns+   attempt to get linkrev from excluded dir %srA  r  s     r8   r-  excludedmanifestrevlog.linkrev
  s!    $$:TYYF
 	
r(   c                H    [         R                  " SU R                  -  5      e)Ns(   attempt to get node from excluded dir %srA  r  s     r8   r  excludedmanifestrevlog.node
  rI  r(   c                    g rP   rQ   )rL   rB  rh  s      r8   rB  excludedmanifestrevlog.add
  s     	r(   )r  r  N)ri   rj   rk   rl   r   rM   r   r  r-  r  rB  rn   rQ   r(   r8   r	  r	  
  s%    







r(   r	  )r1   r\   )r1   r\   r   r   r   r   )r   N)
rW  r    r   r\   r  r   r  zOptional[int]rd   zTuple[int, int])r3   rw  rd   re   )r  r    rq  z Iterable[Tuple[int, int, bytes]]rd   zTuple[bytes, ByteString]r  )W
__future__r   r  r  r  typingr  r   r   r   r   r   r	   r
   r   r   r   r   i18nr   interfaces.typesr   r  r   r   r    r   r   r   r-  r   r   r   r   r   r   
interfacesr   revlogutilsr   r  TYPE_CHECKINGr    	importmodr!   r  r  r9   rC   rE   rp   ry   r   r/   rc   lazymanifestr   AttributeErrorimanifestdictr  r  r=   r  r  r  r  r  r  r  	Exceptionr]  imanifeststorager  r  r2  imanifestlogr  imanifestrevisionwritabler  imanifestrevisionstoredr{  r  r|  r4  r  r	  rQ   r(   r8   <module>rc     sh   #          

 
 
 

 

9
%""  $ 6
 2$ $N )} }@
"((M
u$:++ u$r ?C(((!$(.;((V!!'! !2 	m
::++ m
:`zD-- z~ F9 Fr$Z00 r$l 78l23eN*)) eNP
Z99 
>]%*44 ]%@!
== !
HF%j88 F%R, @
_ 
*(^ (cD  "!M"s   H HH