
    6hY                      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  SSKJr  SSKJrJr  S SKJr  SSKJrJrJrJrJrJrJrJrJ r J!r!J"r"  SS	K#J$r$  SS
K%J&r'  \RP                  " S5      r)\RT                  " SSS9r+\+SLr,\"RZ                  r-\ R\                  r.\R^                  r0\Rb                  r1 " S S\.5      r2 " S S\.5      r3S r4S r5S r6S r7S r8Sr9Sr: " S S\'Rv                  5      r&g)    )annotationsN)AnyDictIterableIteratorListOptionalTuple   )_)MatcherTTransactionT)tracing)dirstatemapencodingerrormatchnodepathutilpolicypycompatscmutiltxnutilutil)	timestamp)dirstateparsersr   T)pyo3c                      \ rS rSrSrS rSrg)	repocacheD   zfilecache for files in .hg/c                8    UR                   R                  U5      $ N)_openerjoinselfobjfnames      4/usr/lib/python3/dist-packages/mercurial/dirstate.pyr%   repocache.joinG   s    {{&&     N__name__
__module____qualname____firstlineno____doc__r%   __static_attributes__r-   r,   r*   r    r    D   s
    %'r,   r    c                      \ rS rSrSrS rSrg)	rootcacheK   z*filecache for files in the repository rootc                $    UR                  U5      $ r#   )_joinr&   s      r*   r%   rootcache.joinN   s    yyr,   r-   Nr.   r-   r,   r*   r6   r6   K   s
    4 r,   r6   c                   ^  U 4S jnU$ )zcheck that the func is called with a non-invalidated dirstate

