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__/mutabletree.cpython-39.pyc
a

�*�^�J�@s�dZddlmZddlmZmZmZmZmZddl	m
Z
Gdd�dej�ZGdd	�d	ej
�ZGd
d�dej�Ze�e_Gdd
�d
e�ZdS)z7MutableTree object.

See MutableTree for more details.
�)�absolute_import�)�errors�hooks�osutils�trace�tree)�	text_typec@seZdZdZdd�ZdS)�BadReferenceTargetz>Can't add reference to %(other_tree)s into %(tree)s.%(reason)scCs||_||_||_dS)N)r�
other_tree�reason)�selfrrr�r�4/usr/lib/python3/dist-packages/breezy/mutabletree.py�__init__*szBadReferenceTarget.__init__N)�__name__�
__module__�__qualname__Z_fmtrrrrrr
%sr
cs�eZdZdZ�fdd�Zdd�Zd/dd�Zd	d
�Zdd�Zd0d
d�Z	dd�Z
d1dd�Zdd�Zdd�Z
dd�Zdd�Zd2dd�Zdd�Zdd �Zd3d"d#�Zd4d$d%�Zd5d'd(�Zd6d)d*�Zd+d,�Zd7d-d.�Z�ZS)8�MutableTreea3A MutableTree is a specialisation of Tree which is able to be mutated.

    Generally speaking these mutations are only possible within a lock_write
    context, and will revert if the lock is broken abnormally - but this cannot
    be guaranteed - depending on the exact implementation of the mutable state.

    The most common form of Mutable Tree is WorkingTree, see breezy.workingtree.
    For tests we also have MemoryTree which is a MutableTree whose contents are
    entirely in memory.

    For now, we are not treating MutableTree as an interface to provide
    conformance tests for - rather we are testing MemoryTree specifically, and
    interface testing implementations of WorkingTree.

    A mutable tree always has an associated Branch and ControlDir object - the
    branch and bzrdir attributes.
    cs tt|�j|i|��d|_dS)NT)�superrrZcase_sensitive)r
�args�kw��	__class__rrrCszMutableTree.__init__cCst|j��dS)a�True if filename is the name of a control file in this tree.

        :param filename: A filename within the tree. This is a relative path
            from the root of this tree.

        This is true IF and ONLY IF the filename is part of the meta data
        that bzr controls in this tree. I.E. a random .bzr directory placed
        on disk will not be a control file for this tree.
        N)�NotImplementedError�is_control_filename)r
�filenamerrrrJs
zMutableTree.is_control_filenameNcCs@t|ttf�rd|dus&t|t�s&t��|dusBt|ttf�sBt��|g}|durV|g}|durd|g}dd�|D�}|dur�dgt|�}nt|�t|�ks�t��|dur�dgt|�}nt|�t|�ks�t��|���T|D]$}|�|�r�tj	|d��t
�|�}q�|�||�|�
|||�Wd�n1�s20YdS)a�Add paths to the set of versioned paths.

        Note that the command line normally calls smart_add instead,
        which can automatically recurse.

        This adds the files to the tree, so that they will be
        recorded by the next commit.

        :param files: List of paths to add, relative to the base of the tree.
        :param ids: If set, use these instead of automatically generated ids.
            Must be the same length as the list of files, but may
            contain None for ids that are to be autogenerated.
        :param kinds: Optional parameter to specify the kinds to be used for
            each file.

        TODO: Perhaps callback with the ids and paths as they're added.
        NcSsg|]}|�d��qS)�/)�strip)�.0�pathrrr�
<listcomp>u�z#MutableTree.add.<locals>.<listcomp>)r)�
isinstance�strr	�bytes�AssertionError�len�lock_tree_writerrZForbiddenControlFileErrorrZ	splitpath�
_gather_kinds�_add)r
�files�ids�kinds�f�fprrr�addVs4

zMutableTree.addcCst�|j|��dS)ziAdd a TreeReference to the tree, pointing at sub_tree.

        :param sub_tree: subtree to add.
        N)r�UnsupportedOperation�
add_reference)r
Zsub_treerrrr2�szMutableTree.add_referencecCst|j��dS)a;Helper function for add - updates the inventory.

        :param files: sequence of pathnames, relative to the tree root
        :param ids: sequence of suggested ids for the files (may be None)
        :param kinds: sequence of  inventory kinds of the files (i.e. may
            contain "tree-reference")
        N)rr*)r
r+r,r-rrrr*�szMutableTree._addc

