HEX
Server: Apache
System: Linux infong-uk86 4.4.400-icpu-106 #2 SMP Mon Sep 15 08:23:40 UTC 2025 x86_64
User: u44115835 (4976590)
PHP: 8.4.17
Disabled: NONE
Upload Files
File: //kunden/lib/python3/dist-packages/breezy/__pycache__/memorytree.cpython-39.pyc
a

�*�^�/�@sxdZddlmZddlZddlZddlmZmZmZ	ddl
mZddlm
Z
ddlmZdd	lmZGd
d�de
�ZdS)z5MemoryTree object.

See MemoryTree for more details.
�)�absolute_importN�)�errors�lock�revision)�	Inventory)�MutableInventoryTree)�sha_file)�MemoryTransportc@seZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
edd��Zdd�Z
dd�ZdBdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�ZdCd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd1d2�Zd3d4�Zd5d6�Zd7d8�ZdDd:d;�Z d<d=�Z!d>d?�Z"dEd@dA�Z#dS)F�
MemoryTreez�A MemoryTree is a specialisation of MutableTree.

    It maintains nearly no state outside of read_lock and write_lock
    transactions. (it keeps a reference to the branch, and its last-revision
    only).
    cCs$||_|j|_||_d|_d|_dS)z4Construct a MemoryTree for branch using revision_id.rN)�branchZ
controldir�_branch_revision_id�_locks�
_lock_mode)�selfr�revision_id�r�3/usr/lib/python3/dist-packages/breezy/memorytree.py�__init__.s
zMemoryTree.__init__cCsdS)NTr�rrrr�supports_symlinks6szMemoryTree.supports_symlinkscCsdS�NFrrrrr�supports_tree_reference9sz"MemoryTree.supports_tree_referencecCs
|j��S�N)r�get_config_stackrrrrr<szMemoryTree.get_config_stackcCsdSrr�r�filenamerrr�is_control_filename?szMemoryTree.is_control_filenamecCs�|����t|||�D]�\}}}|durn|j�|�j}t�|�rFd}n(t�|�rVd}nt�|�rfd}ntd��|dur�|j	j
||d�q|j	j
|||d�qWd�n1s�0YdS)zSee MutableTree._add.N�file�symlink�	directoryzUnknown file kind)�kind)r!�file_id)�lock_tree_write�zip�_file_transport�stat�st_mode�S_ISREG�S_ISLNK�S_ISDIR�AssertionError�
_inventoryZadd_path)r�filesZids�kinds�fr"r!r'rrr�_addCs



zMemoryTree._addcCs|jS)zSee Tree.basis_tree().)�_basis_treerrrr�
basis_treeVszMemoryTree.basis_treecCst�|���}t||�S)zBCreate a MemoryTree for branch, using the last-revision of branch.)�
_mod_revisionZensure_null�
last_revisionr)rrrrr�create_on_branchZszMemoryTree.create_on_branchcCsdS)z�See MutableTree._gather_kinds.

        This implementation does not care about the file kind of
        missing files, so is a no-op.
        Nr)rr-r.rrr�
_gather_kinds`szMemoryTree._gather_kindscCs|j�|�S)zSee Tree.get_file.)r%�get�r�pathrrr�get_filegszMemoryTree.get_fileNcCs|j�|�}t|�S)zSee Tree.get_file_sha1().)r%r7r	)rr9Z
stat_value�streamrrr�
get_file_sha1kszMemoryTree.get_file_sha1cCs|durdS|j|jdfS)zSee Tree._comparison_data.N)NFN)r!�
executable)r�entryr9rrr�_comparison_datapszMemoryTree._comparison_datacCsn|���R|�|�}tj�|�\}}|�|�}|j�||�|j�|||�Wd�n1s`0YdSr)	r#�path2id�osr9�splitr%Zmover,�rename)rZfrom_relZto_relr"Zto_dirZto_tailZto_parent_idrrr�
rename_onevs


zMemoryTree.rename_onecCs�|�|�}|durdS|�||�}|dkrZ|j�|�}t|�}|j|j}d}||||fS|dkrn|dddfS|dkr�|dd|j|jfStd��dS)zSee Tree.path_content_summary.N)ZmissingNNNrr rzunknown kind)	r@r!r%Z	get_bytes�lenr,r=�symlink_target�NotImplementedError)rr9�idr!�bytes�sizer=Zsha1rrr�path_content_summary~s
zMemoryTree.path_content_summarycCs6|���t|j�Wd�S1s(0YdS)z�See Tree.get_parent_ids.

        This implementation returns the current cached value from
            self._parent_ids.
        N)�	lock_read�list�_parent_idsrrrr�get_parent_ids�s
zMemoryTree.get_parent_idscCs|j�|�S)zSee Tree.has_filename().)r%Zhasrrrr�has_filename�szMemoryTree.has_filenamecCs|j�|�jSr)r,�get_entry_by_pathr=r8rrr�
is_executable�szMemoryTree.is_executablecCs|j�|�jSr)r,rQr!r8rrrr!�szMemoryTree.kindcCs0|�||d�|dur |�|�}|j�|�|S)zSee MutableTree.mkdir().r N)�addr@r%�mkdir)rr9r"rrrrT�s

