
    6h̅                       S SK Jr  S SKrS SKrS SKrS SKrS SKrSSKJrJ	r	  SSK
Jr  \R                  (       a  S SKrSSKJrJrJrJr  SSKJr  SSKJr  \R                  (       a  S S	KJrJr  \R0                  r\R4                  r\R8                  r\R<                  r\R@                  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r0Sr1Sr2Sr3Sr4\Rj                  " SSS9 " S S5      5       r6S  r7 " S! S"5      r8 " S# S$\85      r9 " S% S&\95      r: " S' S(\85      r;\Rx                  4   S2S) jjr=S* r> " S+ S,\95      r? " S- S.\?5      r@S/ rAS0 rBS1 rCg)3    )annotationsN   )nullrevsha1nodeconstants)attr)errorpycompatrevlogutilsutil)nodemap)	constants)Any
ByteString                @         i   i   i   i   i    i @  i   TF)slotsinitc                  8   \ rS rSrSr\R                  " 5       r\R                  " 5       r\R                  " 5       r	\R                  " 5       r
\R                  " 5       r\R                  " 5       r\R                  " 5       r\R                  " 5       r\R                  " 5       r\R                  " 5       r        S%S jr\S 5       r\S 5       rS rS rS	 rS
 rS r\S 5       r\S 5       r\S 5       rS r\S&S j5       r\S 5       r \S 5       r!\!RD                  S 5       r#\S 5       r$\S 5       r%\%RD                  S 5       r&\S 5       r'\S 5       r(\S 5       r)\S 5       r*\S 5       r+\S 5       r,\S 5       r-\S 5       r.S r/S&S  jr0S! r1S" r2S# r3S$r4g)'DirstateItemP   a  represent a dirstate entry

It hold multiple attributes

# about file tracking
- wc_tracked: is the file tracked by the working copy
- p1_tracked: is the file tracked in working copy first parent
- p2_info: the file has been involved in some merge operation. Either
           because it was actually merged, or because the p2 version was
           ahead, or because some rename moved it there. In either case
           `hg status` will want it displayed as modified.

# about the file state expected from p1 manifest:
- mode: the file mode in p1
- size: the file size in p1

These value can be set to None, which mean we don't have a meaningful value
to compare with. Either because we don't really care about them as there
`status` is known without having to look at the disk or because we don't
know these right now and a full comparison will be needed to find out if
the file is clean.

# about the file state on disk last time we saw it:
- mtime: the last known clean mtime for the file.

This value can be set to None if no cachable state exist. Either because we
do not care (see previous section) or because we could not cache something
yet.
Nc	                   Xl         X l        X0l        Xpl        Xl        S U l        S U l        S U l        S U l        SU l	        Uc  SnSnOUS   c  SnU(       a  US   U l        US   U l        U(       a  US   u  U l        U l        U l	        g g )NFr   r   r   )
_wc_tracked_p1_tracked_p2_info_fallback_exec_fallback_symlink_mode_size_mtime_s	_mtime_ns_mtime_second_ambiguous)	self
wc_tracked
p1_trackedp2_infohas_meaningful_datahas_meaningful_mtimeparentfiledatafallback_execfallback_symlinks	            8/usr/lib/python3/dist-packages/mercurial/pure/parsers.py__init__DirstateItem.__init__{   s     &%+!1

',$!#( "'A&#( '*DJ'*DJ
 q!	,	      c                6   [        U[        -  5      n[        U[        -  5      nSnU[        7-  (       a  SnSnSnU[        -  (       a	  U[
        -  nSn	U[        -  (       a	  U[        -  n	U(       a^  [        R                  S:X  d   eU[        -  (       a  SnOSnU[        -  (       a  U[        R                  -  nOU[        R                  -  nU[        -  n
U " [        U[        -  5      [        U[         -  5      [        U["        -  5      UUXrX4U
44UU	S9$ )z,Build a new DirstateItem object from V2 dataNFr   i  i  )r+   r,   r-   r.   r/   r0   r1   r2   )boolDIRSTATE_V2_HAS_MODE_AND_SIZEDIRSTATE_V2_HAS_MTIME&DIRSTATE_V2_EXPECTED_STATE_IS_MODIFIEDDIRSTATE_V2_HAS_FALLBACK_EXECDIRSTATE_V2_FALLBACK_EXEC DIRSTATE_V2_HAS_FALLBACK_SYMLINKDIRSTATE_V2_FALLBACK_SYMLINKstatS_IXUSRDIRSTATE_V2_MODE_EXEC_PERMDIRSTATE_V2_MODE_IS_SYMLINKS_IFLNKS_IFREG"DIRSTATE_V2_MTIME_SECOND_AMBIGUOUSDIRSTATE_V2_WDIR_TRACKEDDIRSTATE_V2_P1_TRACKEDDIRSTATE_V2_P2_INFO)clsflagssizemtime_smtime_nshas_mode_sizer/   moder1   r2   second_ambiguouss              r3   from_v2_dataDirstateItem.from_v2_data   s!    U%BBC#E,A$AB::: "M#( 00!$==M33$'CC<<5(((1122$$ #EEE$<<=E$::;!445 -!5 <L(MN'-	
 		
r6   c           	     j   US:X  a  U " SSSS9$ US:X  a  U " SS9$ US:X  a(  U[         :X  a  SnSnOU[        :X  a  SnSnOSnSnU " XVS9$ US	:X  aD  U[        :X  a  U " SSS
9$ U[         :X  a  U " SSS9$ U[        :X  a  U " SSSX#S4S9$ U " SSX#USS44S9$ [        S[        R
                  " U5      -  5      e)zBuild a new DirstateItem object from V1 data

Since the dirstate-v1 format is frozen, the signature of this function
is not expected to change, unlike the __init__ one.
   mT)r+   r,   r-      a)r+      rF)r,   r-      n)r+   r-   )r+   r,   )*   r   F)r+   r,   r/   r0   r   )r+   r,   r0   zunknown state: %s)	NONNORMALFROM_P2AMBIGUOUS_TIMERuntimeErrorr	   sysstr)rJ   staterP   rL   mtimer,   r-   s          r3   from_v1_dataDirstateItem.from_v1_data   s    D=$4FFd]$''d]y !
"
!
*>>d]wdD99"dt<<.(##).$(#?	  ##$(50A#B  2X__U5KKLLr6   c                     SU l         SU l        g)zMark a file as "possibly dirty"

This means the next status call will have to actually check its content
to make sure it is correct.
N)r'   r(   r*   s    r3   set_possibly_dirtyDirstateItem.set_possibly_dirty   s     r6   c                b    SU l         SU l        Xl        X l        Uu  U l        U l        U l        g)aI  mark a file as "clean" cancelling potential "possibly dirty call"

Note: this function is a descendant of `dirstate.normal` and is
currently expected to be call on "normal" entry only. There are not
reason for this to not change in the future as long as the ccode is
updated to preserve the proper state of the non-normal files.
TN)r    r!   r%   r&   r'   r(   r)   )r*   rP   rL   r`   s       r3   	set_cleanDirstateItem.set_clean  s1      

FKCt~t'Cr6   c                .    SU l         SU l        SU l        g)zemark a file as tracked in the working copy

This will ultimately be called by command like `hg add`.
TN)r    r'   r(   rd   s    r3   set_trackedDirstateItem.set_tracked  s    
  
 r6   c                J    SU l         SU l        SU l        SU l        SU l        g)zjmark a file as untracked in the working copy

This will ultimately be called by command like `hg remove`.
FN)r    r%   r&   r'   r(   rd   s    r3   set_untrackedDirstateItem.set_untracked  s(    
 !

r6   c                n    U R                   (       a$  SU l         SU l        SU l        SU l        SU l        gg)zremove all "merge-only" information from a DirstateItem

This is to be call by the dirstatemap code when the second parent is dropped
FN)r"   r%   r&   r'   r(   rd   s    r3   drop_merge_dataDirstateItem.drop_merge_data'  s3    
 ==!DMDJDJ DM!DN r6   c                "    U R                  5       $ N)_v1_moderd   s    r3   rP   DirstateItem.mode3      }}r6   c                "    U R                  5       $ rt   )_v1_sizerd   s    r3   rL   DirstateItem.size7  rw   r6   c                "    U R                  5       $ rt   )	_v1_mtimerd   s    r3   r`   DirstateItem.mtime;  s    ~~r6   c                    U R                   nUc  gU R                  nUu  pEnX$:w  a  gUS:X  d  US:X  a  U R                  (       a  ggX5:H  $ )NFr   T)r'   r(   r)   )r*   other_mtimeself_secself_ns	other_secother_nsrQ   s          r3   mtime_likely_equal_to"DirstateItem.mtime_likely_equal_to?  s\    ==..0;-	- ]gl ++  &&r6   c                F    U R                   (       d  gU R                  5       $ )a  
States are:
  n  normal
  m  needs merging
  r  marked for removal
  a  marked for addition

XXX This "state" is a bit obscure and mostly a direct expression of the
dirstatev1 format. It would make sense to ultimately deprecate it in
favor of the more "semantic" attributes.
   ?)any_tracked	_v1_staterd   s    r3   r_   DirstateItem.stateU  s     ~~r6   c                    U R                   SL$ )ai  True if "fallback" information are available for the "exec" bit

