File: //kunden/lib/python3/dist-packages/breezy/__pycache__/multiwalker.cpython-39.pyc
a
�*�^�. � @ sD d Z ddlmZ ddlmZmZ ddlmZmZ G dd� de �Z
dS ) z$Walk multiple trees simultaneously.
� )�absolute_import� )�errors�osutils)� text_type�
viewvaluesc @ sl e Zd ZdZdd� Zedd� �Zedd� �Zedd � �Zd
d� Z dd
� Z
dd� Zdd� Zdd� Z
dd� ZdS )�MultiWalkerz=Walk multiple trees simultaneously, getting combined results.c C s || _ || _t� | _dS )aC Create a new MultiWalker.
All trees being walked must implement "iter_entries_by_dir()", such
that they yield (path, object) tuples, where that object will have a
'.file_id' member, that can be used to check equality.
:param master_tree: All trees will be 'slaved' to the master_tree such
that nodes in master_tree will be used as 'first-pass' sync points.
Any nodes that aren't in master_tree will be merged in a second
pass.
:param other_trees: A list of other trees to walk simultaneously.
N)�_master_tree�_other_trees�set�_out_of_order_processed)�selfZmaster_treeZother_trees� r �4/usr/lib/python3/dist-packages/breezy/multiwalker.py�__init__* s
zMultiWalker.__init__c C s4 zt | �\}}W n ty$ Y dS 0 d||fS dS )z�Step an iter_entries_by_dir iterator.
:return: (has_more, path, ie)
If has_more is False, path and ie will be None.
�FNNTN)�next�
StopIteration)�iterator�pathZier r r � _step_one? s
zMultiWalker._step_onec C s\ | |krdS t | t�s*tdt| �| f ��t |t�sHtdt|�|f ��t�| �t�|�k S )a� Compare two paths based on what directory they are in.
This generates a sort order, such that all children of a directory are
sorted together, and grandchildren are in the same order as the
children appear. But all grandchildren come after all children.
:param path1: first path
:param path2: the second path
:return: negative number if ``path1`` comes first,
0 if paths are equal
and a positive number if ``path2`` sorts first
Fz,'path1' must be a unicode string, not %s: %rz,'path2' must be a unicode string, not %s: %r)�
isinstancer � TypeError�typer �_path_to_key)Zpath1Zpath2r r r �_lt_path_by_dirblockM s
�
��z MultiWalker._lt_path_by_dirblockc C s t �| �\}}|�d�|fS )N�/)r �split)r �dirname�basenamer r r r j s zMultiWalker._path_to_keyc C s | � ||| j�|��S )N)�_lookup_by_file_idr Zpath2id)r
�
extra_entries�
other_treeZmaster_pathr r r �_lookup_by_master_patho s
�z"MultiWalker._lookup_by_master_pathc C st ||v r|� |�S z|�|�}W n tjy8 d}Y n0 |du rFdS | j�|� t|j|gd��d }||fS dS )a Lookup an inventory entry by file_id.
This is called when an entry is missing in the normal order.
Generally this is because a file was either renamed, or it was
deleted/added. If the entry was found in the inventory and not in
extra_entries, it will be added to self._out_of_order_processed
:param extra_entries: A dictionary of {file_id: (path, ie)}. This
should be filled with entries that were found before they were
used. If file_id is present, it will be removed from the
dictionary.
:param other_tree: The Tree to search, in case we didn't find the entry
yet.
:param file_id: The file_id to look for
:return: (path, ie) if found or (None, None) if not present.
N�NN)Zspecific_filesr )�popZid2pathr ZNoSuchIdr �addr �iter_entries_by_dir)r
r! r"