File: //kunden/lib/python3/dist-packages/breezy/__pycache__/mutabletree.cpython-39.pyc
a
�*�^�J � @ s� d Z ddlmZ ddlmZmZmZmZmZ ddl m
Z
G dd� dej�ZG dd � d ej
�ZG d
d� dej�Ze� e_G dd
� d
e�ZdS )z7MutableTree object.
See MutableTree for more details.
� )�absolute_import� )�errors�hooks�osutils�trace�tree)� text_typec @ s e Zd ZdZdd� ZdS )�BadReferenceTargetz>Can't add reference to %(other_tree)s into %(tree)s.%(reason)sc C s || _ || _|| _d S )N)r �
other_tree�reason)�selfr r r � r �4/usr/lib/python3/dist-packages/breezy/mutabletree.py�__init__* s zBadReferenceTarget.__init__N)�__name__�
__module__�__qualname__Z_fmtr r r r r r
% s r
c s� e Zd ZdZ� fdd�Zdd� Zd/dd�Zd d
� Zdd� Zd0d
d�Z dd� Z
d1dd�Zdd� Zdd� Z
dd� Zdd� Zd2dd�Zdd� Zdd � Zd3d"d#�Zd4d$d%�Zd5d'd(�Zd6d)d*�Zd+d,� Zd7d-d.�Z� ZS )8�MutableTreea3 A 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.
c s t t| �j|i |�� d| _d S )NT)�superr r Zcase_sensitive)r
�args�kw�� __class__r r r C s zMutableTree.__init__c C s t | 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
�filenamer r r r J s
zMutableTree.is_control_filenameNc C s@ t |ttf�rd|du s&t |t�s&t� �|du sBt |ttf�sBt� �|g}|durV|g}|durd|g}dd� |D �}|du r�dgt|� }nt|�t|�ks�t� �|du r�dgt|� }nt|�t|�ks�t� �| �� �T |D ]$}| �|�r�tj |d��t
�|�}q�| �||� | �
|||� W d � n1 �s20 Y dS )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.
Nc S s g | ]}|� d ��qS )�/)�strip)�.0�pathr r r �
<listcomp>u � z#MutableTree.add.<locals>.<listcomp>)r )�
isinstance�strr �bytes�AssertionError�len�lock_tree_writer r ZForbiddenControlFileErrorr Z splitpath�
_gather_kinds�_add)r
�files�ids�kinds�f�fpr r r �addV s4
zMutableTree.addc C s t �| 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_treer r r r2 � s zMutableTree.add_referencec C s t | 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)r r* )r
r+ r, r- r r r r* � s zMutableTree._addc
O s� ddl m} g }| �� �� |j�|| j|�dd �|�dd�|�}|f| }tj d D ]}|| � qT|�� j|| ||d�|��}t
| �} tj d D ]}|| � q�|W d � S 1 s�0 Y d S ) Nr )�commitZauthorsZlocalF�start_commit)Zworking_tree�revprops�possible_master_transports�post_commit)Zbreezyr3 �
lock_writeZCommitZupdate_revprops�branch�pop�getr r �PostCommitHookParams)
r
�messager5 r �kwargsr3 r6 �hookZcommitted_idZpost_hook_paramsr r r r3 � s2
�
���
zMutableTree.commitc C s t | j��dS )z4Helper function for add - sets the entries of kinds.N)r r) )r
r+ r- r r r r) � s zMutableTree._gather_kindsc C s | � � �� t| �� �dkr*W d � dS |du r:| �� }| �|�}| �� r�z,t|�}|jdkrht|�}W W d � dS ty� Y W d � dS 0 nPt dd� |�}ztt
|�� W n ty� Y W d � dS 0 W d � dS W d � n1 �s0 Y dS )a Quickly 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
r NT�NNFc S s | d d dko| d dkS )N� r �symlink� r@ r )�cr r r �<lambda>� r"