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

�*�^��@sXdZddlmZddlZddlZddlZddlZddlmZee�d�ddl	m
Z
ddlmZm
Z
mZmZmZdd	l	mZdd
lmZddl	mZddlmZmZdd
lmZmZGdd�de
j�ZGdd�de
j�ZGdd�deje�ZGdd�de
�Z e �Z!Gdd�de�Z"e!�#ddd�e!�#ddd�e!�#ddd�e!�#dd d!�e!�$d�dS)"arWorkingTree object and friends.

A WorkingTree represents the editable working copy of a branch.
Operations which represent the WorkingTree are also done here,
such as renaming or adding files.

At the moment every WorkingTree has its own branch.  Remote
WorkingTrees aren't supported.

To get a WorkingTree, call controldir.open_workingtree() or
WorkingTree.open(dir).
�)�absolute_importN�)�lazy_importa
import shutil
import stat

from breezy import (
    cleanup,
    conflicts as _mod_conflicts,
    filters as _mod_filters,
    merge,
    revision as _mod_revision,
    transform,
    transport,
    views,
    )
from breezy.bzr import (
    generate_ids,
    )
)�errors)�ControlComponent�ControlComponentFormatRegistry�ControlComponentFormat�
ControlDir�ControlDirFormat)�osutils)�gettext)�mutabletree)�deprecated_method�
deprecated_in)�mutter�notec@seZdZdZdS)�SettingFileIdUnsupportedz.This format does not support setting file ids.N��__name__�
__module__�__qualname__Z_fmt�rr�4/usr/lib/python3/dist-packages/breezy/workingtree.pyrMsrc@seZdZdZdS)�ShelvingUnsupportedz.This format does not support shelving changes.NrrrrrrRsrcs�eZdZdZdd�Zd�dd�Zed	d
��Zedd��Zd
d�Z	dd�Z
edd�dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zed�d)d*��Zed�d+d,��Zed�d.d/��Zd�d0d1�Zed�d2d3��Zd4d5�Zd6d7�Zd8d9�Zd:d;�Zd<d=�Z d�d>d?�Z!d-e"j#fd@dA�Z$d�dBdC�Z%d�dDdE�Z&dFdG�Z'd�dHdI�Z(d�dJdK�Z)dLdM�Z*dNdO�Z+d�dPdQ�Z,d�dRdS�Z-dTdU�Z.e/j0e"j1fdVdW�Z2dXdY�Z3dZd[�Z4d\d]�Z5d^d_�Z6d�d`da�Z7dbdc�Z8ddde�Z9dfdg�Z:d�dhdi�Z;djdk�Z<d�dldm�Z=dndo�Z>dpdq�Z?drds�Z@d�dtdu�ZAdvdw�ZBdxdy�ZCd�dzd{�ZDd�d|d}�ZEd~d�ZFd�d��ZGd�d��ZHd�d�d��ZId�d��ZJd�d��ZKd�d��ZLd�d��ZMd�d��ZNd�d��ZOd�d��ZPd�d��ZQd�d��ZRd�d��ZSd�d��ZTd�d��ZUd�d��ZVd�d��ZWd�d��ZXd�d�d��ZYd�d�d��ZZd�d��Z[d�d��Z\d�d��Z]d�d��Z^d�d��Z_d�d��Z`ea�Zbdddebdfd�d��Zcd�d�d��Zdd�d��Zed�d��Zfd�d��Zgd�d�d��Zheiejd���d�dÄ�Zkd�dńZld�dDŽZmd�d�dɄZn�fd�d˄Zod�d̈́Zpd�dτZqd�dфZrd�d�dӄZsd�d�dՄZtd�dׄZu�ZvS)��WorkingTreez�Working copy tree.

    :ivar basedir: The root of the tree on disk. This is a unicode path object
        (as opposed to a URL).
    cCs
t�|�S�N)�viewsZ
DisabledViews��selfrrr�_make_views_szWorkingTree._make_views�.NFcCsp||_||_|st�d��t�|�}td|�|dur>||_n|j��|_t�	|�|_
||_d|_|�
�|_dS)z�Construct a WorkingTree instance. This is not a public API.

        :param branch: A branch to override probing for the branch.
        zUPlease use controldir.open_workingtree or WorkingTree.open() to obtain a WorkingTree.zopening working tree %rN)�_format�
controldirr�BzrErrorrZsafe_unicoder�_branchZopen_branch�realpath�basedir�
_transport�_rules_searcherrr)rr&�branchZ	_internalr'r!Z_controldirrrr�__init__bs



zWorkingTree.__init__cCs|jjSr)r"�user_transportrrrrr+|szWorkingTree.user_transportcCs|jSr)r'rrrr�control_transport�szWorkingTree.control_transportcCst�|j�Sr)r�supports_symlinksr&rrrrr-�szWorkingTree.supports_symlinkscCs|j�|�S)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.
        )r"�is_control_filename�r�filenamerrrr.�s
zWorkingTree.is_control_filenamecCs|jSr)r$rrrr�<lambda>��zWorkingTree.<lambda>z�The branch this WorkingTree is connected to.

            This cannot be set - it is reflective of the actual disk structure
            the working tree has been constructed from.
            )�fget�doccCs|jjS)z%See `Tree.has_versioned_directories`.)r!�supports_versioned_directoriesrrrr�has_versioned_directories�sz%WorkingTree.has_versioned_directoriescCs|jjS)zKIndicate whether this workingtree supports storing merge_modified.
        )r!�supports_merge_modifiedrrrrr7�sz#WorkingTree.supports_merge_modifiedcCst�|j�Sr)rZsupports_executabler&rrrr�_supports_executable�sz WorkingTree._supports_executablecCst|j��dS)z�Break a lock if one is present from another instance.

        Uses the ui factory to ask for confirmation if the lock may be from
        an active process.

        This will probe the repository for its lock as well.
        N)�NotImplementedError�
break_lockrrrrr:�szWorkingTree.break_lockcCs|jjSr)r!�requires_rich_rootrrrrr;�szWorkingTree.requires_rich_rootcCsdS)NFrrrrr�supports_tree_reference�sz#WorkingTree.supports_tree_referencecCs
|j��Sr)r!�supports_content_filteringrrrrr=�sz&WorkingTree.supports_content_filteringcCs
|j��Sr)r�supports_viewsrrrrr>�szWorkingTree.supports_viewscCs|jjSr)r!�supports_setting_file_idsrrrrr?�sz%WorkingTree.supports_setting_file_idscCs
|j��S)z]Retrieve the config stack for this tree.

        :return: A ``breezy.config.Stack``
        )r)�get_config_stackrrrrr@�szWorkingTree.get_config_stackcCs*|durt��}tj||d�}|j|d�S)z0Open an existing working tree at path.

        N��_unsupported)Zunsupported)r�getcwdr	�open�open_workingtree)�pathrB�controlrrrrD�szWorkingTree.opencCs*|durt��}t�|�\}}|��|fS)a�Open an existing working tree which has its root about path.

        This probes for a working tree at path and searches upwards from there.

        Basically we keep looking up until we find the control directory or
        run into /.  If there isn't one, raises NotBranchError.
        TODO: give this a new exception.
        If there is one, it is returned, along with the unused portion of path.

        :return: The WorkingTree that contains 'path', and the rest of path
        N)rrCr	�open_containingrE)rFrG�relpathrrrrH�s
zWorkingTree.open_containingTcs��durd�|dus t|�dkrnt���d}|��rf|rf|j��}|rf|}t�|�}ttd�|�||fS�dkr�|d}n�}�fdd�|D�}t�|�d}||j	|||d�fS)aOpen the WorkingTree that contains a set of paths.

        Fail if the paths given are not all in a single tree.

        This is used for the many command-line interfaces that take a list of
        any number of files and that require they all be in the same tree.
        Nr rz'Ignoring files outside view. View is %scsg|]}t��|��qSr)r�pathjoin)�.0�f��default_directoryrr�
<listcomp>s�z5WorkingTree.open_containing_paths.<locals>.<listcomp>)�
apply_view)
�lenrrHr>r�lookup_viewZview_display_strrr�safe_relpath_files)�	file_listrN�canonicalizerP�tree�
view_filesZview_strZseedrrMr�open_containing_paths�s*




�
�z!WorkingTree.open_containing_pathsc	s�|durdS���r$|r$�j��}ng}g}|r>�fdd�}n�j}|D]8}|t�|��}|rvt�||�svt�||��|�|�qH|S)a�Convert file_list into a list of relpaths in tree.

        :param self: A tree to operate on.
        :param file_list: A list of user provided paths or None.
        :param apply_view: if True and a view is set, apply it or check that
            specified files are within it
        :return: A list of relative paths.
        :raises errors.PathNotChild: When a provided path is in a different self
            than self.
        Ncst��j|�Sr)rZcanonical_relpathr&)�prrr�fixersz-WorkingTree.safe_relpath_files.<locals>.fixer)	r>rrRrIrZdereference_pathZ
is_inside_anyZFileOutsideView�append)	rrTrUrPrWZnew_listrZr0rIrrrrSszWorkingTree.safe_relpath_filescCstj|dd�S)z~Open an unsupported working tree.

        Only intended for advanced situations like upgrading part of a controldir.
        TrA)rrD)rFrrr�open_downlevel'szWorkingTree.open_downlevelcCsd|jjt|dd�fS)Nz
<%s of %s>r&)�	__class__r�getattrrrrr�__repr__/s
�zWorkingTree.__repr__cCst�|j|�Sr)rrJr&r/rrr�abspath3szWorkingTree.abspathc	Cs�z|��d}Wn"ty2|jj�tj�YS0z|�|�WStjyTYn0z|jj�|�WStj	tjfy�|jj�
|�r��|jj�tj�YS0dS)z�Return RevisionTree for the current last revision.

        If the left most parent is a ghost then the returned tree will be an
        empty tree - one obtained by calling
        repository.revision_tree(NULL_REVISION).
        rN)�get_parent_ids�
IndexErrorr)�
repository�
revision_tree�
_mod_revision�
NULL_REVISIONr�NoSuchRevisionZRevisionNotPresent�has_revision�r�revision_idrrr�
basis_tree6s$�
�zWorkingTree.basis_treecCst�|j|�S)z�Return the local path portion from a given path.

        The path may be absolute or relative. If its a relative path it is
        interpreted relative to the python current working directory.
        )rrIr&�rrFrrrrIXszWorkingTree.relpathcCst�|�|��Sr)r�lexistsr`r/rrr�has_filename`szWorkingTree.has_filenamecCs|j||d�dS)N��filteredr)�get_file_with_stat)rrFrprrr�get_filecszWorkingTree.get_filec

