https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/mercurial/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/mercurial/__pycache__/dirstatemap.cpython-310.pyc
o

�]Lb_�@s�ddlmZddlZddlmZddlmZmZmZm	Z	m
Z
mZddlm
ZmZe�d�Ze�d�ZejZedur=ejZnejZd	ZGd
d�de�ZGdd
�d
e�Zedur`Gdd
�d
e�ZdSdS)�)�absolute_importN�)�_)�error�pathutil�policy�pycompat�txnutil�util)�docket�v2�parsers�dirstatei���c@s�eZdZdZdZdZdd�Zdd�Zd2dd�Zd	d
�Z	dd�Z
d
d�Zdd�Zd2dd�Z
d3dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Z				$	$	d4d%d&�Zd'd(�Zd5d*d+�Zed,d-��Zd.d/�Zd0d1�ZdS)6�_dirstatemapcommonz�
    Methods that are identical for both implementations of the dirstatemap
    class, with and without Rust extensions enabled.
    NcCsF||_||_||_||_||_d|_d|_d|_d|_d|_	d|_
dS)Nsdirstate�F)�_use_dirstate_v2�_nodeconstants�_ui�_opener�_root�	_filename�_nodelen�_parents�
_dirtyparents�_docket�_pendingmode)�self�ui�opener�root�
nodeconstants�use_dirstate_v2�r"�7/usr/lib/python3/dist-packages/mercurial/dirstatemap.py�__init__2s
z_dirstatemapcommon.__init__cCs
|jdS)z5Loads the underlying data, if it's not already loadedN��_map�rr"r"r#�preloadA�
z_dirstatemapcommon.preloadcCs|j�||�S�N)r&�get)r�key�defaultr"r"r#r+E�z_dirstatemapcommon.getcC�
t|j�Sr*)�lenr&r'r"r"r#�__len__H�
z_dirstatemapcommon.__len__cCr/r*��iterr&r'r"r"r#�__iter__Kr2z_dirstatemapcommon.__iter__cC�
||jvSr*r%)rr,r"r"r#�__contains__Nr2z_dirstatemapcommon.__contains__cCs
|j|Sr*r%)r�itemr"r"r#�__getitem__Qr2z_dirstatemapcommon.__getitem__cC�dS)z�incremente the dirstate counter if applicable

        This might be a no-op for some subclass who deal with directory
        tracking in a different way.
        Nr"�r�filename�	old_entryr"r"r#�
_dirs_incrY�z_dirstatemapcommon._dirs_incrFcCr:)z�decremente the dirstate counter if applicable

        This might be a no-op for some subclass who deal with directory
        tracking in a different way.
        Nr")rr<r=�remove_variantr"r"r#�
_dirs_decr`r?z_dirstatemapcommon._dirs_decrcCr:)z record updated state of an entryNr"�r�f�entryr"r"r#�_refresh_entrygr?z!_dirstatemapcommon._refresh_entrycCr:)z�add a new dirstate entry (or replace an unrelated one)

        The fact it is actually new is the responsability of the caller
        Nr"rBr"r"r#�
_insert_entryjr?z _dirstatemapcommon._insert_entrycCr:)z�remove any entry for file f

        This should also drop associated copy information

        The fact we actually need to drop it is the responsability of the callerNr"�rrCr"r"r#�_drop_entrypr?z_dirstatemapcommon._drop_entrycCs ||}|��|�||�dS)z<record that the current state of the file on disk is unknownN)�set_possibly_dirtyrE)rr<rDr"r"r#rIysz%_dirstatemapcommon.set_possibly_dirtycCs<||}|t@}|�|||�|�||�|j�|d�dS)z$mark a file as back to a clean stateN)�	rangemask�	set_cleanrE�copymap�pop)rr<�mode�size�mtimerDr"r"r#rKs
z_dirstatemapcommon.set_cleancCs�d}|�|�}|dur|�|�tdd�}|�||�d}|S|js6|�||�|��|�||�d}|S|��|�||�|S)NFT)�
wc_tracked)r+r>�DirstateItemrF�tracked�set_trackedrErI)rr<�newrDr"r"r#rT�s&

