§
    cÌcA;  ã                   óä   — d Z ddlmZmZmZ ddlmZmZmZm	Z	m
Z
  G d„ dej        ¦  «        Z G d„ de
j        ¦  «        Z G d	„ d
ej        ¦  «        Z e¦   «         e_         G d„ d¦  «        ZdS )z7MutableTree object.

See MutableTree for more details.
é    )ÚOptionalÚUnionÚListé   )ÚerrorsÚhooksÚosutilsÚtraceÚtreec                   ó   — e Zd ZdZd„ ZdS )ÚBadReferenceTargetz>Can't add reference to %(other_tree)s into %(tree)s.%(reason)sc                 ó0   — || _         || _        || _        d S ©N)r   Ú
other_treeÚreason)Úselfr   r   r   s       ú4/usr/lib/python3/dist-packages/breezy/mutabletree.pyÚ__init__zBadReferenceTarget.__init__(   s   € ØˆŒ	Ø$ˆŒØˆŒˆˆó    N)Ú__name__Ú
__module__Ú__qualname__Ú_fmtr   © r   r   r   r   #   s*   € € € € € ð€Dðð ð ð ð r   r   c            	       óì   ‡ — e Zd ZdZˆ fd„Zd„ Zddeeee         f         de	eeee         f                  fd„Z
d„ Zdd	„Zdd
„Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zd„ Zdd„Zdd„Zdd„Zdd„Zd„ Zdd„Zˆ xZS )Ú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                 óH   •—  t          ¦   «         j        |i |¤Ž d| _        d S )NT)Úsuperr   Úcase_sensitive)r   ÚargsÚkwÚ	__class__s      €r   r   zMutableTree.__init__A   s/   ø€ Ø�‰ŒÔ˜$Ð% "Ð%Ð%Ð%ð #ˆÔÐÐr   c                 ó*   — t          | j        ¦  «        ‚)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.
        )ÚNotImplementedErrorÚis_control_filename)r   Úfilenames     r   r%   zMutableTree.is_control_filenameH   s   € õ " $Ô":Ñ;Ô;Ð;r   NÚfilesÚkindsc                 ó*   — t          | j        ¦  «        ‚)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.

        Args:
          files: List of paths to add, relative to the base of the tree.
          kinds: Optional parameter to specify the kinds to be used for
            each file.
        )r$   Úadd)r   r'   r(   s      r   r*   zMutableTree.addT   s   € õ " $¤(Ñ+Ô+Ð+r   c                 ó6   — t          j        | j        | ¦  «        ‚)ziAdd a TreeReference to the tree, pointing at sub_tree.

        :param sub_tree: subtree to add.
        )r   ÚUnsupportedOperationÚadd_reference)r   Úsub_trees     r   r-   zMutableTree.add_referenced   s   € õ
 Ô)¨$Ô*<¸dÑCÔCÐCr   c           
      óø  — ddl m} g }|                      ¦   «         5  |j                             || j        |                     dd ¦  «        |                     dd¦  «        |¦  «        }|f|z   }t          j	        d         D ]} || ¦  «         Œ |                     ¦   «         j        || ||dœ|¤Ž}t          | ¦  «        }	t          j	        d         D ]} ||	¦  «         Œ|cd d d ¦  «         S # 1 swxY w Y   d S )	Nr   )ÚcommitÚauthorsÚlocalFÚstart_commit)Úworking_treeÚrevpropsÚpossible_master_transportsÚpost_commit)Úbreezyr0   Ú
lock_writeÚCommitÚupdate_revpropsÚbranchÚpopÚgetr   r   ÚPostCommitHookParams)
r   Úmessager5   r    Úkwargsr0   r6   ÚhookÚcommitted_idÚpost_hook_paramss
             r   r0   zMutableTree.commitk   s†  € à!Ð!Ð!Ð!Ð!Ð!Ø%'Ð"Ø�_Š_ÑÔð 	 ð 	 Ø”}×4Ò4ØØ”Ø—