Os�ddlm}g}|����|j�||j|�dd�|�dd�|�}|f|}tj	dD]}||�qT|��j||||d�|��}t
|�}	tj	dD]}||	�q�|Wd�S1s�0YdS)	Nr)�commitZauthorsZlocalF�start_commit)Zworking_tree�revprops�possible_master_transports�post_commit)Zbreezyr3�
lock_writeZCommitZupdate_revprops�branch�pop�getrr�PostCommitHookParams)
r
�messager5r�kwargsr3r6�hookZcommitted_idZpost_hook_paramsrrrr3�s2


�

���
zMutableTree.commitcCst|j��dS)z4Helper function for add - sets the entries of kinds.N)rr))r
r+r-rrrr)�szMutableTree._gather_kindsc	Cs|����t|���dkr*Wd�dS|dur:|��}|�|�}|��r�z,t|�}|jdkrht|�}WWd�dSty�YWd�dS0nPt	dd�|�}ztt
|��Wn ty�YWd�dS0Wd�dSWd�n1�s0YdS)aQuickly check that the tree contains at least one commitable change.

        :param _from_tree: tree to compare against to find changes (default to
            the basis tree and is intended to be used by tests).

        :return: True if a change is found. False otherwise
        rNT�NNFcSs|dddko|ddkS)N�r�symlink�r@r)�crrr�<lambda>�r"z)MutableTree.has_changes.<locals>.<lambda>)�	lock_readr'Zget_parent_idsZ
basis_treeZiter_changesZsupports_symlinks�nextZ	parent_id�
StopIteration�filter�iter)r
Z
_from_treeZchangesZchangerrr�has_changes�s.


�zMutableTree.has_changescCs�|����|dur"|j���|�}|dur�d}|��r>tj}n|��|j��krVtj}|dur�|dur�|||d�}t	�
d|���n|||d�}|�Wd�n1s�0YdS)a,Check the tree for uncommitted changes and branch synchronization.

        If strict is None and not set in the config files, a warning is issued.
        If strict is True, an error is raised.
        If strict is False, no checks are done and no warning is issued.

        :param strict: True, False or None, searched in branch config if None.

        :param opt_name: strict option name to search in config file.

        :param more_error: Details about how to avoid the check.

        :param more_warning: Details about what is happening.
        NF)Zmorez%s)rFr9Zget_config_stackr;rKrZUncommittedChanges�
last_revisionZ
OutOfDateTreerZwarningZ_format)r
�strictZopt_nameZ
more_errorZmore_warningZ	err_class�errrrr�check_changed_or_out_of_date�s
z(MutableTree.check_changed_or_out_of_datecCst|j��dS)a�Return the revision id of the last commit performed in this tree.

        In early tree formats the result of last_revision is the same as the
        branch last_revision, but that is no longer the case for modern tree
        formats.

        last_revision returns the left most parent id, or None if there are no
        parents.

        last_revision was deprecated as of 0.11. Please use get_parent_ids
        instead.
        N)rrL�r
rrrrLs
zMutableTree.last_revisioncCst|j��dS)a�Lock the working tree for write, and the branch for read.

        This is useful for operations which only need to mutate the working
        tree. Taking out branch write locks is a relatively expensive process
        and may fail if the branch is on read only media. So branch write locks
        should only be taken out when we are modifying branch data - such as in
        operations like commit, pull, uncommit and update.
        N)rr(rPrrrr(s	zMutableTree.lock_tree_writecCst|j��dS)aLock the tree and its branch. This allows mutating calls to be made.

        Some mutating methods will take out implicit write locks, but in
        general you should always obtain a write lock before calling mutating
        methods on a tree.
        N)rr8rPrrrr8&szMutableTree.lock_writecCst|j��dS)z�Create a directory in the tree. if file_id is None, one is assigned.

        :param path: A unicode file path.
        :param file_id: An optional file-id.
        :return: the file id of the new directory.
        N)r�mkdir)r
r Zfile_idrrrrQ/szMutableTree.mkdircCsdS)a�Tell the tree we have observed a paths sha1.

        The intent of this function is to allow trees that have a hashcache to
        update the hashcache during commit. If the observed file is too new
        (based on the stat_value) to be safely hash-cached the tree will ignore
        it.

        The default implementation does nothing.

        :param path: The file path
        :param sha_and_stat: The sha 1 and stat result observed.
        :return: None
        Nr)r
r Zsha_and_statrrr�_observed_sha18szMutableTree._observed_sha1cCst|j��dS)aOUpdate the content of a file in the tree.

        Note that the file is written in-place rather than being
        written to a temporary location and renamed. As a consequence,
        readers can potentially see the file half-written.

        :param file_id: file-id of the file
        :param bytes: the new file contents
        N)r�put_file_bytes_non_atomic)r