���z_dirstatemapcommon.set_trackedcCsV|�|�}|durdS|j|||jd�|js|j�|d�|��|�||�dS)z4Mark a file as no longer tracked in the dirstate mapNF)r=r@T)r+rA�added�p2_inforLrM�
set_untrackedrErBr"r"r#rX�s
z _dirstatemapcommon.set_untrackedTc
Cs||j�|d�|s!|s!|s!|j�|�}|�|�|j||d�dS|j�|�}|�||�t|||||d�}	|�||	�dS)ahSet a entry to a given state, diregarding all previous state

        This is to be used by the part of the dirstate API dedicated to
        adjusting the dirstate after a update/merge.

        note: calling this might result to no entry existing at all if the
        dirstate map does not see any point at having one for this file
        anymore.
        N)r=)rQ�
p1_trackedrW�has_meaningful_mtime�parentfiledata)	rLrMr&r+rHrAr>rRrF)
rr<rQrYrWrZ�has_meaningful_datar[r=rDr"r"r#�reset_state�s 
�z_dirstatemapcommon.reset_statecCsLt�|j|j|j�\}}|jdur!|j|kr!|��t�t	d���||_|S)Ns1working directory state may be changed parallelly)
r	�
trypendingrrrr�closer�Abortr)r�fprNr"r"r#�_opendirstatefile�s�z$_dirstatemapcommon._opendirstatefile���c
Cspz|���}|�|�Wd�WS1swYWdSty7}z|jtjkr,�WYd}~dSd}~ww)N�)rb�read�IOError�errno�ENOENT)rrOra�errr"r"r#�_readdirstatefile�s
(���z$_dirstatemapcommon._readdirstatefilecCs2|js|jst�d��tj�|��|j�|_|jS)Ns'dirstate only has a docket in v2 format)	rrr�ProgrammingError�	docketmod�DirstateDocket�parserjrr'r"r"r#r�s�
�z_dirstatemapcommon.docketc	s��j}tj����t|�|�}|���|r|��d��j�	�|�|�	|�
��|��|jrM|���d��fdd�	}|rJd|j}|�
||�n|�|�_dS)Nrcs�j���Sr*)r�unlink)�_tr��
data_filenamerr"r#�<lambda>sz7_dirstatemapcommon.write_v2_no_append.<locals>.<lambda>sdirstate-v2-clean-r*)rrlrm�
with_new_uuid�parentsr0rr�addr�write�	serializer_�uuid�addpostcloser)	r�tr�st�meta�packed�
old_docket�
new_docketro�categoryr"rqr#�write_v2_no_append�s$�

z%_dirstatemapcommon.write_v2_no_appendcCs�|jsL|jr|jj|_|jS|jd}|�|�}t|�}||kr5|d|j�||jd|j�f|_|jS|dkrE|jj|jjf|_|jSt	�
td���|jS)N�rs(working directory state appears damaged!)rrrrurrjr0r�nullidrr`r)r�read_lenr|�lr"r"r#rus*

�
���	��z_dirstatemapcommon.parentsr*�NF)FFFTTN)rc)�__name__�
__module__�__qualname__�__doc__r&rLr$r(r+r1r5r7r9r>rArErFrHrIrKrTrXr]rbrj�propertyrr�rur"r"r"r#r'sB


	
�*



rc@s�eZdZdZedd��Zedd��Zdd�Zdd	�ZeZ	d
d�Z
dd
�Zd.dd�Zdd�Z
dd�Zedd��Zd/dd�Zd0dd�Zedd��Zedd��Zd d!�Zd"d#�Zed$d%��Zed&d'��Zd(d)�Zd*d+�Zd,d-�ZdS)1�dirstatemapa�Map encapsulating the dirstate's contents.

    The dirstate contains the following state:

    - `identity` is the identity of the dirstate file, which can be used to
      detect when changes have occurred to the dirstate file.

    - `parents` is a pair containing the parents of the working copy. The
      parents are updated by calling `setparents`.

    - the state map maps filenames to tuples of (state, mode, size, mtime),
      where state is a single character representing 'normal', 'added',
      'removed', or 'merged'. It is read by treating the dirstate as a
      dict.  File state is updated by calling various methods (see each
      documentation for details):

      - `reset_state`,
      - `set_tracked`
      - `set_untracked`
      - `set_clean`
      - `set_possibly_dirty`

    - `copymap` maps destination filenames to their source filename.

    The dirstate also provides the following views onto the state:

    - `filefoldmap` is a dict mapping normalized filenames to the denormalized
      form that they appear as in the dirstate.

    - `dirfoldmap` is a dict mapping normalized directory names to the
      denormalized form that they appear as in the dirstate.
    cCsi|_|��|jSr*)r&rer'r"r"r#r&Ps�dirstatemap._mapcCsi|_|j|jSr*)rLr&r'r"r"r#rLVs�dirstatemap.copymapcCs\|j��|j��|�|jj|jj�t�|d�t�|d�t�|d�t�|d�dS)N�_dirs�_alldirssfilefoldmap�
dirfoldmap)r&�clearrL�
setparentsrr�r
�clearcachedpropertyr'r"r"r#r�\s

�dirstatemap.clearcC�t�|j�Sr*)r�	iteritemsr&r'r"r"r#�itemse��dirstatemap.itemsccs0�|��D]\}}||j|j|j|jfVqdS)z�
        Return an iterator of (filename, state, mode, size, mtime) tuples

        `all` is unused when Rust is not enabled
        N)r��staterNrOrP)r�allr<r8r"r"r#�
debug_iterks���dirstatemap.debug_itercC�
|j��Sr*)r&�keysr'r"r"r#r�tr2�dirstatemap.keysFcCsZ||f|_d|_i}|r+t�|j�D]\}}|jr*|j�|d�}|r&|||<|��q|S)NT)	rrrr�r&rWrLrM�drop_merge_data)r�p1�p2�fold_p2�copiesrC�s�sourcer"r"r#r�ys
��dirstatemap.setparentscCs�tj�|j�|j��|_|jr|jj	sdS|j�
|j���}n|��}|s'dSt�
td�r7t�t|�d�|_|jrR|jj}|jj}t�tj�}||j|j||�nt�tj�}||j|j|�}|jsh|j|�|jj|_|jj|_|jj|_dS)Nsdict_new_presized�G)r
�filestat�frompathr�joinr�identityrrryrerrrj�safehasattrr
�dict_new_presizedr0r&ru�
tree_metadata�nogcr�parse_dirstaterLrr�r7r9r+)rr|�pr}r�r"r"r#re�s0�


zdirstatemap.readcCs^|jrt�|j|j�\}}|�||||�nt�|j|j|���}|�|�|�	�d|_
dSr�)rr�
pack_dirstater&rLr�r
rurwr_r)rr{r|r~r}r"r"r#rw�s�

�dirstatemap.writecC�|j|jSr*�r&r�r'r"r"r#r����dirstatemap.identityNcCsN|dus|jrd|jvr|j�|�|dur#d|jvr%|j�|�dSdSdS)z-incremente the dirstate counter if applicableN�_dirs�_alldirs)�removed�__dict__r��addpathr�r;r"r"r#r>�s
�zdirstatemap._dirs_incrcCs�|dur d|jvr|js|j�|�d|jvr|s|j�|�n
|r-d|jvr-|j�|�d|jvr@t�|�}|j�	|d�dSdS)z-decremente the dirstate counter if applicableNr�r��filefoldmap)
r�r�r��delpathr�r�r
�normcaser�rM)rr<r=r@�normedr"r"r#rA�s�

�zdirstatemap._dirs_decrcCsnztj}Wn	tyYn
w||jtjtj�Si}tj}t�	|j�D]
\}}|j
s0||||�<q#d|d<|S)zeReturns a dictionary mapping normalized case paths to their
        non-normalized versions.
        �.)r
�make_file_foldmap�AttributeErrorr&r
�normcasespec�normcasefallbackr�rr�r�)r�makefilefoldmaprCr��namer�r"r"r#r��s 
����dirstatemap.filefoldmapcCs&i}tj}|jD]}||||�<q|Sr*)r
r�r��rrCr�r�r"r"r#�
dirfoldmap�s

�dirstatemap.dirfoldmapcCr6)zo
        Returns True if the dirstate contains a tracked (not removed) file
        in this directory.
        )r��r�dr"r"r#�
hastrackeddir�
�dirstatemap.hastrackeddircCr6)zn
        Returns True if the dirstate contains a file (tracked or removed)
        in this directory.
        )r�r�r"r"r#�hasdirr��dirstatemap.hasdircCstj|jdd�S)NT)�only_tracked�r�dirsr&r'r"r"r#r�szdirstatemap._dirscCr�r*r�r'r"r"r#r�szdirstatemap._alldirscCs|js|j�|d�dSdSr*)�any_trackedr&rMrBr"r"r#rEs��dirstatemap._refresh_entrycCs||j|<dSr*r%rBr"r"r#rF#r.�dirstatemap._insert_entrycCs |j�|d�|j�|d�dSr*)r&rMrLrGr"r"r#rH&��dirstatemap._drop_entry�Fr*r�)r�r�r�r��
propertycacher&rLr�r�r�r�r�r�rerwr�r>rAr�r�r�r�r�r�rErFrHr"r"r"r#r�,s>#

		
6


	



r�c@s�eZdZedd��Zedd��Zdd�Zdd�Zd	d
�Z	e	Z
dd�Zd%dd�Zedd��Z
dd�Zedd��Zdd�Zdd�Zedd��Zdd�Zdd�Zd d!�Zd"d#�Zd$S)&r�cCs�tj�|j�|j��|_|jr1|jj	r|j�
|j���}nd}tj
�||jj|jj�|_|jj}ntj
�|���\|_}|rF|jsF|j|�|jj|_|jj|_|jj|_|jS)z<
            Fills the Dirstatemap when called.
            rd)r
r�r�rr�rr�rrryrerr�rustmod�DirstateMap�new_v2�	data_sizer�r&ru�new_v1rjrr�r7r9r+)r�datarur"r"r#r&1s(��

�




r�cCr�r*)r&rLr'r"r"r#rLRr)r�cC�|j�|�S)z�
            Return an iterator of (filename, state, mode, size, mtime) tuples

            `all`: also include with `state == b' '` dirstate tree nodes that
            don't have an associated `DirstateItem`.

            )r&r�)rr�r"r"r#r�Vsr�cCsF|j��|�|jj|jj�t�|d�t�|d�t�|d�dS)Nr�r�r�)r&r�r�rr�r
r�r'r"r"r#r�`s
�r�cCr�r*)r&r�r'r"r"r#r�ir2r�cCr/r*r3r'r"r"r#r�or2r�Fc
Csx||f|_d|_i}|r:dd�|j��D�}|j}|D]}|�|�}|j�|d�}	|	r/|	||<|��|�||�q|S)NTcSsg|]	\}}|jr|�qSr")rW)�.0rCr�r"r"r#�
<listcomp>~s