The dirstate is in an "invalidated state" after an error occured during its
modification and remains so until we exited the top level scope that framed
such change.
c                   > U R                   (       a'  SnUTR                  -  n[        R                  " U5      eT" U /UQ70 UD6$ )Nz/calling `%s` after the dirstate was invalidated)_invalidated_contextr/   r   ProgrammingErrorr'   argskwargsmsgfuncs       r*   wrapcheck_invalidated.<locals>.wrapZ   sE    $$CC4== C((--D*4*6**r,   r-   rC   rD   s   ` r*   check_invalidatedrG   R   s    + Kr,   c                &   ^  U 4S jn[        U5      $ )Nc                   > U R                   (       d'  SnUTR                  -  n[        R                  " U5      eT" U /UQ70 UD6$ )Nz2calling `%s` outside of a changing_parents context)is_changing_parentsr/   r   r>   r?   s       r*   rD   'requires_changing_parents.<locals>.wrape   sE    ''FC4== C((--D*4*6**r,   rG   rF   s   ` r*   requires_changing_parentsrM   d       + T""r,   c                &   ^  U 4S jn[        U5      $ )Nc                   > U R                   (       d'  SnUTR                  -  n[        R                  " U5      eT" U /UQ70 UD6$ )Nz*calling `%s` outside of a `changing_files`)is_changing_filesr/   r   r>   r?   s       r*   rD   %requires_changing_files.<locals>.wrapp   sE    %%>C4== C((--D*4*6**r,   rL   rF   s   ` r*   requires_changing_filesrS   o   rN   r,   c                &   ^  U 4S jn[        U5      $ )Nc                   > U R                   (       d'  SnUTR                  -  n[        R                  " U5      eT" U /UQ70 UD6$ )Nz*calling `%s` outside of a changing context)is_changing_anyr/   r   r>   r?   s       r*   rD   #requires_changing_any.<locals>.wrap{   sE    ##>C4== C((--D*4*6**r,   rL   rF   s   ` r*   requires_changing_anyrX   z   rN   r,   c                &   ^  U 4S jn[        U5      $ )Nc                   > U R                   (       d7  U R                  S:  d'  SnUTR                  -  n[        R                  " U5      eT" U /UQ70 UD6$ )Nr   zBcalling `%s` outside of a changing_files or running_status context)rQ   _running_statusr/   r   r>   r?   s       r*   rD   /requires_changing_files_or_status.<locals>.wrap   sY    &&$*>*>*B,  4== C((--D*4*6**r,   rL   rF   s   ` r*   !requires_changing_files_or_statusr]      s    + T""r,   parentsfilesc                     \ rS rSrSr SQS jrS rS r\R                  \
S 5       5       r\R                  \
S 5       5       r\R                  S 5       r\R                  S	 5       rS
 r\SRS j5       r\SRS j5       r\SRS j5       r\S 5       r\S 5       r\" S5      S 5       r\S 5       rSSS jr\" S5      STS j5       r\S 5       r\SRS j5       r\SRS j5       r\S 5       r S r!    SUS jr"\S 5       r#SVS jr$SWSXS jjr%SYS  jr&SZS! jr'S[S" jr(S\S# jr)\)r*S]S$ jr+SVS% jr,SVS& jr-\S' 5       r.SVS( jr/\0SWS^S) jj5       r1      S_S* jr2S+ r3S`S, jr4\5SaS- j5       r6SbS. jr7ScS/ jr8\9SQS0 j5       r:\9S1 5       r;\<S2 5       r=\<S3 5       r>\0S4 5       r?\0   SdS5 j5       r@S6 rA   SdS7 jrBS8 rCS9 rDS: rESeS; jrFSeS< jrG Sf       SgS= jjrH\0S`S> j5       rI\0 SW       ShS? jj5       rJS@ rKSiSA jrLSB rM      SjSC jrNSD rOSE rPSF rQS]SG jrRSkSH jrSSI rT Sl           SmSJ jjrUSK rV            SnSL jrWSoSM jrXSN rY SW     SpSO jjrZSPr[g)qr      r,   c	                   Xpl         Xl        X`l        Xl        X@l        X0l        XPl        [        R                  " U5      U l	        SU l
        SU l        X l        0 U l        SU l        SU l        SU l        SU l        SU l        SU l        SU l        SU R&                  -  U l        0 U l        SU l        [0        R0                  U l        U R4                    g)zCreate a new dirstate object.

opener is an open()-like callable that can be used to open the
dirstate file; root is the root of the directory tracked by
the dirstate.
Fr   Ns   dirstates   dirstate-tracked-hints
   %s.pending)_use_dirstate_v2_use_tracked_hint_nodeconstantsr$   	_validate_root_sparsematchfnr   normasprefix_rootdir_dirty_dirty_tracked_set_ui
_filecache_changing_level_change_typer[   r=   _attached_to_a_transaction	_filename_filename_th_pendingfilename_plchangecallbacks_origplr   _mapcls_cwd)	r'   openeruirootvalidatesparsematchfnnodeconstantsuse_dirstate_v2use_tracked_hints	            r*   __init__dirstate.__init__   s    " !0!1+!
+ !--d3"'    %*!*/'$4 - >"$".. 			r,   c                    U R                   (       a  Sn[        R                  " U5      eS[        U 5      ;   a  U ?S[        U 5      ;   a1  U R
                  R                  5       (       a  U R                  5         g g g )Nz1refreshing the dirstate in the middle of a change_branch_map)rV   r   r>   varsr   r   may_need_refresh
invalidater'   rB   s     r*   refreshdirstate.refresh   se     EC((--T
"T$ZDII$>$>$@$@OO %Ar,   c                    U R                     g)zBmake sure the parents are loaded

Used to avoid a race condition.
N)_plr'   s    r*   prefetch_parentsdirstate.prefetch_parents   s    
 	r,   c              #    #    UR                  5       SLnU R                  nUR                  5       nUSLn[        U R                  5      nU=(       d    U=(       d    U(       + nU(       ac  U R
                  (       aR  UR                  5       SLnU(       d9  U R                  S:X  a)  U R
                  (       a  Sn[        R                  " U5      eU=(       a    U=(       d    U(       + n	U =R                  S-  sl         Sv    U =R                  S-  sl        U R                  (       a  Sn	U R                  5         U	(       a'  UR                  5       UL d   eU R                  U5        gU(       d@  U R
                  (       a.  SnUR                  R                  U5        U R                  5         ggg! [         a    U R                  5         e f = f! U =R                  S-  sl        U R                  (       a  Sn	U R                  5         f f = f7f)u  Wrap a status operation

This context is not mutally exclusive with the `changing_*` context. It
also do not warrant for the `wlock` to be taken.

If the wlock is taken, this context will behave in a simple way, and
ensure the data are scheduled for write when leaving the top level
context.

If the lock is not taken, it will only warrant that the data are either
committed (written) and rolled back (invalidated) when exiting the top
level context. The write/invalidate action must be performed by the
wrapped code.


The expected  logic is:

A: read the dirstate
B: run status
   This might make the dirstate dirty by updating cache,
   especially in Rust.
C: do more "post status fixup if relevant
D: try to take the w-lock (this will invalidate the changes if they were raced)
E0: if dirstate changed on disk → discard change (done by dirstate internal)
E1: elif lock was acquired → write the changes
E2: else → discard the changes
Nr   z8entering a status context, but dirstate is already dirtyr   Fs7   dirstate dirty while exiting an isolated status context)currentwlockrV   currenttransactionboolr[   rk   ro   r   r>   	Exceptionr   r=   writerz   	develwarn)
r'   repohas_lockis_changingtrhas_trnestedfirst_and_alonerB   should_writes
             r*   running_statusdirstate.running_status   s    < $$&d2**$$&4d**+*>f>? t{{,,.d:Fd22a7DKKP,,S11?)>;$?!		"
   A% (($!**,222JJrN{{P!!#&!    	OO	   A% (($! )s+   C9H<F/ B.H/GG ;H		Hc              #    #    UR                  5       c  Sn[        R                  " U5      eUR                  5       S LnU(       d>  U R                  S:X  a.  U R
                  (       a  SnUR                  R                  U5        U R                  S:  d   eU R                  c  U R                  S:X  d   eX l        O8U R                  U:w  a(  SnX2U R                  4-  n[        R                  " U5      eSnU =R                  S-  sl         S v    U R                  S:  d   eU =R                  S-  sl        U R                  S::  a  S U l        U R                  S:X  d   eU R                  (       a  U R                  5         OU R                  S:*  n UR                  5       nXFS L:w  a"  U(       a  SnOSn[        R                  " U5      eU(       a  U R                  U5        g g !   U R                  5         e = f! U R                  S:  d   eU =R                  S-  sl        U R                  S::  a  S U l        U R                  S:X  d   eU R                  (       a  U R                  5         f U R                  S:*  nf = f7f)	Ns7   trying to change the dirstate without holding the wlockr   s:   entering a changing context, but dirstate is already dirtyzJtrying to open "%s" dirstate-changing context while a "%s" is already openFr   z,transaction vanished while changing dirstatez,transaction appeared while changing dirstate)r   r   r>   r   ro   rk   rz   r   rp   r   r=   r   )r'   r   change_typerB   r   r   r   ms           r*   	_changingdirstate._changing)  sM     &LC((--((*$6$..!3OCGGc"##q((($''1,,, ++-   !2!233C((--!	9
 ''!+++  A%  ##q($(!++q000(( !#33q8$$&n%BB((++JJrN 3	OO''!+++  A%  ##q($(!++q000(( !#33q8s,   DJG% CJ%G88G; ;BI>>Jc              #  t   #    U R                  U[        5       nUv   SSS5        g! , (       d  f       g= f7f)a|  Wrap a dirstate change related to a change of working copy parents

This context scopes a series of dirstate modifications that match an
update of the working copy parents (typically `hg update`, `hg merge`
etc).

The dirstate's methods that perform this kind of modifications require
this context to be present before being called.
Such methods are decorated with `@requires_changing_parents`.

The new dirstate contents will be written to disk when the top-most
`changing_parents` context exits successfully. If an exception is
raised during a `changing_parents` context of any level, all changes
are invalidated. If this context is open within an open transaction,
the dirstate writing is delayed until that transaction is successfully
committed (and the dirstate is invalidated on transaction abort).

The `changing_parents` operation is mutually exclusive with the
`changing_files` one.
N)r   CHANGE_TYPE_PARENTSr'   r   cs      r*   changing_parentsdirstate.changing_parentsa  s(     , ^^D"56!G 766   8'	8
58c              #  t   #    U R                  U[        5       nUv   SSS5        g! , (       d  f       g= f7f)a  Wrap a dirstate change related to the set of tracked files

This context scopes a series of dirstate modifications that change the
set of tracked files. (typically `hg add`, `hg remove` etc) or some
dirstate stored information (like `hg rename --after`) but preserve
the working copy parents.

The dirstate's methods that perform this kind of modifications require
this context to be present before being called.
Such methods are decorated with `@requires_changing_files`.

The new dirstate contents will be written to disk when the top-most
`changing_files` context exits successfully. If an exception is raised
during a `changing_files` context of any level, all changes are
invalidated.  If this context is open within an open transaction, the
dirstate writing is delayed until that transaction is successfully
committed (and the dirstate is invalidated on transaction abort).

The `changing_files` operation is mutually exclusive with the
`changing_parents` one.
N)r   CHANGE_TYPE_FILESr   s      r*   changing_filesdirstate.changing_filesz  s(     . ^^D"34G 544r   c                2    Sn[         R                  " U5      e)NzJMercurial 6.4 and later requires call to `dirstate.changing_parents(repo)`)r   r>   r   s     r*   parentchangedirstate.parentchange  s    0 	 $$S))r,   c                     U R                   S:  $ )znReturns true if the dirstate is in the middle of a set of changes.

This returns True for any kind of change.
r   )ro   r   s    r*   rV   dirstate.is_changing_any  s     ##a''r,   c                J    U R                   S::  a  gU R                  [        :H  $ )zcReturns true if the dirstate is in the middle of a set of changes
that modify the dirstate parent.
r   F)ro   rp   r   r   s    r*   rJ   dirstate.is_changing_parents  s'    
 1$  $777r,   c                J    U R                   S::  a  gU R                  [        :H  $ )zrReturns true if the dirstate is in the middle of a set of changes
that modify the files tracked or their sources.
r   F)ro   rp   r   r   s    r*   rQ   dirstate.is_changing_files  s'    
 1$  $555r,   c                    U R                  U R                  U R                  U R                  U R                  U R
                  5      $ )zAReturn the dirstate contents (see documentation for dirstatemap).)rw   rm   r$   rg   re   rc   r   s    r*   r   dirstate._map  s<     ||HHLLJJ!!
 	
r,   c                >    U R                   c  gU R                  5       $ )zThe matcher for the sparse checkout.

The working directory may not include every file from a manifest. The
matcher obtained by this property will match a path if it is to be
included in the working directory.

When sparse if disabled, return None.
N)rh   r   s    r*   _sparsematcherdirstate._sparsematcher  s$     & ""$$r,      branchc                0   S nSn [         R                  " U R                  U R                  S5      u  pUR	                  5       R                  5       nUb  UR                  5         U(       d  gU$ ! [         a     N)f = f! Ub  UR                  5         f f = f)Nr,   r   s   default)r   
trypendingrg   r$   readstripFileNotFoundErrorclose)r'   fdatamodes       r*   r   dirstate._branch  s    	((T\\9MGA668>>#D }	 ! 		 }	 s$   AA/ /
A<9A? ;A<<A? ?Bc                6    U R                   R                  5       $ r#   )r   r^   r   s    r*   r   dirstate._pl  s    yy  ""r,   c                8    U R                   R                  U5      $ r#   )r   hastrackeddir)r'   ds     r*   hasdirdirstate.hasdir  s    yy&&q))r,   	   .hgignorec                    U R                  5       nU(       d  [        R                  " 5       $ U Vs/ s H  nSU-  PM
     nn[        R                  " U R                  S/ X0R
                  R                  S9$ s  snf )Ns
   include:%sr,   warn)_ignorefilesmatchmodneverr   rg   rm   r   )r'   r_   r   patss       r*   _ignoredirstate._ignore  s_    !!#>>##+015a!51~~djj#r4hhmmLL 2s   A7c                n    U R                   R                  SS5      =(       a    [        R                  S:g  $ )N   uis   slash   /)rm   
configboolr   ossepr   s    r*   _slashdirstate._slash  s'    xx""5(3N$8NNr,   c                B    [         R                  " U R                  5      $ r#   )r   	checklinkrg   r   s    r*   
_checklinkdirstate._checklink  s    ~~djj))r,   c                T    [        [        R                  " U R                  5      5      $ r#   )r   r   	checkexecrg   r   s    r*   
_checkexecdirstate._checkexec  s    DNN4::.//r,   c                V    [         R                  " U R                  S5      5      (       + $ )N   .hg)r   fscasesensitiver9   r   s    r*   
_checkcasedirstate._checkcase  s    ''

6(:;;;r,   c                     U R                   U-   $ r#   )rj   )r'   r   s     r*   r9   dirstate._join  s     }}q  r,   c                $   ^ ^^ / mSUUU 4S jjnU$ )a+  build a callable that returns flags associated with a filename

The information is extracted from three possible layers:
1. the file system if it supports the information
2. the "fallback" information stored in the dirstate if any
3. a more expensive mechanism inferring the flags from the parents.
c                  > S nS n [         R                  " TR                  U 5      5      nTR                  (       a  [
        R                  " U5      (       a  gOdTR                  U 5      nUR                  (       a  UR                  (       a  gO/T(       d  TR                  T" 5       5        TS   " U 5      nSU;   a  gTR                  (       a  [
        R                  " U5      (       a  g gUc  TR                  U 5      nUR                  (       a  UR                  (       a  g gUc(  T(       d  TR                  T" 5       5        TS   " U 5      nSU;   a  gg! [         a     gf = f)Nr,      lr      x)oslstatr9   OSErrorr   r   
statislink	get_entryhas_fallback_symlinkfallback_symlinkappendr   
statisexechas_fallback_execfallback_exec)xentryfallback_valuestbuildfallbackfallback_funcr'   s       r*   	get_flags$dirstate.flagfunc.<locals>.get_flags  sE   E!NXXdjjm, ??2&& ' q)----# . )%,,]_=%21%5a%8N~-#??2&& '  = NN1-E****# +  &-,)00A)6q)9!)<~-#E  s   %E 
E&%E&)r  bytesreturnr	  r-   )r'   r  r  r  s   `` @r*   flagfuncdirstate.flagfunc  s     '	 '	R r,   c                v    U R                   R                  SS5      nU(       a  U$ [        R                  " 5       $ )Nr   s   forcecwd)rm   configr   getcwd)r'   forcecwds     r*   rx   dirstate._cwd@  s-     88??5+6O  r,   c                    U R                   nXR                  :X  a  gU R                  n[        R                  " U5      (       d  U[        R
                  -  nUR                  U5      (       a  U[        U5      S $ U$ )zReturn the path from which a canonical path is calculated.

This path should be used to resolve file patterns or to convert
canonical paths back to file paths for display. It shouldn't be
used to get real file paths. Use vfs functions instead.
r,   N)rx   rg   r   endswithsepr   r   
startswithlen)r'   cwdrootseps      r*   r  dirstate.getcwdH  si     ii****((x~~%G>>'""s7|~&& Jr,   Nc                    Uc  U R                  5       n[        R                  " U R                  X!5      nU R                  (       a  [        R
                  " U5      $ U$ r#   )r  r   pathtorg   r   pconvert)r'   r   r  paths       r*   r  dirstate.pathto\  sA    ;++-C{{4::s.;;==&&r,   c                V    U R                   R                  U5      nUc
  [        5       $ U$ )z-return a DirstateItem for the associated path)r   getDirstateItem)r'   r  r  s      r*   r   dirstate.get_entryd  s&    		d#=>!r,   c                    XR                   ;   $ r#   )r   )r'   keys     r*   __contains__dirstate.__contains__k  s    iir,   c                >    [        [        U R                  5      5      $ r#   )itersortedr   r   s    r*   __iter__dirstate.__iter__n  s    F499%&&r,   c                6    U R                   R                  5       $ r#   )r   itemsr   s    r*   r,  dirstate.itemsq  s    yy  r,   c                b    U R                    Vs/ s H  oR                  U5      PM     sn$ s  snf r#   )r   rf   )r'   ps     r*   r^   dirstate.parentsv  s%    +/8848aq!8444s   ,c                >    U R                  U R                  S   5      $ )Nr   rf   r   r   s    r*   p1dirstate.p1y      ~~dhhqk**r,   c                >    U R                  U R                  S   5      $ )Nr   r2  r   s    r*   p2dirstate.p2|  r5  r,   c                N    U R                   S   U R                  R                  :g  $ )zTrue if a merge is in progressr   )r   re   nullidr   s    r*   in_mergedirstate.in_merge  s#     xx{d118888r,   c                B    [         R                  " U R                  5      $ r#   )r   tolocalr   r   s    r*   branchdirstate.branch  s    --r,   c                P   Uc  U R                   R                  nU R                  S:X  a  [        S5      eSU l        U R
                  S   nU R                  c  U R
                  U l        U R                   R                  nX4:g  =(       a    X$:H  nU R                  R                  XUS9$ )zSet dirstate parents to p1 and p2.

When moving from two parents to one, "merged" entries a
adjusted to normal and previous copy records discarded and
returned by the call.

See localrepo.setparents()
r   zOcannot set dirstate parent outside of dirstate.changing_parents context managerTr   )fold_p2)	re   r:  ro   
ValueErrorrk   r   rv   r   
setparents)r'   r3  r7  oldp2r:  rB  s         r*   rD  dirstate.setparents  s     :$$++B1$< 
 <<88DL$$++/2blyy##BG#<<r,   c                   U R                   R                  R                  U [        R                  " U5      5        Ub<  U R                  U5        UR                  SU R                  -  SU R                  SSS9  g U R                  nU" SSSSS9 nU R                  U5        U R                  S	   nU(       a  UR                  5         S S S 5        g ! , (       d  f       g = f)
