
    q&f[                        d dl Z d dlZd dlZd dlZd dlZddlmZ d dlmZ ddl	m
Z
mZmZmZmZmZmZmZmZmZmZ ddlmZ ddlmZmZ  ej8                  d      Z ej<                  d	      ZeduZ ejB                  Z!ejD                  Z"e
jF                  Z$e
jJ                  Z% G d
 de"      Z& G d de"      Z'd Z(d Z)d Z*d Z+d Z,dZ-dZ. ej^                  ej`                         G d d	             Zy)    N   )_)tracing)dirstatemapencodingerrormatchnodepathutilpolicypycompatscmutiltxnutilutil)	timestamp)dirstater   parsersr   c                       e Zd ZdZd Zy)	repocachezfilecache for files in .hg/c                 8    |j                   j                  |      S N)_openerjoinselfobjfnames      4/usr/lib/python3/dist-packages/mercurial/dirstate.pyr   zrepocache.join9   s    {{&&    N__name__
__module____qualname____doc__r    r   r   r   r   6   s
    %'r   r   c                       e Zd ZdZd Zy)	rootcachez*filecache for files in the repository rootc                 $    |j                  |      S r   )_joinr   s      r   r   zrootcache.join@   s    yyr   Nr    r%   r   r   r'   r'   =   s
    4 r   r'   c                       fd}|S )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                     | j                   r&d}|j                  z  }t        j                  |       | g|i |S )Nz/calling `%s` after the dirstate was invalidated)_invalidated_contextr!   r   ProgrammingErrorr   argskwargsmsgfuncs       r   wrapzcheck_invalidated.<locals>.wrapL   sE    $$CC4== C((--D*4*6**r   r%   r2   r3   s   ` r   check_invalidatedr5   D   s    + Kr   c                 $      fd}t        |      S )Nc                     | j                   s&d}|j                  z  }t        j                  |       | g|i |S )Nz2calling `%s` outside of a changing_parents context)is_changing_parentsr!   r   r-   r.   s       r   r3   z'requires_changing_parents.<locals>.wrapW   sE    ''FC4== C((--D*4*6**r   r5   r4   s   ` r   requires_changing_parentsr:   V       + T""r   c                 $      fd}t        |      S )Nc                     | j                   s&d}|j                  z  }t        j                  |       | g|i |S )Nz*calling `%s` outside of a `changing_files`)is_changing_filesr!   r   r-   r.   s       r   r3   z%requires_changing_files.<locals>.wrapb   sE    %%>C4== C((--D*4*6**r   r9   r4   s   ` r   requires_changing_filesr?   a   r;   r   c                 $      fd}t        |      S )Nc                     | j                   s&d}|j                  z  }t        j                  |       | g|i |S )Nz*calling `%s` outside of a changing context)is_changing_anyr!   r   r-   r.   s       r   r3   z#requires_changing_any.<locals>.wrapm   sE    ##>C4== C((--D*4*6**r   r9   r4   s   ` r   requires_changing_anyrC   l   r;   r   c                 $      fd}t        |      S )Nc                     | j                   s5| j                  dkD  s&d}|j                  z  }t        j                  |       | g|i |S )Nr   zBcalling `%s` outside of a changing_files or running_status context)r>   _running_statusr!   r   r-   r.   s       r   r3   z/requires_changing_files_or_status.<locals>.wrapx   sY    &&$*>*>*B,  4== C((--D*4*6**r   r9   r4   s   ` r   !requires_changing_files_or_statusrG   w   s    + T""r   parentsfilesc                      e Zd ZdZ	 dOdZd Zd Zej                  e	d               Z
ej                  e	d               Zej                  d        Zej                  d        Zd	 Zed
        Zed        Zed        Zed        Zed        Z ed      d        Zed        Zd Z ed      d        Zed        Zed        Zed        Zed        Zd Z d Z!ed        Z"d Z#dPdZ$d Z%d  Z&d! Z'd" Z(e(Z)d# Z*d$ Z+d% Z,ed&        Z-d' Z.e/dPd(       Z0d) Z1d* Z2d+ Z3e4d,        Z5d- Z6d. Z7e8dOd/       Z9e8d0        Z:e;d1        Z<e;d2        Z=e/d3        Z>e/	 	 	 dQd4       Z?d5 Z@	 	 	 dQd6ZAd7 ZBd8 ZCd9 ZDdRd:ZEdRd;ZFdSd<ZGe/d=        ZHe/dPd>       ZId? ZJd@ ZKdA ZLdB ZMdC ZNdD ZOdE ZPdF ZQdG ZRdH ZSdTdIZTdJ ZUdK ZVdL ZWdM ZXdPdNZYy)Ur   r   c	                    || _         || _        || _        || _        || _        || _        || _        t        j                  |      | _	        d| _
        d| _        || _        i | _        d| _        d| _        d| _        d| _        d| _        d| _        d| _        d| j&                  z  | _        i | _        d| _        t0        j0                  | _        | j4                   y)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_typerF   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__zdirstate.__init__   s    " !0!1+!
+ !--d3"'    %*!*/'$4 - >"$".. 			r   c                     | j                   rd}t        j                  |      dt        |       v r| `dt        |       v r,| j
                  j                         r| j                          y y y )Nz1refreshing the dirstate in the middle of a change_branch_map)rB   r   r-   varsrl   rm   may_need_refresh