’
˜9 dÑ+Ô+Ø—
’
˜7 EÑ*Ô*Ø*ñ,ô ,ˆHð �; Ñ%ˆDÝ#Ô)¨.Ô9ð ð �Ø��T‘
”
�
�
Ø1˜6Ÿ=š=™?œ?Ô1ð 48ð @DØ;CØMgðCð Cð <BðCð CˆLõ  4°DÑ9Ô9ÐÝ#Ô)¨-Ô8ð 'ð '�Ø�Ð%Ñ&Ô&Ð&Ð&Øð%	 ð 	 ð 	 ð 	 ñ 	 ô 	 ð 	 ð 	 ð 	 ð 	 ð 	 ð 	 øøøð 	 ð 	 ð 	 ð 	 ð 	 ð 	 s   �CC/Ã/C3Ã6C3c                 ó*   — t          | j        ¦  «        ‚)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$   Úhas_changes)r   Ú
_from_trees     r   rF   zMutableTree.has_changesƒ   s   € õ " $Ô"2Ñ3Ô3Ð3r   c                 ó  — |                       ¦   «         5  |€,| j                             ¦   «                              |¦  «        }|dur¦d}|                      ¦   «         rt
          j        }n;|                      ¦   «         | j                             ¦   «         k    rt
          j        }|�F|€5 || |¬¦  «        }t          j
        d|                     ¦   «         ¦  «         n || |¬¦  «        }|‚ddd¦  «         dS # 1 swxY w Y   dS )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)Úmorez%s)Ú	lock_readr<   Úget_config_stackr>   rF   r   ÚUncommittedChangesÚlast_revisionÚOutOfDateTreer
   ÚwarningÚ_format)r   ÚstrictÚopt_nameÚ
more_errorÚmore_warningÚ	err_classÚerrs          r   Úcheck_changed_or_out_of_datez(MutableTree.check_changed_or_out_of_date�   sR  € ð  �^Š^ÑÔð 	"ð 	"Øˆ~Øœ×5Ò5Ñ7Ô7×;Ò;¸HÑEÔE�Ø˜UÐ"Ð"Ø �	Ø×#Ò#Ñ%Ô%ð 5Ý &Ô 9�I�IØ×'Ò'Ñ)Ô)¨T¬[×-FÒ-FÑ-HÔ-HÒHÐHõ !'Ô 4�IØÐ(Ø�~Ø'˜i¨°<Ð@Ñ@Ô@˜õ œ d¨C¯KªK©M¬MÑ:Ô:Ð:Ð:à'˜i¨°:Ð>Ñ>Ô>˜Ø!˜	ð)	"ð 	"ð 	"ñ 	"ô 	"ð 	"ð 	"ð 	"ð 	"ð 	"ð 	"ð 	"øøøð 	"ð 	"ð 	"ð 	"ð 	"ð 	"s   •CC;Ã;C?ÄC?c                 ó*   — t          | j        ¦  «        ‚)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.
        )r$   rM   ©r   s    r   rM   zMutableTree.last_revision³   s   € õ " $Ô"4Ñ5Ô5Ð5r   c                 ó*   — t          | j        ¦  «        ‚)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.
        )r$   Úlock_tree_writerY   s    r   r[   zMutableTree.lock_tree_writeÂ   s   € õ " $Ô"6Ñ7Ô7Ð7r   c                 ó*   — t          | j        ¦  «        ‚)a   Lock 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.
        )r$   r9   rY   s    r   r9   zMutableTree.lock_writeÍ   s   € õ " $¤/Ñ2Ô2Ð2r   c                 ó*   — t          | j        ¦  «        ‚)z†Create a directory in the tree.

        :param path: A unicode file path.
        :return: the file id of the new directory.
        )r$   Úmkdir)r   Úpaths     r   r^   zMutableTree.mkdirÖ   s   € õ " $¤*Ñ-Ô-Ð-r   c                 ó   — dS )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_   Úsha_and_stats      r   Ú_observed_sha1zMutableTree._observed_sha1Þ   s   € € € r   c                 ó*   — t          | j        ¦  «        ‚)aI  Update 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 path: path of the file
        :param bytes: the new file contents
        )r$   Úput_file_bytes_non_atomic)r   r_   Úbytess      r   rd   z%MutableTree.put_file_bytes_non_atomicí   s   € õ " $Ô"@ÑAÔAÐAr   Fc                 ó*   — t          | j        ¦  «        ‚)zgSet the parents ids of the working tree.

        :param revision_ids: A list of revision_ids.
        )r$   Úset_parent_ids)r   Úrevision_idsÚallow_leftmost_as_ghosts      r   rg   zMutableTree.set_parent_idsù   s   € õ
 " $Ô"5Ñ6Ô6Ð6r   c                 ó*   — t          | j        ¦  «        ‚)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.
        )r$   Úset_parent_trees)r   Úparents_listri   s      r   rk   zMutableTree.set_parent_trees   s   € õ " $Ô"7Ñ8Ô8Ð8r   Tc                 ó*   — t          | j        ¦  «        ‚)a  Version 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.
        )r$   Ú	smart_add)r   Ú	file_listÚrecurseÚactionÚsaves        r   rn   zMutableTree.smart_add	  s   € õ( " $¤.Ñ1Ô1Ð1r   c                 ó*   — t          | j        ¦  «        ‚)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.
        )r$   Ú