zMemoryTree.mkdircCs2|���|jWd�S1s$0YdS)zSee MutableTree.last_revision.N)rLr
rrrrr4�s
zMemoryTree.last_revisioncCsf|jd7_z0|jdkr2|j��d|_|��t�|j�WSty`|jd8_�Yn0dS)zvLock the memory tree for reading.

        This triggers population of data from the branch for its revision.
        r�rN)	rrrLr�_populate_from_branchr�LogicalLockResult�unlock�
BaseExceptionrrrrrL�s

zMemoryTree.lock_readcCsz|jd7_z<|jdkr4|j��d|_|��n|jdkrHt�|��Wn"tyl|jd8_�Yn0t�	|j
�S)z"See MutableTree.lock_tree_write().r�wrU)rrrLrrVr�
ReadOnlyErrorrYrrWrXrrrrr#�s



zMemoryTree.lock_tree_writecCs||jd7_zF|jdkr4|j��d|_|��n|jdkrHt�|��t�|j	�WSt
yv|jd8_�Yn0dS)zSee MutableTree.lock_write().rrZrUN)rr�
lock_writerrVrr[rrWrXrYrrrrr\�s




zMemoryTree.lock_writecCs�|��|jtjkrg|_n
|jg|_td|j���|_t	�|_
|j��}|D]�\}}|j�|�
��|dkrpqN|jdkr�|j
�|�qN|jdkr�|j
�|j|�qN|jdkr�|j
�||j�|��qNt|j��qNdS)z+Populate the in-tree state from the branch.N�r rr)�
_set_basisr
r3�
NULL_REVISIONrNrr1Zget_revision_idr,r
r%Ziter_entries_by_dirrS�copyr!rTrrFZput_filer:rGrV)rZinventory_entriesr9r>rrrrV�s(




�z MemoryTree._populate_from_branchcCs|j�||�dS)z*See MutableTree.put_file_bytes_non_atomic.N)r%Z	put_bytes)rr9rIrrr�put_file_bytes_non_atomic�sz$MemoryTree.put_file_bytes_non_atomiccCsZ|jdkrHd|_g|_d|_z|j��Wd|_d|_qVd|_d|_0n|jd8_dS)zvRelease a lock.

        This frees all cached state when the last lock context for the tree is
        left.
        rNr)rr1rNr,rrXrrrrrrX�s
�
zMemoryTree.unlockcCs�|���ht�}|D]*}|�|�}|dur4t�|��|�|�q|D]}|j�|�rD|j�|�qDWd�n1sv0YdS)aRemove the paths from the current versioned set.

        When a file_id is unversioned, all of its children are automatically
        unversioned.

        :param paths: The paths to stop versioning.
        :raises: NoSuchId if any fileid is not currently versioned.
        N)	r#�setr@rZ
NoSuchFilerSr,Zhas_idZremove_recursive_id)r�pathsZfile_idsr9r"rrr�	unversions	


zMemoryTree.unversionFcCsR|D]}t�|�qt|�dkr0g|_tj|_n||_|d|_||_|��dS)�#See MutableTree.set_parent_trees().rN)r3Zcheck_not_reserved_idrErNr_r
�_allow_leftmost_as_ghostr^)rZrevision_ids�allow_leftmost_as_ghostrrrr�set_parent_ids&s

zMemoryTree.set_parent_idscCsLz|jj�|j�|_Wn0tjyF|jr@|jj�tj	�|_n�Yn0dSr)
r�
repository�
revision_treer
r1rZNoSuchRevisionrfr3r_rrrrr^3s�
�zMemoryTree._set_basiscCs8|���|j�|�Wd�S1s*0YdSr)rLr%�readlinkr8rrr�get_symlink_target>s
zMemoryTree.get_symlink_targetcCs�t|�dkr&g|_|jj�tj�|_n�|dddurL|sLt�	|dd��dd�|D�|_|dddus||dddkr�|jj�tj�|_n|dd|_|dd|_
dS)rerrNcSsg|]\}}|�qSrr)�.0Z	parent_idZtreerrr�
<listcomp>L�z/MemoryTree.set_parent_trees.<locals>.<listcomp>snull:)rErNrrirjr3r_r1rZGhostRevisionUnusableHerer
)rZparents_listrgrrr�set_parent_treesBs� �zMemoryTree.set_parent_trees)N)N)F)F)$�__name__�
__module__�__qualname__�__doc__rrrrrr0r2�staticmethodr5r6r:r<r?rDrKrOrPrRr!rTr4rLr#r\rVrarXrdrhr^rlrprrrrr&sB

	


r)rtZ
__future__rrAr&r]rrrr3Z
bzr.inventoryrZbzr.inventorytreerZosutilsr	Ztransport.memoryr
rrrrr�<module>s