Fallback information can be stored in the dirstate to keep track of
filesystem attribute tracked by Mercurial when the underlying file
system or operating system does not support that property, (e.g.
Windows).

Not all version of the dirstate on-disk storage support preserving this
information.
Nr#   rd   s    r3   has_fallback_execDirstateItem.has_fallback_execf  s     ""$..r6   c                    U R                   $ )z"fallback" information for the executable bit

True if the file should be considered executable when we cannot get
this information from the files system. False if it should be
considered non-executable.

See has_fallback_exec for details.r   rd   s    r3   r1   DirstateItem.fallback_exect  s     """r6   c                :    Uc  SU l         g[        U5      U l         g)zcontrol "fallback" executable bit

Set to:
- True if the file should be considered executable,
- False if the file should be considered non-executable,
- None if we do not have valid fallback data.

See has_fallback_exec for details.N)r#   r8   r*   values     r3   set_fallback_execDirstateItem.set_fallback_exec  s     ="&D"&u+Dr6   c                    U R                   SL$ )ah  True if "fallback" information are available for symlink status

Fallback information can be stored in the dirstate to keep track of
filesystem attribute tracked by Mercurial when the underlying file
system or operating system does not support that property, (e.g.
Windows).

Not all version of the dirstate on-disk storage support preserving this
information.Nr$   rd   s    r3   has_fallback_symlink!DirstateItem.has_fallback_symlink  s     %%T11r6   c                    U R                   $ )z"fallback" information for symlink status

True if the file should be considered executable when we cannot get
this information from the files system. False if it should be
considered non-executable.

See has_fallback_exec for details.r   rd   s    r3   r2   DirstateItem.fallback_symlink  s     %%%r6   c                :    Uc  SU l         g[        U5      U l         g)zcontrol "fallback" symlink status

Set to:
- True if the file should be considered a symlink,
- False if the file should be considered not a symlink,
- None if we do not have valid fallback data.

See has_fallback_symlink for details.N)r$   r8   r   s     r3   set_fallback_symlink!DirstateItem.set_fallback_symlink  s     =%)D"%)%[D"r6   c                    U R                   $ )z/True is the file is tracked in the working copy)r    rd   s    r3   trackedDirstateItem.tracked       r6   c                f    U R                   =(       d    U R                  =(       d    U R                  $ )z4True is the file is tracked anywhere (wc or parents)r    r!   r"   rd   s    r3   r   DirstateItem.any_tracked  s$     D4#3#3Dt}}Dr6   c                p    U R                   =(       a$    U R                  =(       d    U R                  (       + $ )zTrue if the file has been addedr   rd   s    r3   addedDirstateItem.added  s'     K)9)9)JT]]$KKr6   c                f    U R                   =(       a    U R                  =(       a    U R                  $ )z"True if the file has been modifiedr   rd   s    r3   modifiedDirstateItem.modified  s$     FD$4$4FFr6   c                p    U R                   (       d  gU R                  (       d  gU R                  (       a  gg)z8True if the file has a chance to be in the "clean" stateFTr   rd   s    r3   maybe_cleanDirstateItem.maybe_clean  s)     !!]]r6   c                    U R                   $ )z8True if the file is tracked in the first parent manifest)r!   rd   s    r3   r,   DirstateItem.p1_tracked  r   r6   c                @    U R                   =(       a    U R                  $ )zfTrue if the file needed to merge or apply any input from p2

See the class documentation for details.
)r    r"   rd   s    r3   r-   DirstateItem.p2_info  s     1DMM1r6   c                p    U R                   (       + =(       a    U R                  =(       d    U R                  $ )z!True if the file has been removedr   rd   s    r3   removedDirstateItem.removed  s'     ###K)9)9)JT]]Kr6   c                6   SnU R                   (       a	  U[        -  nU R                  (       a	  U[        -  nU R                  (       a	  U[
        -  nU R                  bo  U R                  bb  U[        -  nU R                  [        R                  -  (       a	  U[        -  n[        R                  " U R                  5      (       a	  U[        -  nU R                  b	  U[         -  nU R"                  (       a	  U[$        -  nU R&                  b#  U[(        -  nU R&                  (       a	  U[*        -  nU R,                  b#  U[.        -  nU R,                  (       a	  U[0        -  nXR                  =(       d    SU R                  =(       d    SU R2                  =(       d    S4$ )z7Returns (flags, mode, size, mtime) for v2 serializationr   )r    rG   r!   rH   r"   rI   r%   r&   r9   rP   r@   rA   rB   S_ISLNKrC   r'   r:   r)   rF   r#   r<   r=   r$   r>   r?   r(   )r*   rK   s     r3   v2_dataDirstateItem.v2_data  s@   --E++E==((E::!djj&<22Eyy4<<'33||DII&&44==$**E''77E*22E""22!!-55E%%55
 zzQ(:DNN<OaPPr6   c                    U R                   (       d  [        S5      eU R                  (       a  gU R                  (       a  U R                  (       a  gU R
                  (       a  gg)z.return a "state" suitable for v1 serializationuntracked itemrW   rU   rV   rX   )r   r]   r   r!   r"   r   rd   s    r3   r   DirstateItem._v1_state	  sB     /00\\$--ZZr6   c                8    U R                   b  U R                   $ S$ )z-return a "mode" suitable for v1 serializationr   )r%   rd   s    r3   ru   DirstateItem._v1_mode  s    !ZZ3tzz::r6   c                j   U R                   (       d  [        S5      eU R                  (       a(  U R                  (       a  U R                  (       a  [
        $ U R                  (       a  [        $ U R                  (       a  gU R                  (       a  [
        $ U R                  c  [
        $ U R                  $ )z-return a "size" suitable for v1 serializationr   r   )	r   r]   r   r!   r"   rZ   r[   r   r&   rd   s    r3   ry   DirstateItem._v1_size  sq     /00\\d..4==]]N\\ZZZZ::r6   c                &   U R                   (       d  [        S5      eU R                  (       a  gU R                  c  [        $ U R
                  (       a  [        $ U R                  (       d  [        $ U R                  (       a  [        $ U R                  $ )z.return a "mtime" suitable for v1 serializationr   r   )r   r]   r   r'   r\   r"   r!   r)   rd   s    r3   r|   DirstateItem._v1_mtime/  sh     /00\\]]"!!]]!!!!!!))!!== r6   )
r#   r$   r%   r(   r'   r)   r!   r"   r&   r    )FFFTTNNNreturnbytes)5__name__
__module____qualname____firstlineno____doc__r   ibr    r!   r"   r%   r&   r'   r(   r#   r$   r)   r4   classmethodrR   ra   re   rh   rk   rn   rq   propertyrP   rL   r`   r   r_   r   r1   setterr   r   r2   r   r   r   r   r   r   r,   r-   r   r   r   ru   ry   r|   __static_attributes__ r6   r3   r   r   P   s{   < '')K'')KwwyHGGIEGGIEwwyH	IWWYN	"ggi  !$"L )
 )
V (M (MTL	
"        ',      / / # # . . 
2 
2 & & 1 1     E E L L G G       2 2 L L!QF;&!r6   r   c                    [        U S-  5      $ )Ni  )int)qs    r3   gettyper   C  s    q6z?r6   c                     \ rS rSr% Sr\R                  r\R                  " S5      r
\R                  " S5      rSSSSSSS\R                  SS\R                  \R                  \R                  4rS\S'   S\S	'   S
\S'   \R&                  S 5       r\R&                  S 5       rS rS rS rS rS rS S jrS rS rS rS!S jrS r S r!S r"S r#S"S jr$S#S$S jjr%Sr&g)%BaseIndexObjectiG  r   s   >Q   >ir   r   _datazlist[bytes]_extrar   _lgtc                .    U R                   R                  $ rt   )index_formatrL   rd   s    r3   
entry_sizeBaseIndexObject.entry_sizef  s      %%%r6   c                    [         R                  " [        R                  [        05      n[        S[        U 5      5       H  nX   S   nX!U'   M     U$ )Nr      )nodemaputilNodeMapr   nullidr   rangelen)r*   r   rns       r3   _nodemapBaseIndexObject._nodemapj  sL    %%'8'?'?&IJq#d)$A
AAJ % r6   c                    XR                   ;   $ )z*return True if the node exist in the indexr   r*   nodes     r3   has_nodeBaseIndexObject.has_noder  s    }}$$r6   c                     U R                   U   $ )zIreturn a revision for a node

If the node is unknown, raise a RevlogErrorr   r   s     r3   revBaseIndexObject.revv  s     }}T""r6   c                8    U R                   R                  U5      $ )zAreturn a revision for a node

If the node is unknown, return None)r   getr   s     r3   get_revBaseIndexObject.get_rev|  s     }}  &&r6   c                    S[        U 5      ;   a1  [        U[        U 5      5       H  nX   S   nU R                  U	 M     g g Nr   r   )varsr   r   r   )r*   startr   r   s       r3   _stripnodesBaseIndexObject._stripnodes  s?    d#5#d),GAJMM!$ - $r6   c                <    U R                   R                  SS 5        g )Nr   )__dict__poprd   s    r3   clearcachesBaseIndexObject.clearcaches  s    *d+r6   c                F    U R                   [        U R                  5      -   $ rt   )r   r   r   rd   s    r3   __len__BaseIndexObject.__len__  s    yy3t{{+++r6   c                    S[        U 5      ;   a  [        U 5      U R                  US   '   U R                  [        U 5      U5      nU R                  R                  U5        g r   )r   r   r   _pack_entryr   append)r*   tupdatas      r3   r  BaseIndexObject.append  sL    d#$'IDMM#a&!D	3/4 r6   c                f    US   S:X  d   eUS   S:X  d   eU R                   R                  " US S 6 $ )Nr   r   	   r   packr*   r   entrys      r3   r  BaseIndexObject._pack_entry  s?    Qx1}}Qx1}}  %%uRay11r6   c                    [        U[        5      (       d  [        S5      eUS:  d  U[        U 5      :  a  [	        U5      eg )Nzexpecting int indexesr   )
isinstancer   	TypeErrorr   
IndexErrorr*   is     r3   _check_indexBaseIndexObject._check_index  s;    !S!!344q5ATNQ- #r6   c                    [         ert   NotImplementedErrorr  s     r3   _calculate_index BaseIndexObject._calculate_index  s
     "!r6   c                   US:X  a  U R                   $ U R                  U5        XR                  :  a  U R                  XR                  -
     nO,U R	                  U5      nU R
                  X3U R                  -    nU R                  X5      nU R                  (       a2  US:X  a,  [        R                  " S[        US   5      5      nU4USS  -   nU$ )Nr   r   r   )	null_itemr  r   r   r  r   r   _unpack_entryr
   offset_typer   )r*   r  r	  indexr   offsets         r3   __getitem__BaseIndexObject.__getitem__  s    7>>!!		>;;q99}-D))!,E::edoo&=>Dq'99a ,,Q!>F	AabE!Ar6   c                    [        5       ert   r  r  s     r3   __delitem__BaseIndexObject.__delitem__  s    !##r6   c                    U R                   R                  U5      nUSS[        R                  [        R                  [        R                  4-   nU$ Nr   )r   unpackrevlog_constantsCOMP_MODE_INLINERANK_UNKNOWN)r*   r   r	  r   s       r3   r!  BaseIndexObject._unpack_entry  sO    $$T*----))
 
 r6   c                D    [         R                  nUR                  U5      $ )!pack header information as binary)r-  INDEX_HEADERr  )r*   headerv_fmts      r3   pack_headerBaseIndexObject.pack_header  s     --zz&!!r6   c                    X   n[         R                  R                  " USS 6 nUS:X  a  U[         R                  R                  S nU$ )4return the raw binary string representing a revisionNr   r   )r-  INDEX_ENTRY_V1r  r3  rL   )r*   r   r  ps       r3   entry_binaryBaseIndexObject.entry_binary  sK    	++00%)<!8"//4467Ar6   Nc                4  ^ [        U 5      nUb  [        X25      nU(       d  [        /$ S/US-   -  n[        U5      nTb  U4S jU 5       nU H  nSXF'   X   nS=XGS   '   XGS   '   M     [	        U5       VVs/ s H  u  phU(       d  M  UPM     snn$ s  snnf )Nr   r   c              3  6   >#    U  H  oT;  d  M
  Uv   M     g 7frt   r   ).0r   excluded_revss     r3   	<genexpr>+BaseIndexObject.headrevs.<locals>.<genexpr>  s     >t!'=AAts   		      )r   minr   r   	enumerate)	r*   rA  stop_revcountisheadrevsr   evals	    `       r3   headrevsBaseIndexObject.headrevs  s    D	(E9	"U|$>t>DAFIA*++FQ4L6A$<  !*& 19 1faS 1999s   9B
Br   )r   r   r  r   r   r   r   )NN)r   z	list[int])'r   r   r   r   rust_ext_compatr-  r:  r   structcalcsizebig_int_sizeint_sizer   r   r.  r/  r   __annotations__r   propertycacher   r   r   r   r   r   r   r  r  r  r  r  r%  r(  r!  r6  r<  rN  r   r   r6   r3   r   r   G  s   O#22L??5)Lu%H 	
		



  		))))%%I" 
I	& & 
 %#'%,,!2
 "$	"
: :r6   r   c                  2    \ rS rSrSSS jjrS	S jrS rSrg)
IndexObjecti  c                    [        U5      U R                  -  S:X  d3   [        U5      U R                  [        U5      U R                  -  45       eXl        [        U5      U R                  -  U l        / U l        g r+  )r   r   r   r   r   )r*   r	  uses_generaldeltas      r3   r4   IndexObject.__init__  si    4y4??*a/ 	
IOOI'2
 	
/
 
I0	r6   c                    XR                   -  $ rt   )r   r  s     r3   r  IndexObject._calculate_index  s    ??""r6   c                   [        U[        5      (       a  UR                  S:X  a  UR                  b  [	        S5      eUR
                  nU R                  U5        U R                  U5        XR                  :  a.  U R                  S XR                  -   U l	        Xl        / U l        g U R                  S XR                  -
   U l        g Nr   z.deleting slices only supports a:-1 with step 1)r  slicestopstep
ValueErrorr   r  r   r   r   r   r   r  s     r3   r(  IndexObject.__delitem__  s    !U##166R<166;MMNNGG!yy=$9a//&9:DJIDK++oII6DKr6   )r   r   r   N)F)r	  r   rP  )r   r   r   r   r4   r  r(  r   r   r6   r3   rY  rY    s    #7r6   rY  c                  J    \ rS rSr% SrS\S'   S\S'   S\S'   S	 rS
 rS rSr	g)PersistentNodeMapIndexObjecti  a   a Debug oriented class to test persistent nodemap

We need a simple python object to test API and higher level behavior. See
the Rust implementation for  more serious usage. This should be used only
through the dedicated `devel.persistent-nodemap` config.
r   
_nm_docketz
int | None_nm_max_idxznodemaputil.Block | None_nm_rootc                .    [         R                  " U 5      $ )zReturn bytes containing a full serialization of a nodemap

The nodemap should be valid for the full set of revisions in the
index.)r   persistent_datard   s    r3   nodemap_data_all-PersistentNodeMapIndexObject.nodemap_data_all  s    
 **400r6   c                    U R                   c  gU R                  n[        R                  " X R                   U R                  U R                  R
                  5      u  p#S=U l         =U l        U l        XU4$ )zReturn bytes containing a incremental update to persistent nodemap

This containst the data for an append-only update of the data provided
in the last call to `update_nodemap_data`.
N)rj  rh  r   update_persistent_datari  tip_rev)r*   docketchangedr	  s       r3   nodemap_data_incremental5PersistentNodeMapIndexObject.nodemap_data_incremental  sk     == #::--!1!14??3J3J
 >BAA(4?$$r6   c                    UbQ  [         R                  " U5      u  U l        U l        U R                  (       a  Xl        gS=U l        =U l        U l        gg)zprovide full block of persisted binary data for a nodemap

The data are expected to come from disk. See `nodemap_data_all` for a
produceur of such data.N)r   
parse_datarj  ri  rh  )r*   rr  nm_datas      r3   update_nodemap_data0PersistentNodeMapIndexObject.update_nodemap_data"  sK    
 .9.D.DW.M+DM4+}}"(EIII 04? r6   )rh  ri  rj  N)
r   r   r   r   r   rV  rm  rt  ry  r   r   r6   r3   rg  rg    s*     O&&1% 
Jr6   rg  c                  4    \ rS rSrSS jrS rS rS	S jrSrg)
InlinedIndexObjecti/  c                    Xl         U R                  S 5      U l        U R                  U R                  5        / U l        g rt   )r   _inline_scanr   r   )r*   r	  inliner[  s       r3   r4   InlinedIndexObject.__init__0  s2    
%%d+	$))$r6   c                   SnUb  S/U-  U l         SnU[        U R                  5      U R                  -
  ::  a  X R                  -   n[
        R                  " SU R                  XDU R                  -    5      u  nUb  X R                   U'   US-  nX R                  U-   -  nU[        U R                  5      U R                  -
  ::  a  M  U[        U R                  5      :w  a  [        S5      eU$ )Nr   r   r   zcorrupted data)	_offsetsr   r   r   rT  rR  r,  rU  rd  )r*   lgtoffrI  r   ss         r3   r~  InlinedIndexObject._inline_scan6  s    ?C#IDMS_t66+++E==

54==#89DQ '*e$QJE??Q&&C S_t66 #djj/!-..r6   c                |   [        U[        5      (       a  UR                  S:X  a  UR                  b  [	        S5      eUR
                  nU R                  U5        U R                  U5        XR                  :  a"  U R                  S U U l	        Xl        / U l
        g U R                  S XR                  -
   U l
        g r`  )r  ra  rb  rc  rd  r   r  r   r   r  r   r  s     r3   r(  InlinedIndexObject.__delitem__I  s    !U##166R<166;MMNNGG!yy= MM"1-DMIDK++oII6DKr6   c                     U R                   U   $ rt   )r  r  s     r3   r  #InlinedIndexObject._calculate_indexV  s    }}Qr6   )r   r   r   r  N)r   FrP  )	r   r   r   r   r4   r~  r(  r  r   r   r6   r3   r|  r|  /  s    &7 r6   r|  c                    U[         R                  :X  a  [        U 5      $ U(       d+  U[         R                  :X  a  [        nO[
        nU" X5      S 4$ [        nU" XU5      SU 44$ r+  )r-  CHANGELOGV2parse_index_cl_v2REVLOGV2IndexObject2rY  r|  )r	  r  r[  formatrJ   s        r3   parse_index2r  Z  sf     !--- &&%...CC4+T11
Ct./!T::r6   c                    [        U 5      S 4$ rt   )IndexChangelogV2)r	  s    r3   r  r  l  s    D!4''r6   c                  J    \ rS rSr\R
                  rS rS rS r	S r
S rSrg)	r  ip  c                   US:  a  [         eU R                  U5        XR                  :  a  Sn[        U5      e[        X   5      nXGS'   X'S'   X7S'   XWS'   [	        U5      nU R                  X5      nXR                  XR                  -
  '   g)z
Replace an existing index entry's sidedata offset and length with new
ones.
This cannot be used outside of the context of sidedata rewriting,
inside the transaction that creates the revision `rev`.
r   z2cannot rewrite entries outside of this transactionr   r     N)KeyErrorr  r   listtupler  r   )	r*   r   sidedata_offsetsidedata_lengthoffset_flagscompression_modemsgr  news	            r3   replace_sidedata_info"IndexObject2.replace_sidedata_infos  s     7N#?FC3-OE#!H&!H&!H("I%LE""3.C+.KKii(r6   c                    U R                   R                  U5      nUS S nUS   S-  nUS   S-  S-	  nX4U[        R                  4-   $ )N
         r   )r   r,  r-  r/  )r*   r   r	  r  	data_compsidedata_comps         r3   r!  IndexObject2._unpack_entry  sZ      ''-Sb	HqL	bV,2=2B2O2OPPPr6   c                t    US S nUS   S-  nUS   S-  S-  nX4U-  4-  nU R                   R                  " U6 $ )Nr  r  r  r   r  )r*   r   r  r	  r  r  s         r3   r  IndexObject2._pack_entry  sS    Sbz"IM	rQ1,]*,,  %%t,,r6   c                ,    X   nU R                  X5      $ )r9  )r  r  s      r3   r<  IndexObject2.entry_binary  s    	++r6   c                :    SnX!-  n[         R                  " U5      e)r2  z9version header should go in the docket, not the index: %d)r   ProgrammingError)r*   r4  r  s      r3   r6  IndexObject2.pack_header  s    I$$S))r6   r   N)r   r   r   r   r-  INDEX_ENTRY_V2r   r  r!  r  r<  r6  r   r   r6   r3   r  r  p  s'    #22L/<Q-,
*r6   r  c                      \ rS rSr\R
                  r\R                  S\R                   S-   \R                  \R                  S -   rSS jr
S rSrg)r  i  N)r   c                   U R                   R                  U5      nU[        R                     U[        R                     U[        R
                     UUU[        R                     U[        R                     U[        R                     U[        R                     U[        R                     U[        R                     S-  U[        R                     S-	  S-  U[        R                     4$ Nr  r   )r   r,  r-  INDEX_ENTRY_V2_IDX_OFFSET$INDEX_ENTRY_V2_IDX_COMPRESSED_LENGTH&INDEX_ENTRY_V2_IDX_UNCOMPRESSED_LENGTHINDEX_ENTRY_V2_IDX_PARENT_1INDEX_ENTRY_V2_IDX_PARENT_2INDEX_ENTRY_V2_IDX_NODEID"INDEX_ENTRY_V2_IDX_SIDEDATA_OFFSET-INDEX_ENTRY_V2_IDX_SIDEDATA_COMPRESSED_LENGTH#INDEX_ENTRY_V2_IDX_COMPRESSION_MODEINDEX_ENTRY_V2_IDX_RANK)r*   r   r	  r   itemss        r3   r!  IndexChangelogV2._unpack_entry  s    !!((."<<="GGH"IIJ">>?">>?"<<="EEF NN "FFG!K#GGHAM"::;!
 	
r6   c                Z   U[         R                     nU[         R                     nX1:X  d   X145       eXA:X  d   XA45       eU[         R                     U[         R                     U[         R
                     U[         R                     U[         R                     U[         R                     U[         R                     U[         R                     U[         R                     S-  U[         R                     S-  S-  -  U[         R                     4
nU R                  R                  " U6 $ r  )r-  ENTRY_DELTA_BASEENTRY_LINK_REVENTRY_DATA_OFFSETENTRY_DATA_COMPRESSED_LENGTHENTRY_DATA_UNCOMPRESSED_LENGTHENTRY_PARENT_1ENTRY_PARENT_2ENTRY_NODE_IDENTRY_SIDEDATA_OFFSET ENTRY_SIDEDATA_COMPRESSED_LENGTHENTRY_DATA_COMPRESSION_MODEENTRY_SIDEDATA_COMPRESSION_MODE
ENTRY_RANKr   r  )r*   r   r  baselink_revr	  s         r3   r  IndexChangelogV2._pack_entry  s$   %667)889{'TK'{//"445"??@"AAB"112"112"001"889"CCD">>?!C%EEFJ "--.
   %%t,,r6   r   )T)r   r   r   r   r-  INDEX_ENTRY_CL_V2r   r  r   r  r!  r  r   r   r6   r3   r  r    s\    #55L 	<!1!<!<=
	

 
 !1!<!<!>
?	@ 
*-r6   r  c                    [        X5      S4$ )zClike parse_index2, but always return a PersistentNodeMapIndexObjectN)rg  )r	  r  r[  s      r3   parse_index_devel_nodemapr    s    '@$FFr6   c                    US S USS /nSn[         R                  " U5      nSn[        U5      nXg:  aY  Xe-   n[        SX&U 5      n	XS   -   nX(U n
SU
;   a  U
R	                  S5      u  pXU
'   [
        R                  " U	S S 6 X
'   Xg:  a  MY  U$ )N   (      >cllllr       )rR  rS  r   _unpacksplitr   ra   )dmapcopymapstparentsr  e_sizepos1lpos2rL  fcs               r3   parse_dirstater    s    #2w2b	"GF__V$FDBA (}Irt}-d{DMA:775>DAAJ++QrU3 ( Nr6   c                   [        5       nUR                  nU" SR                  U5      5        U R                  5        Ht  u  pVXQ;   a	  SXQU   4-  n[	        SUR                  5       UR                  5       UR                  5       UR                  5       [        U5      5      nU" U5        U" U5        Mv     UR                  5       $ )Nr6   s   %s %sr  )stringiowritejoinr  _packr   ru   ry   r|   r   getvalue)r  r  plcsr  r  rL  s          r3   pack_dirstater    s    	BHHE	#((2,

<Q
O+AKKMJJLJJLKKMF
 	aa  ;;=r6   )r	  r   r   zFtuple[IndexObject | InlinedIndexObject, tuple[int, ByteString] | None])D
__future__r   ior@   rR  typingzlibr   r   r   
thirdpartyr   TYPE_CHECKING r   r	   r
   r   r   r   r   r-  r   r   BytesIOr  r  r  r,  r  compress	_compress
decompress_decompressr[   rZ   r\   rG   rH   rI   rB   rC   r<   r=   r>   r?   r;   r9   r:   rF   DIRSTATE_V2_DIRECTORY DIRSTATE_V2_ALL_UNKNOWN_RECORDED DIRSTATE_V2_ALL_IGNORED_RECORDEDr  r   r   r   rY  rg  r|  REVLOGV1r  r  r  r  r  r  r  r   r6   r3   <module>r     s   # 	      
  1 7	
 :: 	
--MM	oo  	  "   # $  & " #)  % )/ & '  %, " #*  #*   do! o!  o!dX: X:v7/ 78.J; .Jb(  ( ^ $$	;
;
 L;$(9*; 9*x1-| 1-hG
*r6   