invalidater   r1   s     r   refreshzdirstate.refresh   sb     EC((--T
"T$ZDII$>$>$@OO %Ar   c                     | j                    y)zRmake sure the parents are loaded

        Used to avoid a race condition.
        N)_plr   s    r   prefetch_parentszdirstate.prefetch_parents   s    
 	r   c              #     K   |j                         du}| j                  }|j                         }|du}t        | j                        }|xs |xs | }|rR| j
                  rF|j                         du}|s2| j                  dk(  r#| j
                  rd}t        j                  |      |xr |xs | }	| xj                  dz  c_        	 d 	 | xj                  dz  c_        | j                  rd}	| j                          	 |	r&|j                         |u sJ | j                  |       y|s;| j
                  r.d}|j                  j                  |       | j                          yyy# t        $ r | j                           w xY w# | xj                  dz  c_        | j                  rd}	| j                          w w xY ww)uO  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)currentwlockrB   currenttransactionboolrF   rT   rX   r   r-   	Exceptionrp   r,   writerc   	develwarn)
r   repohas_lockis_changingtrhas_trnestedfirst_and_aloner1   should_writes
             r   running_statusz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+   CG 
E) BG )FF 6F==G c              #     K   |j                         d}t        j                  |      |j                         d u}|s8| j                  dk(  r)| j
                  rd}|j                  j                  |       | j                  dk\  sJ | j                  | j                  dk(  sJ || _        n7| j                  |k7  r(d}||| j                  fz  }t        j                  |      d}| xj                  dz  c_        	 d  	 | j                  dkD  sJ | xj                  dz  c_        | j                  dk  rd | _        | j                  dk(  sJ | j                  r| j                          n| j                  dk  }	 |j                         }||d uk7  r|rd}nd}t        j                  |      |r| j                  |       y y #  | j                           xY w# | j                  dkD  sJ | xj                  dz  c_        | j                  dk  rd | _        | j                  dk(  sJ | j                  r| j                          w | j                  dk  }w xY ww)	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)rx   r   r-   ry   rX   rT   rc   r}   rY   rp   r,   r|   )r   r~   change_typer1   r   r   r   ms           r   	_changingzdirstate._changing  sT     &LC((--((*$6$..!3OCGGc"##q((($''1,,, +D+-   K!2!233C((--!	9
 ''!+++  A%  ##q($(!++q000(( !#33q8$$&bn%BB((++JJrN 3	OO''!+++  A%  ##q($(!++q000(( !#33q8s,   C8I;G  CIGG A;IIc              #   j   K   | j                  |t              5 }| ddd       y# 1 sw Y   yxY ww)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_parentszdirstate.changing_parentsU  s2     , ^^D"56 	!G	 	 	   3'	303c              #   j   K   | j                  |t              5 }| ddd       y# 1 sw Y   yxY ww)aG  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_fileszdirstate.changing_filesn  s2     . ^^D"34 	G	 	 	r   c                 0    d}t        j                  |      )NzJMercurial 6.4 and later requires call to `dirstate.changing_parents(repo)`)r   r-   rq   s     r   parentchangezdirstate.parentchange  s    0 	 $$S))r   c                      | j                   dkD  S )z~Returns true if the dirstate is in the middle of a set of changes.

        This returns True for any kind of change.
        r   )rX   ru   s    r   rB   zdirstate.is_changing_any  s     ##a''r   c                 H    | j                   dk  ry| j                  t        k(  S )zsReturns true if the dirstate is in the middle of a set of changes
        that modify the dirstate parent.
        r   F)rX   rY   r   ru   s    r   r8   zdirstate.is_changing_parents  s'    
 1$  $777r   c                 H    | j                   dk  ry| j                  t        k(  S )zReturns true if the dirstate is in the middle of a set of changes
        that modify the files tracked or their sources.
        r   F)rX   rY   r   ru   s    r   r>   zdirstate.is_changing_files  s'    
 1$  $555r   c                     | j                  | j                  | j                  | j                  | j                  | j
                        S )zAReturn the dirstate contents (see documentation for dirstatemap).)r`   rV   r   rP   rN   rL   ru   s    r   rm   zdirstate._map  s<     ||HHLLJJ!!
 	
r   c                 <    | j                   y| j                         S )a!  The 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)rQ   ru   s    r   _sparsematcherzdirstate._sparsematcher  s$     & ""$$r      branchc                 "   d }d}	 t        j                  | j                  | j                  d      \  }}|j	                         j                         }||j                          	 |sy|S # t        $ r Y #w xY w# ||j                          w w xY w)Nr   r   s   default)r   
trypendingrP   r   readstripFileNotFoundErrorclose)r   fdatamodes       r   rl   zdirstate._branch  s    	((T\\9MGAt668>>#D }	 ! 		 }	 s$   AA* *	A63A9 5A66A9 9Bc                 6    | j                   j                         S r   )rm   rH   ru   s    r   rt   zdirstate._pl  s    yy  ""r   c                 8    | j                   j                  |      S r   )rm   hastrackeddir)r   ds     r   hasdirzdirstate.hasdir  s    yy&&q))r   	   .hgignorec                     | j                         }|st        j                         S |D cg c]  }d|z  	 }}t        j                  | j                  dg || j
                  j                        S c c}w )Ns
   include:%sr   warn)_ignorefilesmatchmodneverr	   rP   rV   r   )r   rI   r   patss       r   _ignorezdirstate._ignore  s`    !!#>>##+01a!11~~djj#r4dhhmmLL 2s   A1c                 d    | j                   j                  dd      xr t        j                  dk7  S )N   uis   slash   /)rV   