Ns   dirstate-3-branch%s)r      plainTlocationpost_finalizer      w
atomictemp
checkambigs   _branch)	__class__r   setr   	fromlocal_setup_tr_abortaddfilegenerator_tr_key_suffix_write_branchr$   rn   r   )r'   r?  transactionvfsr   ces         r*   	setbranchdirstate.setbranch  s     	""4););F)CD"  -((&)<)<<""!" )  llDTdCqq! ,B

 DCCs   8C
Cc                @    UR                  U R                  S-   5        g )N   
)r   r   )r'   file_objs     r*   rV  dirstate._write_branch  s    t||e+,r,   c                    S H  nXR                   ;   d  M  [        X5        M!     SU l        SU l        [	        U R
                  S:  =(       d    U R                  =(       d    U R                  5      U l        SU l	        g)zCauses the next access to reread the dirstate.

This is different from localrepo.invalidatedirstate() because it always
rereads the dirstate. Use localrepo.invalidatedirstate() if you want to
check whether the dirstate has changed before rereading it.)r   r   r   Fr   N)
__dict__delattrrk   rl   r   ro   rq   r[   r=   rv   )r'   as     r*   r   dirstate.invalidate  sq     0AMM!  0 "'$(  1$ $..$##%
!
 r,   c                    X:X  a  gSU l         Ub*  U R                  U5        XR                  R                  U'   gU R                  R                  R	                  US5        g)z=Mark dest as a copy of source. Unmark dest if source is None.NT)rk   _check_sparser   copymappop)r'   sourcedests      r*   copydirstate.copy  sS     >v&&,IId#II!!$-r,   c                N    U R                   R                  R                  US 5      $ r#   )r   rg  r  )r'   files     r*   copieddirstate.copied  s    yy  $$T400r,   c                .    U R                   R                  $ r#   )r   rg  r   s    r*   copiesdirstate.copies  s    yy   r,   c                @   SU l         U R                  R                  U5      nUb  UR                  (       d  U R	                  U5        U R                  R                  U5      nU(       a&  U R                  R                  R                  US5        U(       a  SU l        U$ )a-  a "public" method for generic code to mark a file as tracked

This function is to be called outside of "update/merge" case. For
example by a command like `hg add X`.

if reset_copy is set, any existing copy information will be dropped.

return True the file was previously untracked, False otherwise.
TN)	rk   r   r  tracked_check_new_tracked_filenameset_trackedrg  rh  rl   )r'   filename
reset_copyr  pre_trackeds        r*   rw  dirstate.set_tracked  sx     		h'=,,X6ii++H5II!!(D1&*D#r,   c                f    U R                   R                  U5      nU(       a  SU l        SU l        U$ )za "public" method for generic code to mark a file as untracked