Cs�|�|�}zt|d�}Wn<tyT}z$|jtjkr>t�|���WYd}~n
d}~00||���}|r�|��r�|�	|�}|r�t
�||�\}}	t
j||	d�}||fS)zSee Tree.get_file_with_stat.�rbN)�st_size)
r`rD�EnvironmentError�errno�ENOENTr�
NoSuchFile�filenor=Z_content_filter_stackZ_mod_filtersZfiltered_input_fileZFilteredStat)
rrFrpZ_fstatr`Zfile_obj�e�
stat_value�filters�sizerrrrqfs$


��zWorkingTree.get_file_with_statcCs:|j||d��}|��Wd�S1s,0YdS)Nro)rr�read)rrFrpZmy_filerrr�
get_file_textzszWorkingTree.get_file_textcCs:|j||d��}|��Wd�S1s,0YdS)zSee Tree.get_file_lines()roN)rr�	readlines)rrFrp�filerrr�get_file_lines~szWorkingTree.get_file_linescCsrt�|���}tj|krg}n|g}z|j�d�}WntjyHYn&0t�	|�D]}|�
d�}|�|�qT|S)z�See Tree.get_parent_ids.

        This implementation reads the pending merges list and last_revision
        value and uses that to decide what the parents list should be.
        �pending-merges�
)re�ensure_null�_last_revisionrfr'Z	get_bytesrrxrZsplit_lines�rstripr[)r�last_rev�parentsZmerges_bytes�lrjrrrra�s

zWorkingTree.get_parent_idscCsD|���(|��}|�||�|Wd�S1s60YdS)a�Duplicate this working tree into to_bzr, including all state.

        Specifically modified files are kept as modified, but
        ignored and unknown files are discarded.

        If you want to make a new line of development, see ControlDir.sprout()

        revision
            If not None, the cloned tree will have its last revision set to
            revision, and difference between the source trees last revision
            and this one merged in.
        N)�	lock_readZcreate_workingtree�copy_content_into)rZ
to_controldirrj�resultrrr�clone�s
zWorkingTree.clonec	Cs�|����|�|�d��|dur0t�||�n^z|�|�}Wn"tjy`|jj	�|�}Yn0t�||�|t
jkr~g}n|g}|�|�Wd�n1s�0YdS)z?Copy the current content and user files of this tree into tree.�N)
r��set_root_id�path2id�mergeZtransform_treerdrrgr)rcrerf�set_parent_ids)rrVrj�
other_tree�new_parentsrrrr��s
�

zWorkingTree.copy_content_intoc
Cs\ztj�|�|��WStyV}z*|jtjkr4�nWYd}~dSWYd}~n
d}~00dS)zSee Tree.get_file_sizeN)�osrF�getsizer`�OSErrorrvrw)rrFrzrrr�
get_file_size�szWorkingTree.get_file_sizecCs�|����t|�D]r\}}||durt�|�|��}zt�|�||<Wqty�}z"|jtjkrnt	�
|��WYd}~qd}~00qWd�n1s�0YdS)zSee MutableTree._gather_kinds.N)�lock_tree_write�	enumerater�normpathr`�	file_kindr�rvrwrrx)r�filesZkinds�posrL�fullpathrzrrr�
_gather_kinds�s
zWorkingTree._gather_kindscCsT|���8|��|g}|j|t|�dkp,|d�Wd�n1sF0YdS)a�Add revision_id as a parent.

        This is equivalent to retrieving the current list of parent ids
        and setting the list to its value plus revision_id.

        :param revision_id: The revision id to add to the parent list. It may
            be a ghost revision as long as its not the first parent to be
            added, or the allow_leftmost_as_ghost parameter is set True.
        :param allow_leftmost_as_ghost: Allow the first parent to be a ghost.
        r��allow_leftmost_as_ghostN)�
lock_writerar�rQ)rrjr�r�rrr�add_parent_tree_id�s

�zWorkingTree.add_parent_tree_idcCs\|���@|��|dg}t|�dkr,d}|j||d�Wd�n1sN0YdS)acAdd revision_id, tree tuple as a parent.

        This is equivalent to retrieving the current list of parent trees
        and setting the list to its value plus parent_tuple. See also
        add_parent_tree_id - if you only have a parent id available it will be
        simpler to use that api. If you have the parent already available, using
        this api is preferred.

        :param parent_tuple: The (revision id, tree) to add to the parent list.
            If the revision_id is a ghost, pass None for the tree.
        :param allow_leftmost_as_ghost: Allow the first parent to be a ghost.
        rrTr�N)r�rarQr�)rZparent_tupler��
parent_idsrrr�add_parent_tree�s
�zWorkingTree.add_parent_treecGsl|���P|��}d}|D]}||vr(q|�|�d}q|rJ|j|dd�Wd�n1s^0YdS)NFTr�)r�rar[r�)r�revision_idsr��updatedZrev_idrrr�add_pending_merge�s

zWorkingTree.add_pending_mergec	
Cs�|�|�}z||�}WnFty\}z.t|dd�tjkrFWYd}~dS�WYd}~n
d}~00||j�}|dkr||�||�S|dkr�|�|�r�d}|dddfS|dkr�t�	|�}ddd|fS|dddfSdS)zSee Tree.path_content_summary.rvN)ZmissingNNNr��	directoryztree-reference�symlink)
r`r�r^rvrw�st_mode�_file_content_summary�_directory_is_tree_referencer�readlink)	rrFZ_lstatZ_mapperr`�stat_resultrz�kind�targetrrr�path_content_summary
s$