configboolr   ossepru   s    r   _slashzdirstate._slash  s'    xx""5(3N$8NNr   c                 @    t        j                  | j                        S r   )r   	checklinkrP   ru   s    r   
_checklinkzdirstate._checklink  s    ~~djj))r   c                 R    t        t        j                  | j                              S r   )rz   r   	checkexecrP   ru   s    r   
_checkexeczdirstate._checkexec  s    DNN4::.//r   c                 L    t        j                  | j                  d             S )N   .hg)r   fscasesensitiver)   ru   s    r   
_checkcasezdirstate._checkcase  s    ''

6(:;;;r   c                      | j                   |z   S r   )rS   )r   r   s     r   r)   zdirstate._join  s     }}q  r   c                      g  fd}|S )aS  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                 R   d }d }	 t        j                  j                  |             }j                  rt        j                  |      rSyj                  |       }|j                  r|j                  r)ysj                                  d   |       }d|v ryj                  rt        j                  |      ryy|j                  |       }|j                  r|j                  ryy|#sj                                  d   |       }d|v ryy# t        $ r Y yw xY w)Nr      lr      x)oslstatr)   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_flagsz$dirstate.flagfunc.<locals>.get_flags  s+   E!NXXdjjm, ??2&q)----#(%,,]_=%5]1%5a%8N~-#??2&  = NN1-E****#  &-,)00A)9q)9!)<~-#E  s   $D 	D&%D&r%   )r   r   r   r   s   `` @r   flagfunczdirstate.flagfunc  s     '	R r   c                 j    | j                   j                  dd      }|r|S t        j                         S )Nr   s   forcecwd)rV   configr   getcwd)r   forcecwds     r   ra   zdirstate._cwd2  s-     88??5+6O  r   c                     | j                   }|| j                  k(  ry| j                  }t        j                  |      s|t        j
                  z  }|j                  |      r|t        |      d S |S )a  Return 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)ra   rP   r   endswithsepr   r   
startswithlen)r   cwdrootseps      r   r   zdirstate.getcwd:  se     ii$****(x~~%G>>'"s7|~&& Jr   Nc                     || j                         }t        j                  | j                  ||      }| j                  rt        j
                  |      S |S r   )r   r   pathtorP   r   pconvert)r   r   r   paths       r   r   zdirstate.pathtoN  sC    ;++-C{{4::sA.;;==&&r   c                 T    | j                   j                  |      }|
t               S |S )z-return a DirstateItem for the associated path)rm   getDirstateItem)r   r   r   s      r   r   zdirstate.get_entryV  s&    		d#=>!r   c                     || j                   v S r   )rm   )r   keys     r   __contains__zdirstate.__contains__]  s    diir   c                 >    t        t        | j                              S r   )itersortedrm   ru   s    r   __iter__zdirstate.__iter__`  s    F499%&&r   c                 6    | j                   j                         S r   )rm   itemsru   s    r   r   zdirstate.itemsc  s    yy  r   c                 ^    | j                   D cg c]  }| j                  |       c}S c c}w r   )rt   rO   )r   ps     r   rH   zdirstate.parentsh  s#    +/884aq!444s   *c                 >    | j                  | j                  d         S )Nr   rO   rt   ru   s    r   p1zdirstate.p1k      ~~dhhqk**r   c                 >    | j                  | j                  d         S )Nr   r   ru   s    r   p2zdirstate.p2n  r   r   c                 N    | j                   d   | j                  j                  k7  S )zTrue if a merge is in progressr   )rt   rN   nullidru   s    r   in_mergezdirstate.in_mergeq  s#     xx{d118888r   c                 @    t        j                  | j                        S r   )r   tolocalrl   ru   s    r   branchzdirstate.branchv  s    --r   c                 L   || j                   j                  }| j                  dk(  rt        d      d| _        | j
                  d   }| j                  | j
                  | _        | j                   j                  }||k7  xr ||k(  }| j                  j                  |||      S )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   sO   cannot set dirstate parent outside of dirstate.changing_parents context managerTr   )fold_p2)	rN   r   rX   
ValueErrorrT   rt   r_   rm   
setparents)r   r   r   oldp2r   r  s         r   r  zdirstate.setparentsy  s     :$$++B1$= 
 <<88DL$$++6/2bFlyy##BG#<<r   c                    | j                   j                  j                  | t        j                  |             |?| j                  |       |j                  d| j                  z  d| j                  dd       y | j                  } |dddd      5 }| j                  |       | j                  d	   }|r|j                          d d d        y # 1 sw Y   y xY w)
Ns   dirstate-3-branch%s)r      plainTlocationpost_finalizer      w
atomictemp
checkambigs   _branch)	__class__rl   setr   	fromlocal_setup_tr_abortaddfilegenerator_tr_key_suffix_write_branchr   rW   rr   )r   r  transactionvfsr   ces         r   	setbranchzdirstate.setbranch  s    ""4););F)CD"  -((&)<)<<""!" )  llDTdC 		qq! ,B

		 		 		s   3CCc                 @    |j                  | j                  dz          y )N   
)r|   rl   )r   file_objs     r   r  zdirstate._write_branch  s    t||e+,r   c                     dD ]  }|| j                   v st        | |        d| _        d| _        t	        | j
                  dkD  xs | j                  xs | j                        | _        d| _	        y)a  Causes 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.)rm   rl   r   Fr   N)