This function is to be called outside of "update/merge" case. For
example by a command like `hg remove X`.

return True the file was previously tracked, False otherwise.
T)r   set_untrackedrk   rl   )r'   rx  rets      r*   r}  dirstate.set_untracked  s/     ii%%h/DK&*D#
r,   c                    SU l         U R                  U   R                  (       d  U R                  U5        Uu  p4nU R                  R	                  XXE5        g)zFrecord that the current state of the file on disk is known to be cleanTN)rk   r   ru  rv  	set_clean)r'   rx  parentfiledatar   sizemtimes         r*   r  dirstate.set_clean
  sI     yy"**,,X6,U		HD8r,   c                H    SU l         U R                  R                  U5        g)z<record that the current state of the file on disk is unknownTN)rk   r   set_possibly_dirty)r'   rx  s     r*   r  dirstate.set_possibly_dirty  s     		$$X.r,   c                   U R                   (       a  Sn[        R                  " U5      eU R                  R	                  U5      nUc  SnOUR
                  nU(       dF  U(       d?  U R                  R	                  U5      b"  U R                  R                  U5        SU l        O#U(       d  U(       a  Ub  UR                  (       a  gU R                  R                  UUUSS9  g)a  Set a file as tracked in the parent (or not)

This is to be called when adjust the dirstate to a new parent after an history
rewriting operation.

It should not be called during a merge (p2 != nullid) and only within
a `with dirstate.changing_parents(repo):` context.
z7update_file_reference should not be called when mergingNFT)has_meaningful_mtime)	r;  r   r>   r   r  ru  reset_staterk   added)r'   rx  
p1_trackedrB   r  
wc_trackeds         r*   update_file_p1dirstate.update_file_p1  s     ==KC((--		h'=JJjyy}}X&2		%%h/"* U[[		 "' 	 	
r,   c           	     ,    U R                  UUUUUUS9  g)a  update the information about a file in the dirstate

This is to be called when the direstates parent changes to keep track
of what is the file situation in regards to the working copy and its parent.

This function must be called within a `dirstate.changing_parents` context.

note: the API is at an early stage and we might need to adjust it
depending of what information ends up being relevant and useful to
other processing.
)rx  r  r  p2_infopossibly_dirtyr  N)_update_file)r'   rx  r  r  r  r  r  s          r*   update_filedirstate.update_fileA  s)    * 	!!)) 	 	
r,   c                    U R                   S:  d(  U R                  S:  d  Sn[        R                  " U5      eU R                  " U0 UD6  g)a  NEVER USE THIS, YOU DO NOT NEED IT

This function is a variant of "update_file" to be called by a small set
of extensions, it also adjust the internal state of file, but can be
called outside an `changing_parents` context.

A very small number of extension meddle with the working copy content
in a way that requires to adjust the dirstate accordingly. At the time
this command is written they are :
- keyword,
- largefile,
PLEASE DO NOT GROW THIS LIST ANY FURTHER.

This function could probably be replaced by more semantic one (like
"adjust expected size" or "always revalidate file content", etc)
however at the time where this is writen, this is too much of a detour
to be considered.
r   zrequires a changes contextN)ro   r[   r   r>   r  )r'   r@   rA   rB   s       r*   hacky_extension_update_file$dirstate.hacky_extension_update_file_  sN    & $$q(D,@,@1,D.C((--	
	
