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

�*�^�I�
@sdZddlmZddlZddlZddlmZee�d�ddlmZm	Z	m
Z
ddlmZdd	l
mZmZd dd�Zd
d�Zdd�Zd!dd�Zd"dd�Zd#dd�Zdd�ZdZdd�Zdd�Zdd�ZzddlmZWn<e�yZz"e
�e�ddl mZWYdZ[n
dZ[00dS)$z$File annotate based on weave storage�)�absolute_importN�)�lazy_importz=

import patiencediff

from breezy import (
    tsort,
    )
)�config�errors�osutils)�_strip_NULL_ghosts)�CURRENT_REVISION�RevisionFcCs�|dur|j}|durtj}t��}t|�|��}|rDt||||�St|dd�s�t	t
�}	|��|	_z|�
��d�|	_Wntjy�d|	_Yn0d|	_tt��d�|	_t��|	_nd}	tt|||	��}
t|
||||�dS)a)Annotate path in a tree.

    The tree should already be read_locked() when annotate_file_tree is called.

    :param tree: The tree to look for revision numbers and history from.
    :param path: The path to annotate
    :param to_file: The file to output the annotation to.
    :param verbose: Show all details rather than truncating to ensure
        reasonable text width.
    :param full: XXXX Not sure what this does.
    :param show_ids: Show revision ids in the annotation output.
    :param branch: Branch to use for revision revno lookups
    NZget_revision_idF�emailz
local user�?�)�branch�sys�stdoutrZget_terminal_encoding�listZ
annotate_iter�_show_id_annotations�getattrr
r	Zget_parent_ids�
parent_idsZget_config_stack�getZ	committerrZNoWhoami�message�round�time�	timestampZlocal_time_offset�timezone�_expand_annotations�_print_annotations)Ztree�path�to_file�verbose�fullZshow_idsr�encoding�annotations�current_rev�
annotation�r%�1/usr/lib/python3/dist-packages/breezy/annotate.py�annotate_file_tree6s.
�r'cCs�t|�dkrd}}n$tdd�|D��}tdd�|D��}|sHt|d�}t|d�}d}|D]�\}}	}
}}|r�d||||	|
f}
n6t|�|kr�|d	|d
�d}d|||	d	d
�f}
|
��dkr�|r�|}
|�|
�|�d|�|�f�|
}qZd	S)z�Print annotations to to_file.

    :param to_file: The file to output the annotation to.
    :param verbose: Show all details rather than truncating to ensure
        reasonable text width.
    :param full: XXXX Not sure what this does.
    rcss|]}t|d�VqdS�rN��len��.0�xr%r%r&�	<genexpr>o�z%_print_annotations.<locals>.<genexpr>css|]}t|d�VqdS)rNr)r+r%r%r&r.pr/�r
�z%-*s %-*s %8s Nr�>z
%-*s %-7s �z| %s
)r*�max�min�lstrip�write�decode)r$rrr r!�max_origin_lenZ
max_revno_lenZprevanno�	revno_str�author�date_strZline_rev_id�textZannor%r%r&rds*


�
rc		Csj|sdSd}tdd�|D��}|D]B\}}|s6||kr<|}nd}|�d||�d�|�|�f�|}q"dS)Ncss|]\}}t|�VqdS�Nr))r,�originr=r%r%r&r.�r/z'_show_id_annotations.<locals>.<genexpr>r/z%*s | %szutf-8)r4r7r8)	r"rr r!Zlast_rev_idr9r?r=�thisr%r%r&r�s�rccs�|j}tdd�|D��}|durx|j}|��}dd�|�|j�D�}t|�}|j||<tj||ddd�}dd�|D�}	n|�	�}	d}
i}t
|vr�d	|��d
f|	t
<||t
<|�dd�|�
|�D��|D]�\}}
|
�d�}
||
kr�d
\}}}n�|}
||v�rd\}}}nd�dd�|	|D��}||}|j�p6d}t�dt�|j|��}|��d}t�|�\}}|�rt|}|||||
fVq�dS)a�Expand a file's annotations into command line UI ready tuples.

    Each tuple includes detailed information, such as the author name, and date
    string for the commit, rather than just the revision id.

    :param annotations: The annotations to expand.
    :param revision_id_to_revno: A map from id to revision numbers.
    :param branch: A locked branch to query for revision details.
    css|]\}}|VqdSr>r%)r,�o�tr%r%r&r.�r/z&_expand_annotations.<locals>.<genexpr>NcSsi|]\}}|dur||�qSr>r%)r,�key�valuer%r%r&�
<dictcomp>�s�z'_expand_annotations.<locals>.<dictcomp>T)Zgenerate_revnocSsi|]\}}}}}||�qSr%r%)r,Zseq_numZrev_idZdepth�revnoZend_of_merger%r%r&rE�s�z%d?rcss|]}|ddur|VqdSr(r%)r,�entryr%r%r&r.�s�s
)r1r1r1)rrr�.css|]}t|�VqdSr>)�str)r,�ir%r%r&r.�srz%Y%m%d)�
repository�set�revision_idZ	get_graphZ
iter_ancestryrrZtsortZ
merge_sortZget_revision_id_to_revno_mapr	rF�updateZiter_revisions�rstrip�joinrr�strftime�gmtimerZget_apparent_authorsrZparse_username)r"rr#rKZrevision_idsZ
last_revisionZgraphZrevision_graphZmerge_sorted_revisionsZrevision_id_to_revnoZlast_originZ	revisionsr?r=r:r;r<ZrevZtz�_rr%r%r&r�sb

�
���
�


��rcsPt|�dkr"�fdd��D�}�n*t|�dkrDt|d��|�}�nt|�dkrxt|d��|�}t|d��||�}n�t|d��|�g}|���fdd�|dd�D��g}t|�D]�}td	d�|D��}	t|	�dkr�|�|d�q�|dd}
t|	�dk�r�|	v�r|	���t|	�dk�r<|�|	��|
f�q�|��|
f�q�|S)
a�Create a new annotated version from new lines and parent annotations.

    :param parents_lines: List of annotated lines for all parents
    :param new_lines: The un-annotated new lines
    :param new_revision_id: The revision-id to associate with new lines
        (will often be CURRENT_REVISION)
    :param left_matching_blocks: a hint about which areas are common
        between the text and its left-hand-parent.  The format is
        the SequenceMatcher.get_matching_blocks format
        (start_left, start_right, length_of_match).
    :param heads_provider: An object which provides a .heads() call to resolve
        if any revision ids are children of others.
        If None, then any ancestry disputes will be resolved with
        new_revision_id
    rcsg|]}�|f�qSr%r%)r,�line)�new_revision_idr%r&�
<listcomp>�r/zreannotate.<locals>.<listcomp>r�c3s|]}t|���VqdSr>)�_reannotate)r,�p��	new_linesrUr%r&r.s�zreannotate.<locals>.<genexpr>Ncss|]\}}|VqdSr>r%�r,�a�lr%r%r&r.r/)	r*rX�_reannotate_annotated�extend�ziprL�append�remove�pop)Z
parents_linesr[rUZ_left_matching_blocks�heads_provider�lines�leftZ
reannotationsZannosZoriginsrTr%rZr&�
reannotate�s@��
�
�
�
rhcCs�d}|dur0dd�|D�}t�d||�}|��}g}|D]H\}}	}
|||	�D]}|�||f�qN|�||||
��|	|
}q8|S)NrcSsg|]\}}|�qSr%r%)r,�rr^r%r%r&rVr/z_reannotate.<locals>.<listcomp>)�patiencediff�PatienceSequenceMatcher�get_matching_blocksrbr`)Zparent_linesr[rUZmatching_blocksZnew_curZplain_parent_lines�matcherrfrJ�j�nrTr%r%r&rXs�
rXcCst�d||�}|��Sr>)rjrkrl)�old�newrmr%r%r&�_get_matching_blocks'srrcCst|�dS)a�Chose an attribution between several possible ones.

    :param annotated_lines: A list of tuples ((file_id, rev_id), line) where
        the lines are identical but the revids different while no parent
        relation exist between them

     :return : The "winning" line. This must be one with a revid that
         guarantees that further criss-cross merges will converge. Failing to
         do so have performance implications.
    r)�sorted)�annotated_linesr%r%r&�_old_break_annotation_tie/sruc
Cs\|j}
|j}dd�|||�D�}|||�}
t||
�}d}|D�]\}}}||krl|
|||||��t|�D]�}||||}||||}|d|dkr�||�qt|d|	kr�||�qt|dur�||	|df�qt|�|d|df�}t|�dk�r |tt|��|df�qttdu�r<|t	||g��qt|t||g��qt||}q@dS)a�Find lines in plain_right_lines that match the existing lines.

    :param output_lines: Append final annotated lines to this list
    :param plain_child_lines: The unannotated new lines for the child text
    :param child_lines: Lines for the child text which have been annotated
        for the left parent

    :param start_child: Position in plain_child_lines and child_lines to start
        the match searching
    :param end_child: Last position in plain_child_lines and child_lines to
        search for a match
    :param right_lines: The annotated lines for the whole text for the right
        parent
    :param start_right: Position in right_lines to start the match
    :param end_right: Last position in right_lines to search for a match
    :param heads_provider: When parents disagree on the lineage of a line, we
        need to check if one side supersedes the other
    :param revision_id: The label to give if a line should be labeled 'tip'
    cSsg|]\}}|�qSr%r%r\r%r%r&rV^r/z4_find_matching_unannotated_lines.<locals>.<listcomp>rNr)
r`rbrr�range�headsr*�next�iter�_break_annotation_tieru)Zoutput_linesZplain_child_linesZchild_linesZstart_childZ	end_childZright_linesZstart_rightZ	end_rightrerMZ
output_extendZ
output_appendZplain_right_subsetZplain_child_subsetZmatch_blocksZlast_child_idx�	right_idxZ	child_idx�	match_len�offsetrg�rightrwr%r%r&� _find_matching_unannotated_linesDs:

�



�rc
Cs�t|�t|�krtd��g}|j}d}d}t||�}	|	D]j\}
}}||
ksR||krd||||��nt||||||||
||�
|
|}||}|||||��q8|S)aMUpdate the annotations for a node based on another parent.

    :param right_parent_lines: A list of annotated lines for the right-hand
        parent.
    :param new_lines: The unannotated new lines.
    :param new_revision_id: The revision_id to attribute to lines which are not
        present in either parent.
    :param annotated_lines: A list of annotated lines. This should be the
        annotation of new_lines based on parents seen so far.
    :param heads_provider: When parents disagree on the lineage of a line, we
        need to check if one side supersedes the other.
    z(mismatched new_lines and annotated_linesr)r*�AssertionErrorr`rrr)
Zright_parent_linesr[rUrtrerfZlines_extendZlast_right_idxZ
last_left_idxZmatching_left_and_rightr{Zleft_idxr|r%r%r&r_�s0��r_)�	Annotator)FFFN)N)NN)N)!�__doc__Z
__future__rrrr�globalsr1rrrrKrZrevisionr	r
r'rrrrhrXrrrzrurr_Zbreezy._annotator_pyxr��ImportError�eZfailed_to_load_extensionZbreezy._annotator_pyr%r%r%r&�<module>s:�
.$
L�
4�
D1