r r%rrrrSGs
z%MutableTree.put_file_bytes_non_atomicFcCst|j��dS)zgSet the parents ids of the working tree.

        :param revision_ids: A list of revision_ids.
        N)r�set_parent_ids)r
Zrevision_ids�allow_leftmost_as_ghostrrrrTSszMutableTree.set_parent_idscCst|j��dS)z�Set the parents of the working tree.

        :param parents_list: A list of (revision_id, tree) tuples.
            If tree is None, then that element is treated as an unreachable
            parent tree - i.e. a ghost.
        N)r�set_parent_trees)r
Zparents_listrUrrrrVZszMutableTree.set_parent_treesTcCst|j��dS)aVersion file_list, optionally recursing into directories.

        This is designed more towards DWIM for humans than API clarity.
        For the specific behaviour see the help for cmd_add().

        :param file_list: List of zero or more paths.  *NB: these are
            interpreted relative to the process cwd, not relative to the
            tree.*  (Add and most other tree methods use tree-relative
            paths.)
        :param action: A reporter to be called with the working tree, parent_ie,
            path and kind of the path being added. It may return a file_id if
            a specific one should be used.
        :param save: Save the changes after completing the adds. If False
            this provides dry-run functionality by doing the add and not saving
            the changes.
        :return: A tuple - files_added, ignored_files. files_added is the count
            of added files, and ignored_files is a dict mapping files that were
            ignored to the rule that caused them to be ignored.
        N)r�	smart_add)r
Z	file_listZrecurse�actionZsaverrrrWcszMutableTree.smart_addcCst|j��dS)a�Rename one file.

        This can change the directory or the filename or both.

        rename_one has several 'modes' to work. First, it can rename a physical
        file and change the file_id. That is the normal mode. Second, it can
        only change the file_id without touching any physical file.

        rename_one uses the second mode if 'after == True' and 'to_rel' is
        either not versioned or newly added, and present in the working tree.

        rename_one uses the second mode if 'after == False' and 'from_rel' is
        versioned but no longer in the working tree, and 'to_rel' is not
        versioned but present in the working tree.

        rename_one uses the first mode if 'after == False' and 'from_rel' is
        versioned and present in the working tree, and 'to_rel' is not
        versioned and not present in the working tree.

        Everything else results in an error.
        N)r�
rename_one)r
�from_rel�to_relZafterrrrrYyszMutableTree.rename_onecCst|j��dS)zeCopy one file or directory.

        This can change the directory or the filename or both.

        N)r�copy_one)r
rZr[rrrr\�szMutableTree.copy_onecCst|j��dS)z1Return a transform object for use with this tree.N)r�
get_transform)r
Zpbrrrr]�szMutableTree.get_transform)NN)NN)N)N)F)F)TNT)F)N)rrr�__doc__rrr0r2r*r3r)rKrOrLr(r8rQrRrSrTrVrWrYr\r]�
__classcell__rrrrr0s,
6


-&	
	

	

rc@seZdZdZdd�ZdS)�MutableTreeHookszWA dictionary mapping a hook name to a list of callables for mutabletree
    hooks.
    cCsZtj�|dd�|�ddd�|�ddd�|�d	d
d�|�dd
d�|�ddd�dS)z#Create the default hooks.

        zbreezy.mutabletreezMutableTree.hooksr4z�Called before a commit is performed on a tree. The start commit hook is able to change the tree before the commit takes place. start_commit is called with the breezy.mutabletree.MutableTree that the commit is being performed on.)rrCr7z�Called after a commit is performed on a tree. The hook is called with a breezy.mutabletree.PostCommitHookParams object. The mutable tree the commit was performed on is available via the mutable_tree attribute of that object.)�rZ
pre_transformzzCalled before a tree transform on this tree. The hook is called with the tree that is being transformed and the transform.)ra�Zpost_build_treezcCalled after a completely new tree is built. The hook is called with the tree as its only argument.Zpost_transformz�Called after a tree transform has been performed on a tree. The hook is called with the tree that is being transformed and the transform.N)r�HooksrZadd_hookrPrrrr�s*�����zMutableTreeHooks.__init__N�rrrr^rrrrrr`�sr`c@seZdZdZdd�ZdS)r<z�Parameters for the post_commit hook.

    To access the parameters, use the following attributes:

    * mutable_tree - the MutableTree object
    cCs
||_dS)z/Create the parameters for the post_commit hook.N)�mutable_tree)r
rerrrr�szPostCommitHookParams.__init__Nrdrrrrr<�sr<N)r^Z
__future__r�rrrrrZsixishr	ZInternalBzrErrorr
ZTreerrcr`�objectr<rrrr�<module>sp#