��z*dirstatemap.setparents.<locals>.<listcomp>)	rrr&r�r+rLrMr��set_dirstate_item)
rr�r�r�r��files_with_p2_info�rust_maprC�er�r"r"r#r�ts 
�
r�cCr�r*r�r'r"r"r#r��r�r�c
CsV|js|��\}}|j�||�}|�|�|��d|_dS|jjdu}|j�	|�\}}}|r�|j}	|	�
�}
|r?|�|
|	j�|�
|
d��.}|�|	j�|��|	jksUJ�|�|�}|durl|t|�kslJ|t|�f��Wd�n1svwY|	jt|�7_|��|	_||	_|�|	���|��n|�||||�t�|d�d|_dS)NFsr+bs_map)rrur&�write_v1rwr_rrry�write_v2rrrvr�r�seek�tellr0r�rxr�r
r�)
rr{r|r�r�r~�
can_appendr}�appendrrrra�writtenr"r"r#rw�s<

��


r�cCr�)zmReturns a dictionary mapping normalized case paths to their
            non-normalized versions.
            )r&�filefoldmapasdictr'r"r"r#r��r�r�cCr�r*)r&r�r�r"r"r#r��r�r�cCr�r*)r&r�r�r"r"r#r��r�r�cCs*i}tj}|j��D]}||||�<q
|Sr*)r
r�r&�tracked_dirsr�r"r"r#r��s
r�cCs(|js|j�|�dS|j�||�dSr*)r�r&�drop_item_and_copy_source�addfilerBr"r"r#rE�sr�cCs|j�||�dSr*)r&r�rBr"r"r#rF�sr�cCs|j�|�dSr*)r&r�rGr"r"r#rH�sr�cCs t|t�sJ�|j�||�dSr*)�
isinstancerRr&r�)rr,�valuer"r"r#�__setitem__�r�zdirstatemap.__setitem__Nr�)r�r�r�r�r&r�rLr�r�r�r�r�r�r�rwr�r�r�r�rErFrHr�r"r"r"r#r�-s0
 

	

%

	)�
__future__rrg�i18nr�rrrrr	r
�
dirstateutilsrrlr�	importmodr
�
importrustr�r�rRrJ�objectrr�r"r"r"r#�<module>s* 	

�

https://t.me/RX1948 - 2025