r,   c           	         SU l         U R                  R                  U5      nUc  SnOUR                  nX:w  a  SU l        U R                  R                  UUUUU(       + US9  g )NTF)r  r  r  )rk   r   r  ru  rl   r  )	r'   rx  r  r  r  r  r  	old_entryprev_trackeds	            r*   r  dirstate._update_filez  sm     IIMM(+	 L$,,L%&*D#		%3!3) 	 	
r,   c                   [         R                  " U5        U R                  R                  U5      (       a:  [	        S5      nU[
        R                  " U5      -  n[        R                  " U5      e[        R                  " U5       H  nU R                  R                  U5      (       a    OU R                  R                  U5      nUc  ME  UR                  (       a  MX  [	        S5      nU[
        R                  " U5      [
        R                  " U5      4-  n[        R                  " U5      e   U R                  U5        g )Ns    directory %r already in dirstates#   file %r in dirstate clashes with %r)r   checkfilenamer   r   r   r   bytestrr   Abortr   finddirsr  removedrf  )r'   rx  rB   r   r  s        r*   rv  $dirstate._check_new_tracked_filename  s    h'99""8,,78C8##H--C++c""""8,Ayy&&q))IIMM!$E >?((+X-=-=h-GHHkk#&& - 	8$r,   c                    U R                   nUbQ  UR                  5       (       d;  U" U5      (       d-  [        S5      n[        S5      n[        R                  " X1-  US9eggg)z2Check that a filename is inside the sparse profileNs3   cannot add '%s' - it is outside the sparse checkoutsw   include file with `hg debugsparse --include <pattern>` or use `hg add -s <file>` to include file directory while adding)hint)r   alwaysr   r   r  )r'   rx  sparsematchrB   r  s        r*   rf  dirstate._check_sparse  sj    ))";+=+=+?+?x((NOQ kk#.t<< ) ,@"r,   c                2   UcG  [         R                  R                  [         R                  R                  U R                  U5      5      nU(       dD  U(       d8  SU;   a2  UR                  SS5      u  pgU R                  USUS 5      nUS-   U-   nU$ Un U$ SU;   aW  UR                  SS5      u  pgU R                  USUS5      nU R                  S-   U-   n	US-   [        R                  " Xy5      -   nO [        R                  " X R                  5      nXU'   U$ )Nr   r   FT)	r   r  lexistsr%   rg   rsplit
_normalizer   fspath)
r'   r  normedignoremissingexistsstoremapr   r   foldedrs
             r*   _discoverpathdirstate._discoverpath  s    >WW__RWW\\$**d%CDF TT\{{4+OOAumTBTA     v~}}T1-OOAumTBJJ%)TDKK$55VZZ8%Vr,   c                    [         R                  " U5      nU R                  R                  R	                  US 5      nUc2  U(       a  UnU$ U R                  XX4U R                  R                  5      nU$ r#   )r   normcaser   filefoldmapr  r  r'   r  isknownr  r  r  r  s          r*   _normalizefiledirstate._normalizefile  sj    t$&&**648>
  ++-9N9N r,   c                :   [         R                  " U5      nU R                  R                  R	                  US 5      nUc&  U R                  R
                  R	                  US 5      nUc2  U(       a  UnU$ U R                  XX4U R                  R
                  5      nU$ r#   )r   r  r   r  r  
dirfoldmapr  r  s          r*   r  dirstate._normalize  s    t$&&**648>YY))--fd;F>  ++-9M9M r,   c                L    U R                   (       a  U R                  XU5      $ U$ )a  
normalize the case of a pathname when on a casefolding filesystem

isknown specifies whether the filename came from walking the
disk, to avoid extra filesystem access.

If ignoremissing is True, missing path are returned
unchanged. Otherwise, we try harder to normalize possibly
existing path components.

The normalized case is determined based on the following precedence:

- version of name already stored in the dirstate
- version of name stored on disk
- version provided via command arguments
)r   r  )r'   r  r  r  s       r*   	normalizedirstate.normalize  s!    ( ????4-@@r,   c                F    U R                   R                  5         SU l        g )NT)r   clearrk   r   s    r*   r  dirstate.clear  s    		r,   c                   U R                   nUb  UR                  5       (       d{  U Vs/ s H  oT" U5      (       d  M  UPM     nnU(       a   U Vs/ s H  oT" U5      (       d  M  UPM     nnUb1  U  Vs1 s H  oT" U5      (       a  M  UiM     nnUR                  U5      nUc  Un/ nU R                  5         Oc[	        U5      S:  a7  / n/ nU H,  nXR;   a  UR                  U5        M  UR                  U5        M.     O[        U5      n	U	[        U5      -  nX-
  nU R                  c  U R                  U l        U R                  R                  XR                  R                  5        U HB  nU R                  (       a  U R                  U5        M'  U R                  R                  USSS9  MD     U H  nU R                  R                  U5        M      SU l        g s  snf s  snf s  snf )N
   T)r  r  )r   r  unionr  r  r   rQ  rv   r   r   rD  re   r:  r;  rw  r  rk   )
r'   parentallfileschangedfilesmatcherr   dirstatefilestoremove	to_lookupto_dropchangedfilessets
             r*   rebuilddirstate.rebuild  s    %%w~~'7'7#+:8awqz8H:+7F<a71:<F' 59(KDq
D%(K4::<H IGJJL# IG!=$$Q'NN1%	 " ",/O'#h-7I%1G<<88DL		V%8%8%?%?@A}}  #		%%## & 	  AII!!!$  ] ;F
 )Ls"   GGG!$G!3G&G&c                X   ^  Uc  gU 4S jnUR                  ST R                  -  U5        g)z3make sure we invalidate the current change on abortNc                4   > STl         TR                  5         g NF)rq   r   )r   r'   s    r*   on_abort*dirstate._setup_tr_abort.<locals>.on_abortK  s    .3D+OOr,   s   dirstate-invalidate%s)addabortrU  )r'   r   r  s   `  r*   rS  dirstate._setup_tr_abortF  s/    :	 	$t':'::	