__dict__delattrrT   rU   rz   rX   rZ   rF   r,   r_   )r   as     r   rp   zdirstate.invalidate  sz     0 	!ADMM!a 	! "'$(  1$ $..$##%
!
 r   c                     ||k(  ryd| _         |+| j                  |       || j                  j                  |<   y| j                  j                  j	                  |d       y)z=Mark dest as a copy of source. Unmark dest if source is None.NT)rT   _check_sparserm   copymappop)r   sourcedests      r   copyzdirstate.copy  sW     T>v&&,DIId#II!!$-r   c                 N    | j                   j                  j                  |d       S r   )rm   r&  r   )r   files     r   copiedzdirstate.copied  s    yy  $$T400r   c                 .    | j                   j                  S r   )rm   r&  ru   s    r   copieszdirstate.copies  s    yy   r   c                     d| _         | j                  j                  |      }||j                  s| j	                  |       | j                  j                  |      }|r&| j                  j                  j                  |d       |rd| _        |S )aU  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)	rT   rm   r   tracked_check_new_tracked_filenameset_trackedr&  r'  rU   )r   filename
reset_copyr   pre_trackeds        r   r3  zdirstate.set_tracked  sx     		h'=,,X6ii++H5II!!(D1&*D#r   c                 \    | j                   j                  |      }|rd| _        d| _        |S )a
  a "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)rm   set_untrackedrT   rU   )r   r4  rets      r   r8  zdirstate.set_untracked  s/     ii%%h/DK&*D#
r   c                     d| _         | j                  |   j                  s| j                  |       |\  }}}| j                  j	                  ||||       y)zFrecord that the current state of the file on disk is known to be cleanTN)rT   rm   r1  r2  	set_clean)r   r4  parentfiledatar   sizemtimes         r   r;  zdirstate.set_clean  sO     yy"**,,X6,tU		HdD%8r   c                 H    d| _         | j                  j                  |       y)z<record that the current state of the file on disk is unknownTN)rT   rm   set_possibly_dirty)r   r4  s     r   r@  zdirstate.set_possibly_dirty  s     		$$X.r   c                    | j                   rd}t        j                  |      | j                  j	                  |      }|d}n|j
                  }|s@|s>| j                  j	                  |      6| j                  j                  |       d| _        n|s|r||j                  ry| j                  j                  |||d       y)a4  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.
        s7   update_file_reference should not be called when mergingNFT)has_meaningful_mtime)	r   r   r-   rm   r   r1  reset_staterT   added)r   r4  
p1_trackedr1   r   
wc_trackeds         r   update_file_p1zdirstate.update_file_p1	  s     ==LC((--		h'=JJjyy}}X&2		%%h/"* U[[		 "' 	 	
r   c                 2    | j                  ||||||       y)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.
        )r4  rF  rE  p2_infopossibly_dirtyr<  N)_update_file)r   r4  rF  rE  rI  rJ  r<  s          r   update_filezdirstate.update_file1  s)    * 	!!)) 	 	
r   c                     | j                   dkD  s&| j                  dkD  sd}t        j                  |       | j                  |i | y)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)rX   rF   r   r-   rK  )r   r/   r0   r1   s       r   hacky_extension_update_filez$dirstate.hacky_extension_update_fileO  sP    & $$q(D,@,@1,D.C((--	
	
r   c                     d| _         | j                  j                  |      }|d}n|j                  }||k7  rd| _        | j                  j                  ||||| |       y )NTF)rI  rB  r<  )rT   rm   r   r1  rU   rC  )	r   r4  rF  rE  rI  rJ  r<  	old_entryprev_trackeds	            r   rK  zdirstate._update_filej  so     IIMM(+	 L$,,L:%&*D#		%3!3) 	 	
r   c                 R   t        j                  |       | j                  j                  |      r8t	        d      }|t        j                  |      z  }t        j                  |      t        j                  |      D ]  }| j                  j                  |      r ny| j                  j                  |      }|>|j                  rKt	        d      }|t        j                  |      t        j                  |      fz  }t        j                  |       | j                  |       y )Ns    directory %r already in dirstates#   file %r in dirstate clashes with %r)r   checkfilenamerm   r   r   r   bytestrr   Abortr   finddirsr   removedr%  )r   r4  r1   r   r   s        r   r2  z$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                     | j                   }|J|j                         s9 ||      s0t        d      }t        d      }t        j                  ||z  |      yyy)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   rU  )r   r4  sparsematchr1   rY  s        r   r%  zdirstate._check_sparse  sf    ))";+=+=+?x(NOQ kk#.t<< ) ,@"r   c                    |Gt         j                  j                  t         j                  j                  | j                  |            }|s=|s7d|v r3|j                  dd      \  }}| j                  |d|d       }|dz   |z   }|S |}|S d|v rX|j                  dd      \  }}| j                  |d|d      }| j                  dz   |z   }	|dz   t        j                  ||	      z   }n t        j                  || j                        }|||<   |S )Nr   r   FT)	r   r   lexistsr   rP   rsplit
_normalizer   fspath)
r   r   normedignoremissingexistsstoremapr   r   foldedrs
             r   _discoverpathzdirstate._discoverpath  s   >WW__RWW\\$**d%CDF TT\{{4+1OOAumTBTA     v~}}T1-1OOAumTBJJ%)TDKK1$55VTZZ8%HVr   c                     t        j                  |      }| j                  j                  j	                  |d       }|/|r|}|S | j                  ||||| j                  j                        }|S r   )r   normcaserm   filefoldmapr   rg  r   r   isknownrb  rc  ra  re  s          r   _normalizefilezdirstate._normalizefile  sn    t$&&**648>
  ++&-9N9N r   c                 .   t        j                  |      }| j                  j                  j	                  |d       }|&| j                  j
                  j	                  |d       }|/|r|}|S | j                  ||||| j                  j
                        }|S r   )r   ri  rm   rj  r   