rename_one)r   Úfrom_relÚto_relÚafters       r   rt   zMutableTree.rename_one  s   € õ, " $¤/Ñ2Ô2Ð2r   c                 ó*   — t          | j        ¦  «        ‚)zeCopy one file or directory.

        This can change the directory or the filename or both.

        )r$   Úcopy_one)r   ru   rv   s      r   ry   zMutableTree.copy_one7  s   € õ " $¤-Ñ0Ô0Ð0r   c                 ó*   — t          | j        ¦  «        ‚)z1Return a transform object for use with this tree.)r$   Ú	transform)r   Úpbs     r   r{   zMutableTree.transform?  s   € å! $¤.Ñ1Ô1Ð1r   r   )NN)F)TNT)r   r   r   Ú__doc__r   r%   r   Ústrr   r   r*   r-   r0   rF   rW   rM   r[   r9   r^   rb   rd   rg   rk   rn   rt   ry   r{   Ú__classcell__)r"   s   @r   r   r   .   s²  ø€ € € € € ðð ð$#ð #ð #ð #ð #ð
<ð 
<ð 
<ð,ð ,˜˜s D¨¤I˜~Ô.ð ,°xÀÀcÈ4ÐPSÌ9ÀnÔ@UÔ7Vð ,ð ,ð ,ð ,ð Dð Dð Dð ð  ð  ð  ð04ð 4ð 4ð 4ð$"ð $"ð $"ðL6ð 6ð 6ð	8ð 	8ð 	8ð3ð 3ð 3ð.ð .ð .ðð ð ð
Bð 
Bð 
Bð7ð 7ð 7ð 7ð9ð 9ð 9ð 9ð2ð 2ð 2ð 2ð,3ð 3ð 3ð 3ð01ð 1ð 1ð2ð 2ð 2ð 2ð 2ð 2ð 2ð 2r   r   c                   ó   — e Zd ZdZd„ ZdS )ÚMutableTreeHookszWA dictionary mapping a hook name to a list of callables for mutabletree
    hooks.
    c                 ó.  — t           j                             | dd¦  «         |                      ddd¦  «         |                      ddd¦  «         |                      d	d
d¦  «         |                      ddd¦  «         |                      ddd¦  «         dS )z#Create the default hooks.

        zbreezy.mutabletreezMutableTree.hooksr3   zä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.)r   é   r7   zà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.)é   r   Úpre_transformzzCalled before a tree transform on this tree. The hook is called with the tree that is being transformed and the transform.)r„   é   Úpost_build_treezcCalled after a completely new tree is built. The hook is called with the tree as its only argument.Úpost_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   ÚHooksr   Úadd_hookrY   s    r   r   zMutableTreeHooks.__init__I  sê   € õ 	Œ×Ò˜TÐ#7Ð9LÑMÔMÐMØ�Š�nð?ð AGñ		Hô 	Hð 	Hð
 	�Š�mðCð EKñ		Lô 	Lð 	Lð
 	�Š�oðSàñ	ô 	ð 	ð 	�ŠÐ'ðCØDJñ	Lô 	Lð 	Lð 	�ŠÐ&ð'ð ñ		ô 	ð 	ð 	ð 	r   N©r   r   r   r}   r   r   r   r   r�   r�   D  s-   € € € € € ðð ðð ð ð ð r   r�   c                   ó   — e Zd ZdZd„ ZdS )r?   z“Parameters for the post_commit hook.

    To access the parameters, use the following attributes:

    * mutable_tree - the MutableTree object
    c                 ó   — || _         dS )z/Create the parameters for the post_commit hook.N)Úmutable_tree)r   rŽ   s     r   r   zPostCommitHookParams.__init__r  s   € à(ˆÔÐÐr   Nr‹   r   r   r   r?   r?   j  s-   € € € € € ðð ð)ð )ð )ð )ð )r   r?   N)r}   Útypingr   r   r   Ú r   r   r	   r
   r   ÚInternalBzrErrorr   ÚTreer   r‰   r�   r?   r   r   r   ú<module>r“      sI  ðð"ð ð
 )Ð (Ð (Ð (Ð (Ð (Ð (Ð (Ð (Ð (ðð ð ð ð ð ð ð ð ð ð ð ð ð ðð ð ð ð ˜Ô0ñ ô ð ðS2ð S2ð S2ð S2ð S2�$”)ñ S2ô S2ð S2ðlð ð ð ð �u”{ñ ô ð ðF %Ð$Ñ&Ô&€Ô ð
)ð 
)ð 
)ð 
)ð 
)ñ 
)ô 
)ð 
)ð 
)ð 
)r   