z WorkingTree.path_content_summarycCs&|j}|�||�}d|||�||�fS)Nr�)rtZ!_is_executable_from_path_and_stat�_sha_from_stat)rrFr�r}�
executablerrrr�(s

�z!WorkingTree._file_content_summarycCs4t|�dkr0|d}|s0|jj�|�s0t�|��dS)z�Common ghost checking functionality from set_parent_*.

        This checks that the left hand-parent exists if there are any
        revisions present.
        rN)rQr)rcrhrZGhostRevisionUnusableHere)rr�r�Zleftmost_idrrr�_check_parents_for_ghosts/s�z%WorkingTree._check_parents_for_ghostscCs.|dd�}|jjdd�|�|j��d�dS)Nrr�r�)�mode)r'Z	put_bytes�joinr"Z_get_file_mode)rr��mergesrrr�_set_merges_from_parent_ids;s�z'WorkingTree._set_merges_from_parent_idscCsvt|�dkr|S|jj��}|�|�}|dd�}|dd�D]}||vr>||vr>|�|�q>||krrtd||�|S)z�Check that all merged revisions are proper 'heads'.

        This will always return the first revision_id, and any merged revisions
        which are
        rNrz6requested to set revision_ids = %s, but filtered to %s)rQr)rc�	get_graph�headsr[r)rr��graphr�Znew_revision_idsrjrrr�_filter_parent_ids_by_ancestry@s
�z*WorkingTree._filter_parent_ids_by_ancestrycCs�|���n|j||d�|D]}t�|�q|�|�}t|�dkrR|�|d�n|�tj�|�|�Wd�n1s|0YdS)aSet the parent ids to revision_ids.

        See also set_parent_trees. This api will try to retrieve the tree data
        for each element of revision_ids from the trees repository. If you have
        tree data already available, it is more efficient to use
        set_parent_trees rather than set_parent_ids. set_parent_ids is however
        an easier API to use.

        :param revision_ids: The revision_ids to set as the parent ids of this
            working tree. Any of these may be ghosts.
        r�rN)	r�r�re�check_not_reserved_idr�rQ�set_last_revisionrfr�)rr�r�rjrrrr�Ss
�
zWorkingTree.set_parent_idscCsR|���6|��}|dd�}||}|�|�Wd�n1sD0YdS)Nr)r�rar�)rZrev_listr�Zleftmostr�rrr�set_pending_mergesns

zWorkingTree.set_pending_mergescCst|j��dS)zSet the merge modified hashes.N)r9�set_merge_modified)rZmodified_hashesrrrr�uszWorkingTree.set_merge_modifiedcCsdS)z�Get a sha digest from the tree's stat cache.

        The default implementation assumes no stat cache is present.

        :param path: The path.
        :param stat_result: The stat result being looked up.
        Nr)rrFr�rrrr�yszWorkingTree._sha_from_statc
Cs>ddlm}m}|����||j|d�}|s@|��r@t�|��|durVt�	|�
��}||_t�|j�rrt�
|��|jj||jd�|j|_|jj�|j�|_||_|dur�|��n|�||�|j|jkr�tj�d|_|dur�||_n||_|�d�d|_d|_|��}	|��|	Wd�S1�s00YdS)avMerge from a branch into this working tree.

        :param branch: The branch to merge from.
        :param to_revision: If non-None, the merge will merge to to_revision,
            but not beyond it. to_revision does not need to be in the history
            of the branch when it is supplied. If None, to_revision defaults to
            branch.last_revision().
        r)�Merger�Merge3Merger)�	this_treeN)�
stop_revisionF)r�r�r�r�r)Zhas_changesrZUncommittedChangesrer��
last_revisionZother_rev_id�is_nullZ	NoCommitsZfetchZother_basisrcrdr�Zother_branchZ	find_baseZset_base_revision�base_rev_idZPointlessMergeZbackup_files�
merge_typeZset_interesting_files�	show_baseZ	reprocessZdo_mergeZset_pending)
rr)Zto_revisionZ
from_revisionr��forcer�r�Zmerger�	conflictsrrr�merge_from_branch�s>


�

zWorkingTree.merge_from_branchcCst|j��dS)avReturn a dictionary of files modified by a merge.

        The list is initialized by WorkingTree.set_merge_modified, which is
        typically called after we make some automatic updates to the tree
        because of a merge.

        This returns a map of file_id->sha1, containing only files which are
        still in the working tree and have that text hash.
        N)r9�merge_modifiedrrrrr��s
zWorkingTree.merge_modifiedcCs�|dur$|��r2t�tj�|��}n|��s2t��|���2t�|�	|��|�
||d�|Wd�S1sr0YdS)zSee MutableTree.mkdir().Nr�)r?Zgenerate_idsZgen_file_idr�rF�basenamerr��mkdirr`�add)rrF�file_idrrrr��s
zWorkingTree.mkdircCs|�|�}t�|�}|Sr)r`rr�)rrFr`r�rrr�get_symlink_target�s

zWorkingTree.get_symlink_targetcCst|j��dSr)r9�subsume)rr�rrrr��szWorkingTree.subsumecCst|j��dSr)r9r��rrIrrrr��sz(WorkingTree._directory_is_tree_referencecCst|j��dS)zuExtract a subtree from this tree.

        A new branch will be created, relative to the path for this tree.
        N)r9�extract)rrF�formatrrrr��szWorkingTree.extractcCst|j��dS)z&Write the in memory meta data to disk.N)r9�flushrrrrr��szWorkingTree.flushcCst�|�|��Sr)rr�r`r�rrrr��szWorkingTree.kindcCst|j��dS)a�List all files as (path, class, kind, id, entry).

        Lists, but does not descend into unversioned directories.
        This does not include files that have been deleted in this
        tree. Skips the control directory.

        :param include_root: if True, return an entry for the root
        :param from_dir: start from this directory or None for the root
        :param recursive: whether to recurse into subdirectories or not
        N)r9�
list_files)rZinclude_rootZfrom_dir�	recursiveZrecurse_nestedrrrr��szWorkingTree.list_filescCst|j��dS)a�Rename files.

        to_dir must be known to the working tree.

        If to_dir exists and is a directory, the files are moved into
        it, keeping their old names.

        Note that to_dir is only the last component of the new name;
        this doesn't change the directory.

        For each entry in from_paths the move mode will be determined
        independently.

        The first mode moves the file in the filesystem and updates the
        working tree metadata. The second mode only updates the working tree
        metadata without touching the file on the filesystem.

        move uses the second mode if 'after == True' and the target is not
        versioned but present in the working tree.

        move uses the second mode if 'after == False' and the source is
        versioned but no longer in the working tree, and the target is not
        versioned but present in the working tree.

        move uses the first mode if 'after == False' and the source is
        versioned and present in the working tree, and the target is not
        versioned and not present in the working tree.

        Everything else results in an error.

        This returns a list of (from_path, to_path) pairs for each
        entry that is moved.
        N)r9�move)rZ
from_pathsZto_dirZafterrrrr��s"zWorkingTree.movecCs&t�|�|�|�|��|�|�dS)aCopy a file in the tree to a new location.

        This default implementation just copies the file, then
        adds the target.

        :param from_rel: From location (relative to tree root)
        :param to_rel: Target location (relative to tree root)
        N)ZshutilZcopyfiler`r�)rZfrom_relZto_relrrr�copy_ones	zWorkingTree.copy_onecsF����*t�fdd����D��Wd�S1s80YdS)z�Return all unknown files.

        These are files in the working directory that are not versioned or
        control files or ignored.
        csg|]}��|�s|�qSr)�
is_ignored)rK�subprrrrO)r2z(WorkingTree.unknowns.<locals>.<listcomp>N)r��iter�extrasrrrr�unknownss
�zWorkingTree.unknownscCst|j��dS)aRemove the path in pahs from the current versioned set.

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

        :param paths: The paths to stop versioning.
        :raises NoSuchFile: if any path is not currently versioned.
        N)r9�	unversion)r�pathsrrrr�+s	zWorkingTree.unversionc	s�|�����|����b|j��}	|��}
|jj||||||d�}|j��}||	k�rX|jj��jjr�|�	�}
|
r�|
d}��
|�}
|
���`|j��}tj|j||
|||d�|
�
d�}|�
d�}|dur�||kr�|�|�Wd�n1s�0Yg}|j��tjk�r&|�|j��|f�|�	�dd�}|��fdd�|D��|�|�|Wd�Wd�S1�s�0YWd�n1�s�0YdS)N)�possible_transports�local�tag_selectorr�r��change_reporterr�r�rcsg|]}|��|�f�qSr)rd)rK�parent�rcrrrOas�z$WorkingTree.pull.<locals>.<listcomp>)r�r�r)Zlast_revision_infork�pullrcr!Zfast_deltasrardr��merge_innerr�r�r�rerfr[�extend�set_parent_trees)r�sourceZ	overwriter�r�r�r�r�r�Zold_revision_infork�countZnew_revision_infor�Zbasis_idZnew_basis_treeZ
basis_root_idZnew_root_id�parent_treesr�rr�rr�6sP
�




�

(��
zWorkingTree.pullc	Csf|���Jt|�|�d��}|�|�Wd�n1s:0YWd�n1sX0YdS)z*See MutableTree.put_file_bytes_non_atomic.�wbN)r�rDr`�write)rrF�bytes�streamrrr�put_file_bytes_non_atomicgsz%WorkingTree.put_file_bytes_non_atomiccCst|j��dS)a�Yield all unversioned files in this WorkingTree.

        If there are any unversioned directories and the file format
        supports versioning directories, then only the directory is returned,
        not all its children. But if there are unversioned files under a
        versioned subdirectory, they are returned.

        Currently returned depth-first, sorted by name within directories.
        This is the same order used by 'osutils.walkdirs'.
        N)r9r�rrrrr�lszWorkingTree.extrasccs.|��D] }|�|�}|dur||fVqdS)z"Yield list of PATH, IGNORE_PATTERNN)r�r�)rr�Zpatrrr�
ignored_filesys
zWorkingTree.ignored_filescCst|j��dS)z>Check whether the filename matches an ignore pattern.
        N)r9r�r/rrrr��szWorkingTree.is_ignoredcCst|j��dS)zSee Tree.stored_kindN)r9�stored_kindrlrrrr��szWorkingTree.stored_kindc	
Cs�|�|�}zt�|�}WnFty^}z.t|dd�tjkrHd}d}d}n�WYd}~nJd}~00|j}t�	|�}|�
�s�|duo�|j}ntt
�|�o�t
j|@�}|||fS)NrvF)r`r��lstatr�r^rvrwr�r�file_kind_from_stat_moder8r��bool�stat�S_ISREG�S_IEXEC)	r�entryrFr`r{rzr�r�r�rrr�_comparison_data�s

zWorkingTree._comparison_datacCs|��S)z�Return the last revision of the branch for this tree.

        This format tree does not support a separate marker for last-revision
        compared to the branch.

        See MutableTree.last_revision
        )r�rrrrr��szWorkingTree.last_revisioncCs<|��� t�|j���Wd�S1s.0YdS)zhelper for get_parent_ids.N)r�rer�r)r�rrrrr��s
zWorkingTree._last_revisioncCst|j��dS)zCheck if this tree is locked.N)r9�	is_lockedrrrrr�szWorkingTree.is_lockedcCst|j��dS)z�Lock the tree for reading.

        This also locks the branch, and can be unlocked via self.unlock().

        :return: A breezy.lock.LogicalLockResult.
        N)r9r�rrrrr��szWorkingTree.lock_readcCst|j��dS)ztSee MutableTree.lock_tree_write, and WorkingTree.unlock.

        :return: A breezy.lock.LogicalLockResult.
        N)r9r�rrrrr��szWorkingTree.lock_tree_writecCst|j��dS)zoSee MutableTree.lock_write, and WorkingTree.unlock.

        :return: A breezy.lock.LogicalLockResult.
        N)r9r�rrrrr��szWorkingTree.lock_writecCst|j��dSr)r9�get_physical_lock_statusrrrrr�sz$WorkingTree.get_physical_lock_statuscCst|j��dS)z-Change the last revision in the working tree.N)r9r��rZnew_revisionrrrr��szWorkingTree.set_last_revisioncCs^t�|�r|j�d|�dSt�|�z|j�|�Wn"tjyX|j�|g�Yn0dS)z�Template method part of set_last_revision to perform the change.

        This is used to allow WorkingTree3 instances to not affect branch
        when their last revision is set.
        rFT)	rer�r)Zset_last_revision_infor�Zgenerate_revision_historyrrgZ_set_revision_historyrrrr�_change_last_revision�s

z!WorkingTree._change_last_revisioncCst|j��dS)a-Remove nominated files from the working tree metadata.

        :files: File paths relative to the basedir.
        :keep_files: If true, the files will also be kept.
        :force: Delete files and directories, even if they are changed and
            even if the directories are not empty.
        N)r9�remove)rr��verboseZto_fileZ
keep_filesr�rrrr�s	zWorkingTree.removec	Csddlm}t����}|�|���|durH|��}|�|���|}nd}t�	||||||�}	|dur�t
|���dkr�g}
|��}|t
jkr�|dur�|��}|�|���|
�||f�|�|
�||�n|||ddd�|	Wd�S1�s�0YdS)Nr)�resolveT)Z
ignore_missesr�)r�r	�cleanup�	ExitStack�
enter_contextr�rkr�Z	transform�revertrQrar�rerfr[r�)r�	filenamesZold_treeZbackupsZpbZreport_changesr	Z
exit_stackrkr�r�r�rrrr
�s.
�


zWorkingTree.revertcCst|j��dS)z6Store uncommitted changes from the tree in the branch.N)r9�store_uncommittedrrrrrszWorkingTree.store_uncommittedcCst|j��dS)z:Restore uncommitted changes from the branch into the tree.N)r9�restore_uncommittedrrrrr	szWorkingTree.restore_uncommittedcCst|j��dS)z�See Tree.revision_tree.

        For trees that can be obtained from the working tree, this
        will do so. For other trees, it will fall back to the repository.
        N)r9rdrirrrrd
szWorkingTree.revision_treecCs^|��st��|���4|dur(td��t�|�}|�|�Wd�n1sP0YdS)zSet the root id for this tree.Nz(WorkingTree.set_root_id with fileid=None)r?rr��
ValueErrorrZsafe_file_id�_set_root_id�rr�rrrr�s
�
zWorkingTree.set_root_idcCst|j��dS)aSet the root id for this tree, in a format specific manner.

        :param file_id: The file id to assign to the root. It must not be
            present in the current inventory or an error will occur. It must
            not be None, but rather a valid file id.
        N)r9rrrrrr!szWorkingTree._set_root_idcCst|j��dS)a�See Branch.unlock.

        WorkingTree locking just uses the Branch locking facilities.
        This is current because all working trees have an embedded branch
        within them. IF in the future, we were to make branch data shareable
        between multiple working trees, i.e. via shared storage, then we
        would probably want to lock both the local tree, and the branch.
        N)r9�unlockrrrrr*s	zWorkingTree.unlockcCsx|j��dur"|��||ju}n|��d}z:|rB|j�|�}n||jurPd}|�||||�W|��S|��0dS)a�Update a working tree along its branch.

        This will update the branch if its bound too, which means we have
        multiple trees involved:

        - The new basis tree of the master.
        - The old basis tree of the branch.
        - The old basis tree of the working tree.
        - The current working tree state.

        Pathologically, all three may be different, and non-ancestors of each
        other.  Conceptually we want to:

        - Preserve the wt.basis->wt.state changes
        - Transform the wt.basis to the new master basis.
        - Apply a merge of the old branch basis to get any 'local' changes from
          it into the tree.
        - Restore the wt.basis->wt.state changes.

        There isn't a single operation at the moment to do that, so we:

        - Merge current state -> basis tree of the master w.r.t. the old tree
          basis.
        - Do a 'normal' merge of the old branch basis if it is relevant.

        :param revision: The target revision to update to. Must be in the
            revision history.
        :param old_tip: If branch.update() has already been run, the value it
            returned (old tip of the branch or None). _marker is used
            otherwise.
        NF)r)Zget_bound_locationr��_markerr��update�_update_treer)rr�r��revision�old_tipr�Z
update_branchrrrr7s!
�zWorkingTree.updatec	Cs@|���� d}z|��d}Wnty8tj}Yn0|durL|j��}|pTtj}t�|�s�||kr�|��}|jj	�
|�}tj|j|||||d�}|r�|�
||f�ttd��|Wd�S|t�|�k�r|jj	�
|�}	|	�d�}
|��}|���B|�d�du�s |�d�|
k�r2|�|
�|��Wd�n1�sH0Y|jj	��}|�|j��|�}
|jj	�
|
�}tj|j|	||||d�}|�|�||	fg}|��dd�}|D]}|�||jj	�
|�f��q�t�|��s|�||jj	�
|�f�|�|�|dd}|Wd�S1�s20YdS)z�Update a tree to the master branch.

        :param old_tip: if supplied, the previous tip revision the branch,
            before it was changed to the master branch's tip.
        rNr�z(Rerun update after fixing the conflicts.r�r)r�rarbrerfr)r�r�rkrcrdr�r�r�rrr�r�r�r�r�r�Zfind_unique_lcar�r[r�)rrr�rr�Znb_conflictsr�Z	base_treer�Zto_treeZ
to_root_idZbasisr�r�r�r�r�rrrrhsj


�

 
(��

��
zWorkingTree._update_treecCst�|j|��dSr)r�UnsupportedOperation�
set_conflicts�r�argrrrr�szWorkingTree.set_conflictscCst�|j|��dSr)rr�
add_conflictsrrrrr�szWorkingTree.add_conflictscCst|j��dSr)r9r�rrrrr��szWorkingTree.conflictsr�cCst|j��dS)aWalk the directories of this tree.

        returns a generator which yields items in the form:
                ((curren_directory_path, fileid),
                 [(file1_path, file1_name, file1_kind, (lstat), file1_id,
                   file1_kind), ... ])

        This API returns a generator, which is only valid during the current
        tree transaction - within a single lock_read or lock_write duration.

        If the tree is not locked, it may cause an error to be raised,
        depending on the tree implementation.
        N)r9�walkdirs)r�prefixrrrr�szWorkingTree.walkdirs)�rrc
Cs�|����t��}t��}|��D]D}z|�|�WntyP|�|�Yq"0|�|�|�|�q"|�|�||fWd�S1s�0YdS)a�Automatically resolve text conflicts according to contents.

        Only text conflicts are auto_resolvable. Files with no conflict markers
        are considered 'resolved', because bzr always puts conflict markers
        into files that have text conflicts.  The corresponding .THIS .BASE and
        .OTHER files are deleted, as per 'resolve'.

        :return: a tuple of ConflictLists: (un_resolved, resolved).
        N)	r�Z_mod_conflictsZConflictListr�Zaction_autor9r[r
r)rZun_resolvedZresolvedZconflictrrr�auto_resolve�s


zWorkingTree.auto_resolvecCsdS)a(Validate internal structures.

        This is meant mostly for the test suite. To give it a chance to detect
        corruption after actions have occurred. The default implementation is a
        just a no-op.

        :return: None. An exception should be raised if there is an error.
        Nrrrrr�	_validate�s	zWorkingTree._validatecCst|j��dS)z,Check that the working state is/isn't valid.N)r9�check_staterrrrr$�szWorkingTree.check_statecCst|j��dS)z�Reset the state of the working tree.

        This does a hard-reset to a last-known-good state. This is a way to
        fix if something got corrupted (like the .bzr/checkout/dirstate file)
        N)r9�reset_state)rr�rrrr%�szWorkingTree.reset_statecs"|jdurtt|��|�|_|jS)zSee Tree._get_rules_searcher.N)r(�superr�_get_rules_searcher)rZdefault_searcher�r]rrr's
��zWorkingTree._get_rules_searchercCst|j��dS)z-Return the ShelfManager for this WorkingTree.N)r9�get_shelf_managerrrrrr)szWorkingTree.get_shelf_managerccs<|��� |D]
}|VqWd�n1s.0YdS)a;Like get_canonical_path() but works on multiple items.

        :param paths: A sequence of paths relative to the root of the tree.
        :return: A list of paths, with each item the corresponding input path
            adjusted to account for existing elements that match case
            insensitively.
        N)r�)rr�rFrrr�get_canonical_pathss
zWorkingTree.get_canonical_pathscCs<|��� t|�|g��Wd�S1s.0YdS)a_Returns the first item in the tree that matches a path.

        This is meant to allow case-insensitive path lookups on e.g.
        FAT filesystems.

        If a path matches exactly, it is returned. If no path matches exactly
        but more than one path matches according to the underlying file system,
        it is implementation defined which is returned.

        If no path matches according to the file system, the input path is
        returned, but with as many path entries that do exist changed to their
        canonical form.

        If you need to resolve many names from the same tree, you should
        use get_canonical_paths() to avoid O(N) behaviour.

        :param path: A paths relative to the root of the tree.
        :return: The input path adjusted to account for existing elements
        that match case insensitively.
        N)r��nextr*rlrrr�get_canonical_paths
zWorkingTree.get_canonical_pathcCst�|j|��dSr)rr�reference_parent)rrFr)r�rrrr-4szWorkingTree.reference_parentcCst�|j|��dSr)rr�get_reference_info)rrFr)rrrr.7szWorkingTree.get_reference_infocCst�|j|��dSr)rr�set_reference_info)rZ	tree_pathZbranch_locationrrrr/:szWorkingTree.set_reference_info)r NFNNN)NF)N)NTT)TT)N)T)T)T)N)N)F)F)F)NNNF)N)N)FNTF)NF)FNNNFFN)FNTF)NNTNF)NNNF)r�)N)NN)N)wrrr�__doc__rr*�propertyr+r,r-r.r)r6r7r8r:r;r<r=r>r?r@�staticmethodrDrHrXrSr\r_r`rkrIrnrrr�fstatrqrr�rar�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�rr�r�r�rr�rrr
rrrdr�rr�objectrrrrrr�rrrr"r#r$r%r'r)r*r,r-r.r/�
__classcell__rrr(rrWs�


�
	�"
 "
�






�


�
,


�

$�
1

	�
�
	�
1�
T





rcs:eZdZdZd�fdd�	Zdd�Zdd�Zd	d
�Z�ZS)�WorkingTreeFormatRegistryz"Registry for working tree formats.Ncs tt|��|�d|_d|_dSr)r&r6r*�_default_format�_default_format_key)rZother_registryr(rrr*Asz"WorkingTreeFormatRegistry.__init__cCs(|jdur"|jdur"|�|j�|_|jS)z"Return the current default format.N)r8r7�getrrrr�get_defaultFs