dirfoldmaprg  rk  s          r   r_  zdirstate._normalize  s    t$&&**648>YY))--fd;F>  ++&-9M9M r   c                 D    | j                   r| j                  |||      S |S )aL  
        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   rl  rb  s       r   	normalizezdirstate.normalize  s#    $ ????4-@@r   c                 F    | j                   j                          d| _        y )NT)rm   clearrT   ru   s    r   rs  zdirstate.clear  s    		r   c                 v   | j                   }|m|j                         s]|D cg c]  } ||      s| }}|r|D cg c]  } ||      s| }}|)| D ch c]  } ||      r| }}|j                  |      }||}g }| j                          n_t	        |      dk  r3g }g }|D ])  }||v r|j                  |       |j                  |       + nt        |      }	|	t        |      z  }|	|z
  }| j                  | j                  | _        | j                  j                  || j                  j                         |D ]>  }| j                  r| j                  |       !| j                  j                  |dd       @ |D ]  }| j                  j                  |        d| _        y c c}w c c}w c c}w )N
   T)rF  rE  )r   rZ  unionrs  r   r   r  r_   rt   rm   r  rN   r   r   r3  rC  rT   )
r   parentallfileschangedfilesmatcherr   dirstatefilestoremove	to_lookupto_dropchangedfilessets
             r   rebuildzdirstate.rebuild  s   %%w~~'7#+:awqz:H:+7Fa71:FF' 59(Kq
(K%(K4::<H IGJJL# IG! &=$$Q'NN1%	& ",/O'#h-7I%	1G<<88DL		VT%8%8%?%?@ 	A}}  #		%%## & 		  	%AII!!!$	% ] ;F
 )Ls!   F,F,F1F1F6%F6c                 T     |y fd}|j                  d j                  z  |       y)z3make sure we invalidate the current change on abortNc                 4    d_         j                          y NF)rZ   rp   )r   r   s    r   on_abortz*dirstate._setup_tr_abort.<locals>.on_abort5  s    .3D+OOr   s   dirstate-invalidate%s)addabortr  )r   r   r  s   `  r   r  zdirstate._setup_tr_abort0  s/    :	 	$t':'::	
r   c                 l     j                   sy  j                  rJ  j                  xr  j                  }r j	                         d _         fd}j                  d j                  z   j                  f|dd       |r2j                  d j                  z   j                  f fddd       y  fd} | j                        5 } j                  |       d d d        |r. | j                        5 } j                  |       d d d        y y # 1 sw Y   :xY w# 1 sw Y   y xY w)	NTc                 :    d_         j                  |       f y r  )rZ   _writedirstater   r   r   s    r   
on_successz"dirstate.write.<locals>.on_successK  s    27/##B*+r   s   dirstate-1-main%sr
  r  s   dirstate-2-key-post%sc                 (    j                  |       S r   )_write_tracked_hintr  s    r   <lambda>z dirstate.write.<locals>.<lambda>[  s    d66r1= r   c                 .    j                  | ddd      S )Nr  Tr  )r   )r   r   s    r   r  z dirstate.write.<locals>.<lambda>a  s    a$4P r   )rT   r,   rM   rU   r  rZ   r  r  r[   r\   r  r  )r   r   	write_keyr  r,  r   s   ``    r   r|   zdirstate.write>  sD   {{ ,,,,**Ft/F/F	  $.2D+,
 $t':'::!!"    ##,t/B/BB&&(=%"& $  P$..! 	'QA&	' d''( 0A((Q/0 0 	' 	'
0 0s   DD*D'*D3c                 \    | j                   j                  | j                         d| _        y)zOremove the tracked_hint file

        To be used by format downgrades operationFN)r   unlinkr\   rM   ru   s    r   delete_tracked_hintzdirstate.delete_tracked_hintj  s$     	D--.!&r   c                 "    || j                   |<   y)a%  add 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)r^   )r   categorycallbacks      r   addparentchangecallbackz dirstate.addparentchangecallbackq  s     -5)r   c                 ^   | j                   rJ | j                  i| j                  | j                  k7  rPt        | j                  j                               D ]#  \  }} || | j                  | j                         % d | _        | j                  j                  ||       d| _        d| _	        y r  )
r,   r_   rt   r   r^   r   rm   r|   rT   rU   )r   r   r   r   r  s        r   r  zdirstate._writedirstate|  s    ,,,,<<#(@%d&=&=&C&C&EF 78t||TXX67DL		B"'r   c                     t        j                  t        j                         j                        }|j                  d|z         y )Ns   1
%s
)r
   hexuuiduuid4bytesr|   )r   r   r   r   s       r   r  zdirstate._write_tracked_hint  s-    hhtzz|))*	
S !r   c                     | j                  |      ryt        j                  |      D ]  }| j                  |      s y y)NTF)r   r   rV  )r   r   r   s      r   
_dirignorezdirstate._dirignore  s=    <<?""1% 	A||A	 r   c           	         g }t         j                  j                  | j                  d            r |j	                  | j                  d             | j
                  j                  d      D ]h  \  }}|dk(  s|j                  d      s|j	                  t         j                  j                  | j                  t        j                  |                   j |S )Nr   r   s   ignores   ignore.)r   r   rc  r)   r   rV   configitemsr   r   rS   r   
expandpath)r   rI   namer   s       r   r   zdirstate._ignorefiles  s    77>>$**\23LLL12((..u5 	QJD$y DOOJ$? RWW\\$--9NOP		Q
 r   c                    t        j                  | j                               }t               }|r|j	                         }t        j                  || j                  j                  d      }|D ]  \  }}}t        j                  |d      \  }	}
|	dk(  r|
|vr|j                  |
       ;t        j                  | j                  dg |g| j                  j                        } ||      s}|||fc S  |j                  |       |ry)NT)
sourceinfos   globs
   subincluder   r   )Nr   )collectionsdequer   r  popleftr   readpatternfilerV   r   	_patsplitr   r	   rP   add)r   r   rI   visitedipatternspatternlinenolinekindr   r   s               r   _ignorefileandlinezdirstate._ignorefileandline  s    !!$"3"3"56%A//488==TH *2 
-%",,Wg>a=('QNNJJR' Q4vt,,
- KKN! " r   c           	      h   d }|j                   }| j                  }t        j                  }t        j
                  }t        j                  }t        j                  }	t        j                  }
| j                  }g }|j                  }g }|j                  }|j                         s| j                  r| j                  }nd}t        |j                               }|j!                          d\  }}|t#        |      k  r|t#        |      k  r||   dz   }||   |k  r|dz  }2|t#        |      k  r:||   j%                  |      r&||= |t#        |      k  r||   j%                  |      r&|dz  }|t#        |      k  r|t#        |      k  r|rd|v rdg}d}t&        j)                  |      }d|d<   |D ]x  }|r ||dd	      }n|}||v r	  | ||            } ||j*                        }||k(  r||v rd||<    |||f       n(||	k(  s||
k(  r|||<   n || ||             ||v rd||<   z |j7                         r&t9        |      D ]  }|dk(  s||v r ||      r||=  |j                         r| j                  ri }|j;                         D ]P  \  }}|	t=        j>                  |      }|jA                  |      }|tC               }|||<   |jE                  |       R |j;                         D ]O  \  }}t#        |      dkD  s|D ]6  } | jG                  | |d	d| j                  jH                        }!| |!k7  s2d|| <   8 Q |||fS # t,        $ r_}||v rd||<   nJ| j                  j/                  |      r	 ||       n& ||t1        j2                  |j4                               Y d}~d}~ww xY w)
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                 |   t        d      }t        j                  |       rt        d      }nt        j                  |       rt        d      }nbt        j                  |       rt        d      }nAt        j
                  |       rt        d      }n t        j                  |       rt        d      }t        d      |z  S )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   badtypez'dirstate._walkexplicit.<locals>.badtype  s    Z=D||D!,-d#)t$zt$|d#:;dBBr   N)r   r   r   r   r   r   FT)%badrm   r   r   r  S_IFMTS_IFDIRS_IFREGS_IFLNKr)   r   isexactr   r_  r   rI   sortr   r   dictfromkeysst_moder   r   r   
strtolocalstrerroranypatslistr   r   ri  r   r  r  rg  ro  )"r   r	   subreposr  badfndmapr   getkinddirkindregkindlnkkindr   	dirsfoundfoundadddirsnotfoundnotfoundaddrq  rI   r  jsubpathresultsffnfr   r  instr   ra  ncpathsnormr   re  s"                                     r   _walkexplicitz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!H c%j.U1X%8%8%AFA #e*nS]!2 uEE I--) 	FBr5$/W}F48_rzz*7?Tz&*b"X&W_"$GBK"gdm,Tz&*+	FF ==?'] #;!x-Qx
# ==?tF  2:]]1%

2=EE!&F2J		!  &||~ 1eu:> % 1!%!3!3 $dDII4H4H"  6>,0GDM11 	<//e  F:"&GBKyy''+#Bb("5"5dmm"DEFs   A!M			N1AN,,N1c                 2    !"#$%& |r!t         j                  t         j                  }n;|r j                   j                  }n t         j                  t         j                  } j
                  Zt        j                  j                               }t        j                   j                  |g      }t        j                  |      j                  !j	                          j                  " j                  t         j                  t         j"                  }	t$        j&                  t$        j(                  %t$        j*                   j,                  dx}
}j/                         rd}
t         j                  }nj1                         rd}|
s' j2                  r j4                  # j6                  $d}n j4                  #d$ j9                  |      \  &}}"r!|D ]  } "|d           |D ]
  } "|        |xr |xs | }|D cg c]  } ||d         r| }} !"#$%& fd}|D ]  \  }}# xs ||k(  } ||g|        |D ]  }&|=  &d= |s|
s&s rD cg c]  }| }}nD cg c]  }|&vs !|      s| }}|j;                          |rpt=        j>                   j@                  d      }tC        |      D ]?  }$r $|dd      &v rd&|<   |jE                  |      r	  |	 |            &|<   ;d&|<   A &S tC        |      }t        jH                  |D cg c]
  } |       c}      D ]  }|&tK        |      <    &S c c}w c c}w c c}w # tF        $ r d&|<   Y w xY wc c}w )a3  
        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                    | j                   }| r_t        j                  dt        |              | j	                         }j                  |      }|sF|dk(  s|dk(  rd }d }|dk7  rd}	 t        j                  d|      5    |      d|      }d d d        D ]  \  }}	}
|r||vrr |xr |d	z   |z   xs |dd      }n|xr |d	z   |z   xs |}|vs>|	k(  r0 |      sr |        ||       |v sbs	 |      smd |<   s|	k(  s|	k(  r;|v rs	 |      s|
|<   s	 |      s |      r|s
 |d
d      }|
|<   |v ss	 |      sd |<    | r^y y # 1 sw Y   xY w# t        t        f$ rI}j                  j                  |      t        j                  |j                               Y d }~d }~ww xY w)Nzdirstate.walk works   thiss   allr   r   z!dirstate.walk.traverse listdir %sT)r  skipr   F)r   r   counterr   r'  visitchildrensetlogPermissionErrorr   r  r   r   r  r  )workalreadynormedwaddndvisitentriesr  entriesr  r   r  r   r  r  r  ignorer   listdirr  r	   matchalwaysmatchfn	matchtdirrq  normalizefiler  r  r   s               r   traversezdirstate.walk.<locals>.traverse  s   ;;D 4c$i@XXZ$55b9#7*lf.D#'L9!D %H"M J")$r(D"IJ $+ (/KAtR $(= $ +2BIM7at  3R$Y]8q(7?#)":#,$-bM $R!Tz{gbk.2!W_!Tz#.'"+24GBK"-f "G (5)22ud)CB.04Z[GBK*.GBKQ(/' J J'):; IIB)<)<T]])K 	s0   *E=  E1E= 1E:6E= =G>GGr   )cached)&r   r   r   r  rZ  rQ   r   exactrI   unionmatcherr   intersectmatchersr  traversedirrm   r  r   r   r  r  r  r  r)   r  prefixr   r_  rm  r  r  r   pathauditorrP   r   checkr   	statfilesnext)'r   r	   r  unknownignoredfull	dirignoreemsmr   r  	skipstep3r  r  r   r  r  r  sr   visit
audit_pathr  ivr  r   r  r  r  r   r  r  r  r  r  rq  r  r  r  s'   ``                        @@@@@@@@@@@@@r   walkzdirstate.walk=  sq    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';|"<	7ay177=	/ =	/ =	/~  	)EB !*M4R1WMaS-(		)  	A
	FO  {$()q))$(LqAW,<LLJJL
 &11$**TJ
u+ +B &)"dD9WD&* $))"-/*/R/GBK '+-+:  %[..5)Aa$q')AB +B(*GDH%+w 8d *L4  ' /*.GBK/ *Bs<   M1-M1=	M6	M;M; M;N N NNc                 D   | j                   Zt        j                  |j                               }t        j                  | j
                  |g      }t        j                  ||      }| j                  j                  dd      }|#t        j                  j                  dd|z         | j                  j                  ddd      }|sdt        j                  d<   t        j                  | j                  j                  || j                   | j#                         | j$                  t'        |      t'        |      t'        |      t'        |j(                        	      \  }	}
}}}}}}}}}}| xj*                  |z  c_        |j(                  r|D ]  }|j)                  |        | j                  j,                  r|D ]  }t/        |t0              r1|\  }}t3        d      ||fz  }| j                  j-                  |       Dt3        d	      }| j                  j-                  |t5        j6                  | j                   | j                   |      d
fz          |D ]*  \  }}|j9                  |t        j:                  |             , t=        j                  |
||||||      }|	|fS )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)modifiedrD  rW  deletedr  r  clean)rQ   r   r  rI   r  r   r  rV   	configintr   environ
setdefaultr   rustmodstatusrm   rS   r   r   rz   r  rT   r   
isinstancetupler   r   	canonpathr  r  r   )r   rz  
list_cleanlist_ignoredlist_unknownr  r  numcpusworkers_enabledlookupr  rD  rW  r  r  r  r  warningsr  	traverseddirtydiritem	file_pathsyntaxr1   fnmessager  s                                r   _rust_statuszdirstate._rust_status  sw   *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           	      H   | j                   sd}t        j                  |      |||}	}}g g g g g f\  }
}}}}g g g }}}| j                  }|j	                          d}t
        j                  t
        j                  t
        j                  t
        j                  t
        j                  t
        j                  t
        j                  f}t        d}n"| j                  rd}n|rd}nt        ||      sd}	 t!        j"                  | j$                        }|r	 | j)                  ||||	      }||fz   S d }|j,                  }|j.                  }|
j0                  }|j0                  }|j0                  }|	r|j0                  n|}|r|j0                  n|}|j0                  }|j0                  }|r|j0                  n|}|j2                  }| j4                  } | j6                  }!| j8                  }"| j                  j:                  }#|xs |j<                  du}$| j?                  |||	||$      jA                         D ]  \  }%}& ||%      s&|s ||%      r | |%      r|r ||%       n ||%       5 ||%      }'|'jB                  }(|'jD                  })|&s|'jF                  r	 ||%       l|'jH                  r	 ||%       |'jJ                  r	 ||%       |'jL                  r	 ||%       |'jF                  s|"s|'jN                  r	 ||%       |!s|'jP                  r	 ||%       |)dk\  r9|)|&jR                  k7  r|)|&jR                  tT        z  k7  s|(|&jV                  z  dz  r|!s|%|#v rBtY        jZ                  |&jV                        r|)|&jR                  k7  r
 ||%       ` ||%       j|'j]                  t!        j^                  |&            s
 ||%       |s ||%        ta        jb                  |||||||      }*|
