File: //kunden/lib/python3/dist-packages/breezy/__pycache__/rename_map.cpython-39.pyc
a
�*�^v* � @ s` d dl mZ ddlmZmZmZ ddlmZ ddlm Z m
Z
mZ ddlm
Z
G dd� de�Zd S )
� )�absolute_import� )�osutils�progress�trace)�gettext)�BytesIO� viewitems�
viewvalues)�
ui_factoryc @ s� e Zd ZdZdd� Zedd� �Zdd� Zdd � Zd
d� Z dd
� Z
dd� Zedd� �Zdd� Z
dd� Zdd� Zeddd��Zdd� ZdS )� RenameMapzDetermine a mapping of renames.c C s || _ i | _d S �N)�tree�edge_hashes)�selfr � r �3/usr/lib/python3/dist-packages/breezy/rename_map.py�__init__% s zRenameMap.__init__c c s8 d}t t| ��D ]"}tt| ||d � ��| V qdS )a8 Iterate through the hashes of line pairs (which make up an edge).
The hash is truncated using a modulus to avoid excessive memory
consumption by the hitscount dict. A modulus of 10Mi means that the
maximum number of keys is 10Mi. (Keys are normally 32 bits, e.g.
4 Gi)
i � � N)�range�len�hash�tuple)�lines�modulus�nr r r �iter_edge_hashes) s zRenameMap.iter_edge_hashesc C s* | � |�D ]}| j�|t� ��|� q
dS )z�Update edge_hashes to include the given lines.
:param lines: The lines to update the hashes for.
:param tag: A tag uniquely associated with these lines (i.e. file-id)
N)r r �
setdefault�set�add)r r �tag�my_hashr r r �add_edge_hashes6 s zRenameMap.add_edge_hashesc s� � fdd�|D �}t �� �l}t� �|��D ]L\}\}}|�td�|t|�� t� }|�|� |� d� | �
|�� |� q*W d � n1 s�0 Y dS )z�Update to reflect the hashes for files in the tree.
:param tree: The tree containing the files.
:param file_ids: A list of file_ids to perform the updates for.
c s g | ]}� � |�|f�qS r )�id2path)�.0�f�r r r �
<listcomp>E � z2RenameMap.add_file_edge_hashes.<locals>.<listcomp>zCalculating hashesr N)r �nested_progress_bar� enumerateZiter_files_bytes�updater r r �
writelines�seekr"