�z%WorkingTreeFormatRegistry.get_defaultcCs||_d|_dS)zSet the default format.N)r7r8)rr�rrr�set_defaultMsz%WorkingTreeFormatRegistry.set_defaultcCs||_d|_dS)z,Set the default format by its format string.N)r8r7)r�
format_stringrrr�set_default_keyRsz)WorkingTreeFormatRegistry.set_default_key)N)	rrrr0r*r:r;r=r5rrr(rr6>s
r6c@s�eZdZdZdZdZdZdZdZdZ	dZ
dZdZdZ
dZdZddd�Zdd	�Zd
d�Zdd
�Zdd�Zdd�Zdd�Zdd�ZdS)�WorkingTreeFormata�An encapsulation of the initialization and open routines for a format.

    Formats provide three things:
     * An initialization routine,
     * a format string,
     * an open routine.

    Formats are placed in an dict by their format string for reference
    during workingtree opening. Its not required that these be instances, they
    can be classes themselves with class methods - it simply depends on
    whether state is needed for a given format or not.

    Once a format is deprecated, just deprecate the initialize and open
    methods on the format class. Do not deprecate the object, as the
    object will be created every time regardless.
    FZFoRMaTNTcCst|j��dS)a�Initialize a new working tree in controldir.

        :param controldir: ControlDir to initialize the working tree in.
        :param revision_id: allows creating a working tree at a different
            revision than the branch is at.
        :param from_branch: Branch to checkout
        :param accelerator_tree: A tree which can be used for retrieving file
            contents more quickly than the revision tree, i.e. a workingtree.
            The revision tree will be used for cases where accelerator_tree's
            content is different.
        :param hardlink: If true, hard-link files from accelerator_tree,
            where possible.
        N)r9�
initialize)rr"rjZfrom_branchZaccelerator_treeZhardlinkrrrr?�szWorkingTreeFormat.initializecCs|j|juSrr(�r�otherrrr�__eq__�szWorkingTreeFormat.__eq__cCs
||kSrrr@rrr�__ne__�szWorkingTreeFormat.__ne__cCst|j��dS)z-Return the short description for this format.N)r9�get_format_descriptionrrrrrD�sz(WorkingTreeFormat.get_format_descriptioncCsdS)z�Is this format supported?

        Supported formats can be initialized and opened.
        Unsupported formats may not support initialization or committing or
        some other features depending on the reason for not being supported.
        Trrrrr�is_supported�szWorkingTreeFormat.is_supportedcCsdS)z/True if this format supports content filtering.Frrrrrr=�sz,WorkingTreeFormat.supports_content_filteringcCsdS)z*True if this format supports stored views.Frrrrrr>�sz WorkingTreeFormat.supports_viewscCs|jS)z�Get the control directory format for creating branches.

        This is to support testing of working tree formats that can not exist
        in the same control directory as a branch.
        )Z_matchingcontroldirrrrr�get_controldir_for_branch�sz+WorkingTreeFormat.get_controldir_for_branch)NNNF)rrrr0r;Zupgrade_recommendedZ%requires_normalized_unicode_filenamesZcase_sensitive_filenameZmissing_parent_conflictsr5r7r?Zsupports_store_uncommittedZ$supports_leftmost_parent_id_as_ghostZ%supports_righthand_parent_id_as_ghostZignore_filenamer?rBrCrDrEr=r>rFrrrrr>[s.�
	r>s(Bazaar Working Tree Format 4 (bzr 0.15)
zbreezy.bzr.workingtree_4ZWorkingTreeFormat4s(Bazaar Working Tree Format 5 (bzr 1.11)
ZWorkingTreeFormat5s(Bazaar Working Tree Format 6 (bzr 1.14)
ZWorkingTreeFormat6sBazaar-NG Working Tree format 3zbreezy.bzr.workingtree_3ZWorkingTreeFormat3)%r0Z
__future__rrvr��sysZbreezyr�globalsr�rr"rrrr	r
rZi18nrr
Zsymbol_versioningrrZtracerrr#rrZMutableTreerr6Zformat_registryr>Z
register_lazyr=rrrr�<module>sT
pd����