r,   c                  ^ ^ T R                   (       d  g T R                  (       a   eT R                  =(       a    T R                  nT(       a  T R	                  T5        ST l        U U4S jnTR                  ST R                  -  T R                  4USSS9  U(       a0  TR                  ST R                  -  T R                  4U U4S jSSS9  g U 4S jnU" T R                  5       nT R                  TU5        S S S 5        U(       a.  U" T R                  5       nT R                  TU5        S S S 5        g g ! , (       d  f       ND= f! , (       d  f       g = f)	NTc                :   > STl         TR                  TU 5      4  g r  )rq   _writedirstater   r'   r   s    r*   
on_success"dirstate.write.<locals>.on_success`  s    27/##B*+r,   s   dirstate-1-main%srH  rI  s   dirstate-2-key-post%sc                (   > TR                  TU 5      $ r#   )_write_tracked_hintr  s    r*   <lambda> dirstate.write.<locals>.<lambda>p  s    d66r1=r,   c                (   > TR                  U SSSS9$ )NrL  TrM  )r$   )r   r'   s    r*   r  r  v  s    a$4Pr,   )rk   r=   rd   rl   rS  rq   rT  rU  rr   rs   r  r  )r'   r   	write_keyr  rn  r   s   ``    r*   r   dirstate.writeT  s4   {{ ,,,,**Ft/F/F	  $.2D+,
 $t':'::!!"    ##,t/B/BB&&(=%"& $  P$..!QA& " d''(A((Q/ )(  "!
 )(s   (D9E
9
E

Ec                \    U R                   R                  U R                  5        SU l        g)zGremove the tracked_hint file

To be used by format downgrades operationFN)r$   unlinkrs   rd   r   s    r*   delete_tracked_hintdirstate.delete_tracked_hint  s$     	D--.!&r,   c                     X R                   U'   g)zadd a callback to be called when the wd parents are changed

Callback will be called with the following arguments:
    dirstate, (oldp1, oldp2), (newp1, newp2)

Category is a unique identifier to allow overwriting an old callback
with a newer callback.
N)ru   )r'   categorycallbacks      r*   addparentchangecallback dirstate.addparentchangecallback  s     -5)r,   c                j   U R                   (       a   eU R                  bj  U R                  U R                  :w  aP  [        U R                  R                  5       5       H"  u  p4U" X R                  U R                  5        M$     S U l        U R                  R                  X5        SU l        SU l	        g r  )
r=   rv   r   r(  ru   r,  r   r   rk   rl   )r'   r   r  r   r  s        r*   r  dirstate._writedirstate  s    ,,,,<<#(@%d&=&=&C&C&EF||TXX6  GDL		"'r,   c                    [         R                  " [        R                  " 5       R                  5      nUR                  SU-  5        g )Ns   1
%s
)r   hexuuiduuid4r	  r   )r'   r   r   r#  s       r*   r  dirstate._write_tracked_hint  s-    hhtzz|))*	
S !r,   c                    U R                  U5      (       a  g[        R                  " U5       H  nU R                  U5      (       d  M    g   g)NTF)r   r   r  )r'   r   r/  s      r*   
_dirignoredirstate._dirignore  s<    <<??""1%A||A & r,   c           	        / n[         R                  R                  U R                  S5      5      (       a   UR	                  U R                  S5      5        U R
                  R                  S5       Hp  u  p#US:X  d  UR                  S5      (       d  M#  UR	                  [         R                  R                  U R                  [        R                  " U5      5      5        Mr     U$ )Nr   r   s   ignores   ignore.)r   r  r  r9   r   rm   configitemsr  r%   rj   r   
expandpath)r'   r_   namer  s       r*   r   dirstate._ignorefiles  s    77>>$**\233LLL12((..u5JDy DOOJ$?$? RWW\\$--9NOP	 6
 r,   c           	     .   [         R                  " U R                  5       5      n[        5       nU(       a  UR	                  5       n[
        R                  " X@R                  R                  SS9nU H  u  pgn[
        R                  " US5      u  pU	S:X  a  X;  a  UR                  U
5        M=  [
        R                  " U R                  S/ U/U R                  R                  S9nU" U5      (       d  M  XGU4s  $    UR                  U5        U(       a  M  g)NT)
sourceinfos   globs
   subincluder,   r   )Nr,   )collectionsdequer   rQ  popleftr   readpatternfilerm   r   	_patsplitr   r   rg   add)r'   r   r_   visitedipatternspatternlinenolinekindr/  r   s               r*   _ignorefileandlinedirstate._ignorefileandline  s    !!$"3"3"56%A//88==TH *2%",,Wg>=('QNNJJR' Q44t,, *2 KKN! e" r,   c           	     X   S nUR                   nU R                  n[        R                  n[        R
                  n[        R                  n[        R                  n	[        R                  n
U R                  n/ nUR                  n/ nUR                  nUR                  5       (       d  U R                  (       a  U R                  nOSn[        UR                  5       5      nUR!                  5         Su  nnU[#        U5      :  a  U[#        U5      :  a  UU   S-   nUU   U:  a  US-  nM6  U[#        U5      :  aF  UU   R%                  U5      (       a-  UU	 U[#        U5      :  a  UU   R%                  U5      (       a  M-  US-  nU[#        U5      :  a  U[#        U5      :  a  M  U(       a  SU;   a  S/nSn[&        R)                  U5      nSUS'   U H  nU(       a  U" USS	5      nOUnUU;   a  M   U" U" U5      5      nU" UR*                  5      nUU:X  a  UU;   a  SUU'   U" UU45        M]  UU	:X  d  UU
:X  a  UUU'   Mp  U" UU" U5      5        UU;   a  SUU'   M  M     UR7                  5       (       a2  [9        U5       H#  nUS:X  d  UU;   a  M  U" U5      (       a  M   UU	 M%     UR                  5       (       a  U R                  (       a  0 nUR;                  5        HU  u  nnUc  M  [<        R>                  " U5      nURA                  U5      nUc  [C        5       nUUU'   URE                  U5        MW     UR;                  5        HV  u  nn[#        U5      S:  d  M  U H9  n U RG                  U US	SU R                  RH                  5      n!U U!:w  d  M4  SUU '   M;     MX     UX4$ ! [,         at  nUU;   a  SUU'    SnAGM  U R                  R/                  U5      (       a  U" U5         SnAGM!  U" U[0        R2                  " UR4                  5      5         SnAGMO  SnAff = f)
a  Get stat data about the files explicitly specified by match.

Return a triple (results, dirsfound, dirsnotfound).
- results is a mapping from filename to stat result. It also contains
  listings mapping subrepos and .hg to None.
- dirsfound is a list of files found to be directories.
- dirsnotfound is a list of files that the dirstate thinks are
  directories and that were not found.c                   [        S5      n[        R                  " U 5      (       a  [        S5      nO[        R                  " U 5      (       a  [        S5      nOt[        R                  " U 5      (       a  [        S5      nOM[        R
                  " U 5      (       a  [        S5      nO&[        R                  " U 5      (       a  [        S5      n[        S5      U-  $ )Ns   unknowns   character devices   block devices   fifos   sockets	   directorys"   unsupported file type (type is %s))r   statS_ISCHRS_ISBLKS_ISFIFOS_ISSOCKS_ISDIR)r   r  s     r*   badtype'dirstate._walkexplicit.<locals>.badtype  s    Z=D||D!!,-d##)t$$zt$$|d##:;dBBr,   N)r   r   r   r   r,   r   FT)%badr   r   r   r  S_IFMTS_IFDIRS_IFREGS_IFLNKr9   r   isexactr   r  r(  r_   sortr  r  dictfromkeysst_moder   r   r   
strtolocalstrerroranypatslistr,  r   r  r  rQ  r  r  r  )"r'   r   subreposr  badfndmapr   getkinddirkindregkindlnkkindr%   	dirsfoundfoundadddirsnotfoundnotfoundaddr  r_   r
  jsubpathresultsffnfr  r  instr   r  ncpathsnormr  r  s"                                     r*   _walkexplicitdirstate._walkexplicit  s   	C 		yy++,,,,,,zz	##"))}}4??IIu{{}%1#e*nS]!2qkD(GQx'!Qc%j.U1X%8%8%A%A!H c%j.U1X%8%8%A%AFA #e*nS]!2 uEE I--)Br5$/W}F48_rzz*7?Tz&*b"X&W_"$GBK"gdm,Tz&* ") F ==??'];!x-Qxx
 # ==??tF 2:]]1%

2=EE!&F2J		! )  &||~eu:> %!%!3!3 $dDII4H4H"  6>,0GDM !&  . 	//e  F:"&GBKKyy''++#Bb("5"5dmm"DEEFs0   5;N+2N+N++
P)5P$(P$6'P$$P)c                L  ^ ^^^^^^^^ ^!^"^#^$^%^& U(       a!  [         R                  m[         R                  nO@U(       a  T R                  mT R                  nO [         R                  m[         R                  nT R
                  b]  [        R                  " TR                  5       5      n[        R                  " T R                  U/5      n[        R                  " TU5      mTR                  m!TR	                  5       m TR                  m"T R                  m[         R                  m[         R"                  n	[$        R&                  m[$        R(                  m%[$        R*                  mT R,                  mS=pTR/                  5       (       a  Sn
[         R                  nOTR1                  5       (       a  SnU
(       d,  T R2                  (       a  T R4                  m#T R6                  m$SnOT R4                  m#Sm$T R9                  TU5      u  m&pT"(       a%  U H  nT"" US   5        M     U H  nT"" U5        M     U=(       a    U=(       d    U(       + nU Vs/ s H  o" US   5      (       a  M  UPM     nnUUUUUUUU U!U"U#U$U%U&U 4S jnU H#  u  nnT#(       + =(       d    UU:H  nU" U/U5        M%     U H  nT&U	 M     T&S	 U(       Gd4  U
(       Gd,  T&(       d  T (       a  T Vs/ s H  nUPM     nnO)T Vs/ s H  nUT&;  d  M  T!" U5      (       d  M  UPM     nnUR;                  5         U(       a~  [<        R>                  " T R@                  SS9n[C        U5       HN  nT$(       a  T$" USS5      T&;   a  ST&U'   M  URE                  U5      (       a   U	" T" U5      5      T&U'   MI  ST&U'   MP     T&$ [C        U5      n[         RH                  " U Vs/ s H  nT" U5      PM     sn5       H  nUT&[K        U5      '   M     T&$ s  snf s  snf s  snf ! [F         a	    ST&U'    M  f = fs  snf )a  
Walk recursively through the directory tree, finding all files
matched by match.

If full is False, maybe skip some known-clean files.

Return a dict mapping filename to stat-like object (either
mercurial.osutil.stat instance or return value of os.stat()).

NFTr   c                  > U R                   nU (       Ga  [        R                  " S[        U 5      5        U R	                  5       nTR                  U5      nU(       d  MR  US:X  d  US:X  a  S nS nUS:w  a  Sn [        R                  " SU5         T" T" U5      SUS9nS S S 5        W GHD  u  pn
U(       a  X;  a  M  T(       a#  T" U=(       a    US	-   U-   =(       d    USS5      nOU=(       a    US	-   U-   =(       d    UnUT;  d  Ma  U	T:X  aI  T" U5      (       d  T(       a  T" U5        U" U5        UT;   a  T(       d  T" U5      (       a  S TU'   M  M  M  U	T:X  d  U	T:X  ac  UT;   a  T(       d  T" U5      (       a  U
TU'   M  M  T(       d  T" U5      (       a)  T" U5      (       d  U(       d
  T" US
S5      nU
TU'   GM  GM  GM  UT;   d  GM(  T(       d  T" U5      (       d  GM?  S TU'   GMG     U (       a  GM  g g ! , (       d  f       GNf= f! [        [        4 aK  nTR                  TR                  U5      [        R                  " UR                  5      5         S nAGMX  S nAff = f)Nzdirstate.walk works   thiss   allr,   r   z!dirstate.walk.traverse listdir %sT)r  skipr   F)r   r   counterr  rh  visitchildrensetlogPermissionErrorr   r  r  r   r&  r'  )workalreadynormedwaddndvisitentriesrB  entriesr:  r   r  r  r9  r.  r,  ignorer%   listdirr0  r   matchalwaysmatchfn	matchtdirr  normalizefiler/  r7  r'   s               r*   traversedirstate.walk.<locals>.traverse  s   ;;D 4c$i@XXZ$55b9#7*lf.D#'L9!D %H"M")$r(D"I N $+KAR $(= $ +2BIM7at  3R$Y]8q(7?#)"::#,$-bM $R!Tz{gbkk.2 ?Jz!W_!Tz#.'"++24GBK 3>"-f "G G (5)22ud)CB.0G  4Z[GBKK*.GBKQ $+' $ NM'):; IIB)<)<T]])K 	s6   9H G>H >
HH H I+ ?I&&I+r   )cached)&r   r   r   r  r  rh   r   exactr_   unionmatcherr   intersectmatchersrP  traversedirr   rN  r   r   r  r  r  r   r9   r!  prefixr   r  r  r>  r"  r   pathauditorrg   r'  checkr   	statfilesnext)'r'   r   r*  unknownignoredfull	dirignoreemsmr   rV  	skipstep3rG  r3  r   rS  rJ  rH  sr   visit
audit_pathr9  ivr
  r  r.  r,  rM  r%   rN  r0  rO  rP  rQ  r  rR  r/  r7  s'   ``                        @@@@@@@@@@@@@r*   walkdirstate.walkT  sb   , ZZF

I\\FI [[FI*.B&&(;(;R'@AB..ub9E--lln%%	yy,,,,,,,,zz!!==??EI\\^^II //MII M '+&8&8&I#!A$ !! " <t';|"<	74ay147=	/ =	/ =	/~ EB !*M4R1WMaS-(	  A
 FO  {$()DqD)$(LDqAW,<DLJJL
 &11$**TJ
u+B &)"dD9WD&* $))"--/*/R/GBK '+- &:  %[..5)A5a$q'5)ABB(*GDH% Cw 8d *L4  ' /*.GBK/ *Bs<   O<*O< P3
PPPPP!PPc                   U R                   b\  [        R                  " UR                  5       5      n[        R                  " U R
                  U/5      n[        R                  " X5      nU R                  R                  SS5      nUb#  [        R                  R                  SSU-  5        U R                  R                  SSS5      nU(       d  S[        R                  S'   [        R                  U R                  R                  UU R                   U R#                  5       U R$                  ['        U5      ['        U5      ['        U5      ['        UR(                  5      5	      u  n	n
nnnnnnnnnnU =R*                  U-  sl        UR(                  (       a  U H  nUR)                  U5        M     U R                  R,                  (       a  U H  n[/        U[0        5      (       a2  Uu  nn[3        S5      UU4-  nU R                  R-                  U5        MJ  [3        S	5      nU R                  R-                  U[4        R6                  " U R                   U R                   U5      S
4-  5        M     [9        U5       H,  u  nnUR;                  U[        R<                  " U5      5        M.     [>        R                  " U
UUUUUUS9nU	U4$ )Ns   workers   numcpuss   RAYON_NUM_THREADSs   %ds   enabledT   1s!   %s: ignoring invalid syntax '%s'
s*   skipping unreadable pattern file '%s': %s
s   No such file or directory)modifiedr  r  deletedr_  r`  clean) rh   r   rV  r_   rW  r   rX  rm   	configintr   environ
setdefaultr   rustmodstatusr   rj   r   r   r   rY  rk   r   
isinstancetupler   r   	canonpathr(  r  r&  r   )r'   r  
list_cleanlist_ignoredlist_unknownrc  rd  numcpusworkers_enabledlookuprn  r  r  ro  rp  r`  r_  warningsr  	traverseddirtydiritem	file_pathsyntaxrB   fnmessageru  s                                r*   _rust_statusdirstate._rust_status  sm   *0B&&(;(;R'@AB00=G (($$Y
;''(<egoN((--iTJ59H12 NNIINNMMOO$$%

	
 	u ##C( ! 88== dE**(,%IvAB!F C HHMM#&JKCHHMM$.. $t}}d 9	 !( "#;KBKKH//89 ' 
 r,   c           	     	   U R                   (       d  Sn[        R                  " U5      eX4Upn/ / / / / 4u  ppn/ / / pNnU R                  nUR	                  5         Sn[
        c  SnOU R                  (       a  SnO	U(       a  Sn [        R                  " U R                  5      nU(       a   U R                  XXy5      nUU4-   $ S nUR                  nUR                  nU
R                  nUR                  nUR                  nU	(       a  UR                  OUnU(       a  UR                  OUnUR                  nUR                  nU(       a  UR                  OUnUR                   nU R"                  nU R$                  n U R&                  n!U R                  R(                  n"U=(       d    UR*                  SLn#U R-                  XXU#S9R/                  5        GH_  u  n$n%U" U$5      (       d;  U(       d  U" U$5      (       a  U" U$5      (       a  U(       a  U" U$5        OU" U$5        MO  U" U$5      n&U&R0                  n'U&R2                  n(U%(       d  U&R4                  (       a
  U" U$5        M  U&R6                  (       a
  U" U$5        M  U&R8                  (       a
  U" U$5        M  U&R:                  (       a
  U" U$5        M  U&R4                  (       d  M  U!(       d  U&R<                  (       a  U" U$5        GM  U (       d  U&R>                  (       a  U" U$5        GM;  U(S:  aE  U(U%R@                  :w  a  U(U%R@                  [B        -  :w  d$  U'U%RD                  -  S-  (       a  U (       d  U$U";   aK  [F        RH                  " U%RD                  5      (       a  U(U%R@                  :w  a  U" U$5        GM  U" U$5        GM  Sn)Ub  [        RJ                  " U%U5      n)O5U&RM                  [        RN                  " U%5      5      (       a  U" U$5        GM)  U)b  U&RM                  U)5      (       d  U" U$5        GMM  U(       d  GMW  U" U$5        GMb     [P        RR                  " XXXSU5      n*U
U*U4$ ! [         a    Sn GNf = f! [
        R                   a     GNf = f)	a  Determine the status of the working copy relative to the
dirstate and return a pair of (unsure, status), where status is of type
scmutil.status and:

  unsure:
    files that might have been modified since the dirstate was
    written, but need to be read to be sure (size is the same
    but mtime differs)
  status.modified:
    files that have definitely been modified since the dirstate
    was written (different size or mode)
  status.clean:
    files that have definitely not been modified since the
    dirstate was written
z3Calling `status` outside a `running_status` contextTNFc                    g r#   r-   )r   s    r*   noopdirstate.status.<locals>.noop  s    r,   )ra  r   @   )*r[   r   r>   r   preloadrt  r   r   
get_fs_nowr$   r   r  FallbackErrorr$  __getitem__r   rV  r  r   r   rg  rY  rj  r,  r   r  ru  r  r  r  r   r   st_size
_rangemaskr%  r  S_ISLNKreliable_mtime_ofmtime_likely_equal_tomtime_ofr   ru  )+r'   r   r*  r`  rp  r_  rB   listignored	listcleanlistunknownr~  rn  r  r  ro  r,  use_rustmtime_boundaryresr  	dcontainsdgetladdmaddaadduaddiaddradddaddcaddmexactrb  r   r   rg  ra  r  r  tr   r  reliableru  s+                                              r*   ru  dirstate.statusl  s   . ##GC((--.5g46BB4F1%'"$b"%yy?H__HH	"&11$,,?N
 ''k n...	 %%	}}||!,w~~$!,w~~$~~~~(u||dOO	OO	OO	))## 9E--T9ii[D   

%'FB R==6"::9R=="RHRA66D66D!))RRRR Q%;%; H"q':': HAI+

Z8O0O!BJJ.%7IW}||BJJ//DBJJ4F RR#H%1#,#>#>$ 001C1CB1GHH R 'q/F/F 0 0 R"RKL Ww
 //]  	"!N	" (( s$    Q ,Q+ Q('Q(+RRc                  ^ U R                   m[        b  U R                   R                   mUR                  5       (       a  TR                  5       $ UR	                  5       nUR                  5       (       a  U Vs/ s H  o3T;   d  M
  UPM     sn$ UR                  5       (       a%  [        U4S jU 5       5      (       a  [        U5      $ T Vs/ s H  o1" U5      (       d  M  UPM     sn$ s  snf s  snf )zD
return files in the dirstate (in whatever state) filtered by match
c              3  ,   >#    U  H	  oT;   v   M     g 7fr#   r-   ).0r  r,  s     r*   	<genexpr>#dirstate.matches.<locals>.<genexpr>  s     !=u*us   )	r   rt  r  keysr_   r!  rZ  allr)  )r'   r   r_   r   r,  s       @r*   matchesdirstate.matches  s     yy99>>D<<>>99;==??  %2u!T	Au22<<>>c!=u!=== ;,4a584,, 3
 -s   9	C*C*C/!C/c                0   S/nU R                   R                  U R                  5      (       a_  UR                  U R                  5        U R                  (       a3  UR                  U R
                  R                  R                  5       5        [        U5      $ )z{list all filename currently used by this dirstate

This is only used to do `hg rollback` related backup in the transaction
r   )	r$   r  rr   r   rc   r   docketdata_filenamerw  )r'   r_   s     r*   all_file_namesdirstate.all_file_names   sf    
 <<t~~..LL($$TYY--;;=>U|r,   c              #  4  #    [        S5      n[        S5      n[        S5      n[        S5      nU R                  5        Hy  u  pU
R                  (       aC  U
R                  (       a  X;  a  X;  a  Xy-  v   O!X;  a  XY[        R
                  " U5      4-  v   U
R                  (       d  Ml  X;   d  Ms  Xi-  v   M{     U HU  n	Ub  U" U	5      (       d  M  U R                  U	5      n
U
R                  (       a  M9  X[        R
                  " U5      4-  v   MW     g7f)zJ
check the dirstate contents against the parent manifest and yield errors
s5   %s marked as tracked in p1 (%s) but not in manifest1
s*   %s marked as added, but also in manifest1
s2   %s marked as modified, but not in either manifest
s6   %s in manifest1, but not marked as tracked in p1 (%s)
N)r   r,  r  rn  r   shortr  r   )r'   m1m2r3  narrow_matchermissing_from_p1unexpected_in_p1missing_from_psmissing_from_dsr   r  s              r*   verifydirstate.verify,  s      E
 KLB
 F
 

HA>>akak)--[)

2,???{{{qw&** % A).2C2CNN1%E###%DJJrN(;;; s   B%D+D2AD7!D)rq   rp   ro   rk   rl   rn   rr   rs   r=   rw   re   r$   rv   rt   ru   rg   rj   r[   rh   rm   rc   rd   rf   )F)r
  r   )r   r	  r
  r   )r
  r   )r  zintdirstate.FlagFuncFallbackTr
  zintdirstate.FlagFuncReturnT)r
  r	  r#   )r   r	  r  Optional[bytes]r
  r	  )r  r	  r
  zintdirstate.DirstateItemT)r#  r   r
  r   )r
  Iterator[bytes])r
  z1Iterator[Tuple[bytes, intdirstate.DirstateItemT]])r
  zList[bytes])r3  r	  r7  r  )r?  r	  rW  Optional[TransactionT]r
  None)r
  r  )ri  r  rj  r	  r
  r  )rn  r	  r
  r  )r
  zDict[bytes, bytes])FFN)FN)FF)r  r	  r  r   r  r   r
  r	  )r  r	  r  Iterable[bytes]r  zOptional[Iterable[bytes]]r
  r  )r   r  r
  r  )r  r	  r  z$intdirstate.AddParentChangeCallbackTr
  r  )r   r	  r
  zintdirstate.IgnoreFileAndLineT)T)r   r   r*  r   r_  r   r`  r   ra  r   r
  zintdirstate.WalkReturnT)r   r   r*  r   r`  r   rp  r   r_  r   r
  zintdirstate.StatusReturnT)r   r   r
  r  )r3  r	  r  zOptional[Any]r
  r  )\r/   r0   r1   r2   rU  r   r   r   
contextlibcontextmanagerrG   r   r   r   r   r   propertyrV   rJ   rQ   propertycacher   r   r    r   r   r   r6   r   r   r   r   r   r9   r  rx   r  r  r   r$  r)  r,  	iteritemsr^   r3  r7  r;  r?  rM   rD  rZ  rV  r   rX   rk  ro  rr  rS   rw  r}  r]   r  r  r  r  r  r  rv  rf  r  r  r  r  r  r  rS  r   r  r  r  r  r  r   r  r>  rj  r  ru  r  r  r  r4   r-   r,   r*   r   r      s   N 5n
 @"  @"D 4  4l  0  4* ( ( 8 8 6 6 
 
 % %  y  # #* |M M O O * * 0 0 < <!
7:7	$7r ! !( '! I5++ 9 9. = =4*@	6-& 	. 	.1!  *   '9 '9 '/ '/
 %
 %
N  
 
:
@ 
>%"
=4
" IN$(AE	6   
 37	77 "7 0	7
 
7 7r
)0V'55)M5	5
("	,F0\ DD D 	D
 D D 
!DLP d]0]0 ]0 	]0
 ]0 ]0 
#]0~-*
 BF<<1><	< <r,   )<
__future__r   r  r  r   r  r  typingr   r   r   r   r   r	   r
   i18nr   interfaces.typesr   r   hgdemandimportr    r   r   r   r   r   r   r   r   r   r   r   r   dirstateutilsr   
interfacesr   intdirstate	importmodr   
importrustrt  HAS_FAST_DIRSTATE_V2r  	filecache	rangemaskr  r   r    r6   rG   rM   rS   rX   r]   r   r   	idirstater-   r,   r*   <module>r     s   #   	     
 #    

9
%


JT
2d* ""	""
'''	 ' 	  $####    r<{$$ r<r,   