|*|fS # t&        $ r d}Y w xY w# t        j*                  $ r Y w xY w)	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                      y r   r%   )r   s    r   noopzdirstate.status.<locals>.noop  s    r   )r  r   @   )2rF   r   r-   rm   preloadr   alwaysmatcherdifferencematcherexactmatcherincludematcherintersectionmatchernevermatcherr  r  r   r  r   
get_fs_nowr   r   r%  FallbackErrorr   __getitem__r   r  r  r   r   r&  r  r  r   r   r=  r1  rI  rD  rW  r   r   st_size
_rangemaskr  r  S_ISLNKmtime_likely_equal_tomtime_ofr   r  )+r   r	   r  r  r  r  r1   listignored	listcleanlistunknownr  r  rD  rW  r  r  use_rustallowed_matchersmtime_boundaryresr(  	dcontainsdgetladdmaddaadduaddiaddradddaddcaddmexactr   r   r   r&  r  r#  r   tr   r=  r  s+                                              r   r  zdirstate.statusN  s     ##GC((--.5ugY46BB4F1%'"$b"%yy ""&&!!##((!!!!
 ?H__HHE#34H	"&11$,,?N
 ''9k; n...	 %%	}}||!,w~~$!,w~~$~~~~(u||dOO	OO	OO	))## 9E--T9ii8[+D   

%'7	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001C1CB1GH
 HHo7	p eWgw
 //A  	"!N	" (( s$   2O8 P
 8PP
P! P!c                    | j                   t        | j                   j                   |j                         rj                         S |j	                         }|j                         r|D cg c]	  }|v s| c}S |j                         rt        fd|D              rt        |      S D cg c]  } ||      s| c}S c c}w c c}w )zT
        return files in the dirstate (in whatever state) filtered by match
        c              3   &   K   | ]  }|v  
 y wr   r%   ).0r#  r  s     r   	<genexpr>z#dirstate.matches.<locals>.<genexpr>  s     !="*!=s   )	rm   r  rZ  keysrI   r  r  allr  )r   r	   rI   r   r  s       @r   matcheszdirstate.matches  s     yy99>>D<<>99;==?  %2!T	A22<<>c!=u!== ;,a58,, 3
 -s   .	C8C2C Cc                    dg}| j                   j                  | j                        rZ|j                  | j                         | j                  r3|j                  | j
                  j                  j                                t        |      S )zlist all filename currently used by this dirstate

        This is only used to do `hg rollback` related backup in the transaction
        r   )	r   rc  r[   r   rL   rm   docketdata_filenamer  )r   rI   s     r   all_file_nameszdirstate.all_file_names  sc    
 <<t~~.LL($$TYY--;;=>U|r   c              #     K   t        d      }t        d      }t        d      }t        d      }| j                         D ]f  \  }	}
|
j                  r<|
j                  r|	|vr|	|vr||	z   n |	|vr||	t	        j
                  |      fz   |
j                  s[|	|v s`||	z   h |D ]G  }	|	 ||	      s| j                  |	      }
|
j                  r,||	t	        j
                  |      fz   I yw)zZ
        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   rE  r  r
   shortrD  r   )r   m1m2r   narrow_matchermissing_from_p1unexpected_in_p1missing_from_psmissing_from_dsr   r   s              r   verifyzdirstate.verify  s     E
 KLB
 F
 

 	+HAu>>arkark)A--b[)Q

2,???{{qBw&**	+  	<A).2CNN1%E##%DJJrN(;;;	<s   BC5C56C5C5)Fr   )FFN)FN)FF)T)Zr!   r"   r#   r  rj   rr   rv   
contextlibcontextmanagerr5   r   r   r   r   r   propertyrB   r8   r>   propertycacherm   r   r   rl   rt   r   r'   r   r   r   r   r   r)   r   ra   r   r   r   r   r   r   	iteritemsrH   r   r   r   r  r:   r  r  r  rp   rC   r*  r-  r/  r?   r3  r8  rG   r;  r@  rG  rL  rN  rK  r2  r%  rg  rm  r_  rq  rs  r  r  r|   r  r  r  r  r  r   r  r  r  r%  r  rR  rV  r`  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 < <!
5n ! !( '! I5++ 9 9. = =42-& 	. 	.1!  *   '9 '9 '/ '/
 %
 %
N  
 
:
@ 
@%"
=4
 2   2 2h
*0X'	5
("	,F0P}~P dU0n-*
<r   )1r  ra  r   r  r  i18nr   hgdemandimportr    r   r   r   r	   r   r
   r   r   r   r   r   r   dirstateutilsr   
interfacesr   intdirstateinterfaceutil	importmodr   
importrustr  HAS_FAST_DIRSTATE_V2rd  	filecache	rangemaskr5  r   r   r'   r5   r:   r?   rC   rG   r   r   implementer	idirstater%   r   r   <module>rt     s     	    "   
 &

9
%
&

J
'd* ""	""
'''	 ' 	  $####     ;001W< W< 2W<r   