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

�*�^M��	@s�ddlmZddlZddlZddlZddlZddlmZee�d�ddlm	Z	ddl
mZddlm
Z
dd	lmZmZmZdd
lmZdZGdd
�d
ej�Zdddefdd�Zd;dd�Zd<dd�Zgd�Zdd�Zdd�Zd=dd�Zd>d d!�Zddd"d#ddddef	d$d%�Zd&d'�Z d(d)�Z!Gd*d+�d+e"�Z#Gd,d-�d-e"�Z$Gd.d/�d/e#�Z%Gd0d1�d1e#�Z&Gd2d3�d3e#�Z'Gd4d5�d5e#�Z(Gd6d7�d7e#�Z)Gd8d9�d9e"�Z*e�Z+e+�,d:e*�dS)?�)�absolute_importN�)�lazy_importz�
import errno
import patiencediff
import subprocess
import tempfile

from breezy import (
    cleanup,
    controldir,
    osutils,
    textfile,
    timestamp,
    views,
    )

from breezy.workingtree import WorkingTree
from breezy.i18n import gettext
)�errors)�Registry)�	text_type)�mutter�note�warning)�FileTimestampUnavailable�c@seZdZdZdd�ZdS)�_PrematchedMatcherz<Allow SequenceMatcher operations to use predetermined blockscCst�|dd�||_d|_dS�N)�difflib�SequenceMatcher�matching_blocksZopcodes)�selfr�r�-/usr/lib/python3/dist-packages/breezy/diff.py�__init__Bsz_PrematchedMatcher.__init__N)�__name__�
__module__�__qualname__�__doc__rrrrrr
?sr
F�utf8c	Cs�|durt�|�t�|�|dur*tj}t|||�|d�|�|d�||d�}	t|	�}	t|	�dkrfdS|s�|	d�dd�|	d<n|s�|	d�dd	�|	d<|	D]"}
|�	|
�|
�
d
�s�|�	d�q�|�	d
�dS)NF�replace)�fromfile�tofile�n�sequencematcherr�s-1,0s-0,0s+1,0s+0,0�
s
\ No newline at end of file
)ZtextfileZcheck_text_linesZpatiencediffZPatienceSequenceMatcher�unified_diff_bytes�encode�list�lenr�write�endswith)�	old_label�oldlines�	new_label�newlines�to_fileZallow_binaryZsequence_matcher�
path_encoding�
context_linesZud�linerrr�
internal_diffHs.




�

r0�r!c	csn|durtj}|rdt|�}|r.dt|�}d}	|d||��|�D�]"}
|	srd|||fVd|||fVd}	|
dd|
d	d
|
dd|
d	df\}}}
}d
|d|||
d||
|fV|
D]�\}}}}
}|dk�r|||�D]}d|Vq�q�|dk�s|dk�r6|||�D]}d|V�q$|dk�sH|dkr�||
|�D]}d|V�qTq�qDdS)a�
    Compare two sequences of lines; generate the delta as a unified diff.

    Unified diffs are a compact way of showing line changes and a few
    lines of context.  The number of context lines is set by 'n' which
    defaults to three.

    By default, the diff control lines (those with ---, +++, or @@) are
    created with a trailing newline.  This is helpful so that inputs
    created from file.readlines() result in diffs that are suitable for
    file.writelines() since both the inputs and outputs have trailing
    newlines.

    For inputs that do not have trailing newlines, set the lineterm
    argument to "" so that the output will be uniformly newline free.

    The unidiff format normally has a header for filenames and modification
    times.  Any or all of these may be specified using strings for
    'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'.  The modification
    times are normally expressed in the format returned by time.ctime().

    Example:

    >>> for line in bytes_unified_diff(b'one two three four'.split(),
    ...             b'zero one tree four'.split(), b'Original', b'Current',
    ...             b'Sat Jan 26 23:30:50 1991', b'Fri Jun 06 10:20:52 2003',
    ...             lineterm=b''):
    ...     print line
    --- Original Sat Jan 26 23:30:50 1991
    +++ Current Fri Jun 06 10:20:52 2003
    @@ -1,4 +1,4 @@
    +zero
     one
    -two
    -three
    +tree
     four
    N�	Fs
--- %s%s%ss
+++ %s%s%sTrr���r r�s@@ -%d,%d +%d,%d @@%sZequal� r�delete�-�insert�+)rr�bytesZget_grouped_opcodes)�a�brrZfromfiledateZ
tofiledaterZlinetermrZstarted�groupZi1Zi2Zj1Zj2�tagr/rrrr"rs2(4$
r"Tc
Cs�|rDi}tj�d�}|dur$||d<d|d<d|d<d|d<tj}nd}d}ztj|tjtj||d�}Wn@ty�}z(|jtjkr�t	�
t|����WYd}~n
d}~00|S)a@Spawn the external diff process, and return the child handle.

    :param diffcmd: The command list to spawn
    :param capture_errors: Capture stderr as well as setting LANG=C
        and LC_ALL=C. This lets us read and understand the output of diff,
        and respond to any errors.
    :return: A Popen object.
    �PATHN�CZLANGUAGEZLANG�LC_ALL)�stdin�stdout�stderr�env)�os�environ�get�
subprocess�PIPE�Popen�OSError�errno�ENOENTrZNoDiff�str)�diffcmd�capture_errorsrE�pathrD�pipe�errr�_spawn_external_diff�s.	�
rU)z-cz-Cz	--contextz-ez--edz-fz--forward-edz-qz--briefz--normalz-nz--rcs�-uz-Uz	--unifiedz-yz--side-by-sidez-Dz--ifdefcCs6tD]"}|D]}|�|�rq"qqq2q|�d�|S)a�Default to unified diff style if alternative not specified in diff_opts.

        diff only allows one style to be specified; they don't override.
        Note that some of these take optargs, and the optargs can be
        directly appended to the options.
        This is only an approximate parser; it doesn't properly understand
        the grammar.

    :param diff_opts: List of options for external (GNU) diff.
    :return: List of options with default style=='unified'.
    rV)�style_option_list�
startswith�append)�	diff_opts�s�jrrr�default_style_unified�s

r]cCs6|��tjdd�\}}tjdd�\}}	t�|d�}
t�|d�}�z�|
�|�|�|�|
��|��|spg}tjdkr�|�	d�}|�	d�}dd||d||	d	g}t
|�}|r�|�|�t|d
d�}
|
�
�\}}|
j}|d7}|d
k�r�|}t|dd�}
|
�
�\}}|�|d�|
jd
k�r.t�d|f��|�dd�d}t�d|tj�}|du�rjt�d|f��n.W|
��|��dd�}||�||	�dS|�|�|dv�r�|dk�r�d|}nd|}t�d||f��W|
��|��dd�}||�||	�n*|
��|��dd�}||�||	�0dS)z;Display a diff by calling out to the external diff program.z
brz-diff-old-��prefixz
brz-diff-new-�wb�win32�mbcs�diffz--labelz--binaryT)rQr!r Fzfexternal diff failed with exit code 2 when run with LANG=C and LC_ALL=C, but not when run natively: %rrrs^(binary )?files.*differ$Nz2external diff failed with exit code 2; command: %rc
SsRzt�|�Wn>tyL}z&|jtjfvr8td||�WYd}~n
d}~00dS)Nz&Failed to delete temporary file: %s %s)rF�removerLrMrNr
)rRrTrrr�cleanupas
zexternal_diff.<locals>.cleanup)rrz	signal %dzexit code %dz)external diff failed with %s; command: %r)�flushZtempfileZmkstemprF�fdopen�
writelines�close�sys�platformr#r]�extendrUZcommunicate�
returncoder&rZBzrError�split�re�match�I)r(r)r*r+r,rZZ	oldtmp_fdZold_abspathZ	newtmp_fdZnew_abspathZoldtmpfZnewtmpfrPrS�out�errZrcZ
lang_c_outZ
first_line�mre�msgrrr�
external_diffs�




�

��
�
�


�

�
rvcsdd}d}|durXt|�dkr4|d}|dur4|��}t|�dkrX|d}|durX|��}g}d}	d}
|dusxt|�dkr�d}d}
n.|dur�|dur�|}d}	n|d}|dd�}�fdd�}g}
|dur�|}tj�|�\}}}|||�|
�r|d	k�r|du�r|�rt�||�|
�|�t|||�}|}|du�r<|}||k�r�tj�|�\}}}|||�|
�r�|d	k�r�|du�r�|�r�t�||�|
�|�t||||dud
�}|}|	�r�|du�r�|j	||d�}|
�
|�t|
�dk�r2d}
|du�r2|���r2|�r2|j��}|�r2|}
t�
|�}ttd�|�d}|du�rT|||fv�rT|f}|||||
|fS)
a!Get the trees and specific files to diff given a list of paths.

    This method works out the trees to be diff'ed and the files of
    interest within those trees.

    :param path_list:
        the list of arguments passed to the diff command
    :param revision_specs:
        Zero, one or two RevisionSpecs from the diff command line,
        saying what revisions to compare.
    :param old_url:
        The url of the old branch or tree. If None, the tree to use is
        taken from the first path, if any, or the current working tree.
    :param new_url:
        The url of the new branch or tree. If None, the tree to use is
        taken from the first path, if any, or the current working tree.
    :param exit_stack:
        an ExitStack object. get_trees_and_branches_to_diff
        will register cleanups that must be run to unlock the trees, etc.
    :param apply_view:
        if True and a view is set, apply the view or check that the paths
        are within it
    :returns:
        a tuple of (old_tree, new_tree, old_branch, new_branch,
        specific_files, extra_trees) where extra_trees is a sequence of
        additional trees to search in for file-ids.  The trees and branches
        will be read-locked until the cleanups registered via the exit_stack
        param are run.
    NrrT�.Fcs2|dur��|���n|dur.��|���dSr)�
enter_context�	lock_read)Zwt�br��
exit_stackrr�lock_tree_or_branch�szBget_trees_and_branches_to_diff_locked.<locals>.lock_tree_or_branch�)�basis_is_default)�
apply_viewz+*** Ignoring files outside view. View is %s)r%Z
get_branchZ
controldirZ
ControlDirZopen_containing_tree_or_branchZviewsZcheck_path_in_viewrY�_get_tree_to_diffZsafe_relpath_filesrlZsupports_viewsZlookup_viewZview_display_strr	�gettext)�	path_listZrevision_specsZold_urlZnew_urlr|r�Zold_revision_specZnew_revision_specZother_pathsZmake_paths_wt_relativeZconsider_relpathZdefault_locationr}�specific_filesZworking_tree�branch�relpath�old_treeZ
old_branch�new_treeZ
new_branchZ
view_filesZview_str�extra_treesrr{r�%get_trees_and_branches_to_diff_lockedos� 
�




�

��
�

�r�cCsT|dur|dur|j}|dus(|jdurJ|rF|dur<|��S|��Sn|S|�|�Sr)r��specZ
basis_treeZas_tree)r��treer�rrrrr��s
r�za/zb/cCs�|durt}|
durt}
t���t}|�|���|durP|D]}
|�|
���q<|�|���|
j||||||||	|d�	}|�||�Wd�S1s�0YdS)aShow in text form the changes from one tree to another.

    :param to_file: The output stream.
    :param specific_files: Include only changes to these files - None for all
        changes.
    :param external_diff_options: If set, use an external GNU diff and pass
        these options.
    :param extra_trees: If set, more Trees to use for looking up file ids
    :param path_encoding: If set, the path will be encoded as specified,
        otherwise is supposed to be utf8
    :param format_cls: Formatter class (DiffTree subclass)
    N�r.)�DEFAULT_CONTEXT_AMOUNT�DiffTreere�	ExitStackrxry�from_trees_options�	show_diff)r�r�r,r��external_diff_optionsr(r*r�r-�usingZ
format_cls�contextr|r��differrrr�show_diff_trees�s"

�r�cCs0z|�|�}Wnty$d}Yn0t�|�S)z7Returns a timestamp suitable for use in a patch header.r)�get_file_mtimerZ	timestampZformat_patch_date)r�rR�mtimerrr�_patch_header_dates

r�cCs2dddd�}||kr*d||||fgSgSdS)Ns+xs-xs??)TFNs%s to %sr)Zold_is_xZnew_is_xZdescrrrr�get_executable_change!sr�c@sFeZdZdZdZdZdZddd�Zdd	�Ze	d
d��Z
edd
��ZdS)�DiffPathz/Base type for command object that compare files�CANNOT_DIFF�CHANGED�	UNCHANGED�utf-8cCs||_||_||_||_dS)a)Constructor.

        :param old_tree: The tree to show as the old tree in the comparison
        :param new_tree: The tree to show as new in the comparison
        :param to_file: The file to write comparison data to
        :param path_encoding: The character encoding to write paths in
        N�r�r�r,r-)rr�r�r,r-rrrr3szDiffPath.__init__cCsdSrr�rrrr�finish@szDiffPath.finishcCs||j|j|j|j�Srr���klass�	diff_treerrr�from_diff_treeCs
�zDiffPath.from_diff_treecCs2|D]&}|�||||�}|tjur|SqtjSr)rcr�r�)�differs�old_path�new_path�old_kind�new_kindZfile_differ�resultrrr�
_diff_manyHs


zDiffPath._diff_manyN)r�)
rrrrr�r�r�rr��classmethodr��staticmethodr�rrrrr�)s


r�c@s4eZdZdZdd�Zdd�Zedd��Zdd	�Zd
S)�DiffKindChangez�Special differ for file kind changes.

    Represents kind change as deletion + creation.  Uses the other differs
    to do this.
    cCs
||_dSr�r�)rr�rrrrYszDiffKindChange.__init__cCsdSrrr�rrrr�\szDiffKindChange.finishcCs
||j�Srr�r�rrrr�_szDiffKindChange.from_diff_treecCsHd||fvrtjSt�|j|||d�}|tjur4|St�|j||d|�S)z�Perform comparison

        :param old_path: Path of the file in the old tree
        :param new_path: Path of the file in the new tree
        :param old_kind: Old file-kind of the file
        :param new_kind: New file-kind of the file
        N)r�r�r�r�)rr�r�r�r�r�rrrrccs�
�zDiffKindChange.diffN)	rrrrrr�r�r�rcrrrrr�Rs
r�c@seZdZdd�ZdS)�DiffTreeReferencecCs4d||fvr|jS|dvr |jS|dvr.|jS|jS)zBPerform comparison between two tree references.  (dummy)

        �tree-reference)r�N�r�r��rr�r�r�r�rrrrcwszDiffTreeReference.diffN�rrrrcrrrrr�usr�c@seZdZdd�ZdS)�
DiffDirectorycCs4d||fvr|jS|dvr |jS|dvr.|jS|jS)z>Perform comparison between two directories.  (dummy)

        �	directory)r�Nr�r�rrrrc�szDiffDirectory.diffNr�rrrrr��sr�c@seZdZdd�Zdd�ZdS)�DiffSymlinkcCsrd||fvr|jS|dkr(|j�|�}n|dur6d}n|jS|dkrR|j�|�}n|dur`d}n|jS|�||�S)aPerform comparison between two symlinks

        :param old_path: Path of the file in the old tree
        :param new_path: Path of the file in the new tree
        :param old_kind: Old file-kind of the file
        :param new_kind: New file-kind of the file
        �symlinkN)r�r�Zget_symlink_targetr��diff_symlink)rr�r�r�r��
old_target�
new_targetrrrrc�szDiffSymlink.diffcCsv|dur$|j�d|�|jd��nL|durH|j�d|�|jd��n(|j�d|�|jd�|�|jd�f�|jS)Ns=== target is '%s'
rs=== target was '%s'
s === target changed '%s' => '%s'
)r,r&r#r-r�)rr�r�rrrr��s����zDiffSymlink.diff_symlinkN)rrrrcr�rrrrr��sr�c@s4eZdZdZdddeefdd�Zdd�Zdd	�Zd
S)�DiffTextz1970-01-01 00:00:00 +0000r�r~c		Cs4t�|||||�||_||_||_||_||_dSr)r�r�text_differr(r*r-r.)	rr�r�r,r-r(r*r�r.rrrr�szDiffText.__init__c	Cs�d||fvr|jS|dkr(t|j|�}n|dur8|j}n|jS|dkrTt|j|�}n|durd|j}n|jSd|j|pv||f}d|j|p�||f}|�||||�S)aCompare two files in unified diff format

        :param old_path: Path of the file in the old tree
        :param new_path: Path of the file in the new tree
        :param old_kind: Old file-kind of the file
        :param new_kind: New file-kind of the file
        �fileNz%s%s	%s)r�r�r��
EPOCH_DATEr�r(r*�	diff_text)	rr�r�r�r�Zold_dateZnew_date�
from_label�to_labelrrrrc�s&��z
DiffText.diffc
Cs�dd�}z:||j|�}||j|�}|j|||||j|j|jd�WnBtjy�|j�d|j	|pd||j
|pn|f�|jd��Yn0|jS)aXDiff the content of given files in two trees

        :param from_path: The path in the from tree. If None,
            the file is not present in the from tree.
        :param to_path: The path in the to tree. This may refer
            to a different file from from_path.  If None,
            the file is not present in the to tree.
        cSs6|durgSz|�|�WStjy0gYS0dSr)Zget_file_linesrZ
NoSuchFile)r�rRrrr�	_get_text�sz%DiffText.diff_text.<locals>._get_text)r-r.z"Binary files %s%s and %s%s differ
r)
r�r�r�r,r-r.rZ
BinaryFiler&r(r*r#r�)rZ	from_pathZto_pathr�r�r�Z	from_textZto_textrrrr��s&	�


����
zDiffText.diff_textN)	rrrr�r0r�rrcr�rrrrr��s�

r�c@s�eZdZd dd�Zed!dd��Zed"dd��Zd	d
�Zdd�Zd
d�Z	e
dd��Zdd�Zdd�Z
d#dd�Zd$dd�Zdd�Zdd�Zdd�ZdS)%�DiffFromToolr�cCs*t�|||||�||_tjdd�|_dS)Nz	brz-diff-r^)r�r�command_template�osutilsZmkdtemp�_root)rr�r�r�r,r-rrrrszDiffFromTool.__init__cCs||||||�Srr)r�r�r�r�r,r-rrr�from_strings
�zDiffFromTool.from_stringNcs���fdd�}|S)Ncs0�g}�dur|d�7}��||j|j|j�S)N� )r�r�r�r,)r�Zfull_command_string��command_stringr�r�rrr�s
�z8DiffFromTool.make_from_diff_tree.<locals>.from_diff_treer)r�r�r�r�rr�r�make_from_diff_treesz DiffFromTool.make_from_diff_treecs~||d���fdd�|jD�}||jkr4|||g7}tjdkrvg}|D]*}t|t�rf|�|�d��qF|�|�qF|S|SdS)N)r�r�csg|]}|jfi����qSr)�format)�.0�t�Zmy_maprr�
<listcomp> r1z-DiffFromTool._get_command.<locals>.<listcomp>rarb)r�rjrk�
isinstancerrYr#)rr�r��commandZcommand_encoded�crr�r�_get_commands

�


zDiffFromTool._get_commandc
Cs�|�||�}ztj|tj|jd�}WnBtyf}z*|jtjkrPt�	|d��n�WYd}~n
d}~00|j
�|j�
��|j��|��S)N)rC�cwdr)r�rIrKrJr�rLrMrNrZExecutableMissingr,r&rC�readri�wait)rr�r�r��procrTrrr�_execute/s
�

zDiffFromTool._executec
Cstt|dd�dust��sdSz t�|�d�t�|j|��Wn2tyn}z|j	t	j
krZ�WYd}~n
d}~00dS)N�abspathFr~T)�getattrr�Zhost_os_dereferences_symlinksrFr�r��pathjoinr�rLrM�EEXIST)rr�r_rTrrr�_try_symlink_root=s� zDiffFromTool._try_symlink_rootcCstjdkrdSt��pdSdS)z8Returns safe encoding for passing file path to diff toolrarb�asciiN)rjrk�getfilesystemencodingrrrr�_fencHs
zDiffFromTool._fenccCs8|��}z||�|��|�kWSty2YdS0dS)z8Return true if `path` may be able to pass to subprocess.FN)r�r#�decode�UnicodeError)rrR�fencrrr�_is_safepathRs
zDiffFromTool._is_safepathcCs8|��}|�|d��|d�}|�dd�}t�|j||�S)z]Replace unsafe character in `relpath` then join `self._root`,
        `prefix` and `relpath`.r�?�_)r�r#r�rr�r�r�)rr_r�r�Zrelpath_tmprrr�_safe_filenameZszDiffFromTool._safe_filenameFc
Cs:|s&t|t�r&|�|�}|�|�r&|S|�||�}|sF|�||�rF|St�|�}zt�	|�Wn2t
y�}z|jtjkr|�WYd}~n
d}~00|�
|��F}	t|d��}
t�|	|
�Wd�n1s�0YWd�n1s�0Yz|�|�}Wnt�yYn0t�|||f�|�s6t�|�|S)Nr`)r�ZWorkingTreer�r�r�r�r��dirnamerF�makedirsrLrMr�Zget_file�openZpumpfiler�r�utimeZ
make_readonly)rr�r�r_�
force_temp�allow_write�	full_pathZ
parent_dirrT�source�targetr�rrr�_write_fileds4


�H
zDiffFromTool._write_filecCs0|�||jd|�}|j||jd||d�}||fS)N�old�new)r�)r�r�r�)rr�r�r��allow_write_new�
old_disk_path�
new_disk_pathrrr�_prepare_files�s
�
�zDiffFromTool._prepare_filesc
CsXzt�|j�WnBtyR}z*|jtjkr>td|j|f�WYd}~n
d}~00dS)Nz9The temporary directory "%s" was not cleanly removed: %s.)r�Zrmtreer�rLrMrNr)rrTrrrr��s�zDiffFromTool.finishcCs2||fdkrtjS|�||�\}}|�||�dS)N)r�r�)r�r�r�r�)rr�r�r�r�r�r�rrrrc�s�zDiffFromTool.diffcCsh|j||ddd�\}}|�||�}tj||jd�t|d��}|��Wd�S1sZ0YdS)z�Use this tool to edit a file.

        A temporary copy will be edited, and the new contents will be
        returned.

        :return: The new contents of the file.
        T)r�r�)r��rbN)r�r�rIZcallr�r�r�)rr�r�Zold_abs_pathZnew_abs_pathr�Znew_filerrr�	edit_file�s�
zDiffFromTool.edit_file)r�)r�)N)FF)FF)rrrrr�r�r�r�r�r�r�r�r�r�r�r�r�rcr�rrrrr�s.�
�	
	
�
�
	r�c@sXeZdZdZejejejgZddd�Z	e
dd��Zddd	�Zd
d�Z
dd
�Zdd�ZdS)r�a Provides textual representations of the difference between two trees.

    A DiffTree examines two trees and where a file-id has altered
    between them, generates a textual representation of the difference.
    DiffTree uses a sequence of DiffPath objects which are each
    given the opportunity to handle a given altered fileid. The list
    of DiffPath objects can be extended globally by appending to
    DiffTree.diff_factories, or for a specific diff operation by
    supplying the extra_factories option to the appropriate method.
    r�Ncs�|durt||||ddt�}|�_|�_|�_|�_g�_|dur\�j��fdd�|D���j��fdd��jD���j�|t	�
��g�dS)a�Constructor

        :param old_tree: Tree to show as old in the comparison
        :param new_tree: Tree to show as new in the comparison
        :param to_file: File to write comparision to
        :param path_encoding: Character encoding to write paths in
        :param diff_text: DiffPath-type object to use as a last resort for
            diffing text files.
        :param extra_factories: Factories of DiffPaths to try before any other
            DiffPathsNr~c3s|]}|��VqdSrr�r��fr�rr�	<genexpr>�r1z$DiffTree.__init__.<locals>.<genexpr>c3s|]}|��VqdSrrr�r�rrr�r1)r�r0r�r�r,r-r�rl�diff_factoriesr�r�)rr�r�r,r-r��extra_factoriesrr�rr�s
�zDiffTree.__init__c


sf|durt�||�g}
ng}
|r8|���d�fdd�	}nt}t||||||||	d�}|||||||
�S)a�Factory for producing a DiffTree.

        Designed to accept options used by show_diff_trees.

        :param old_tree: The tree to show as old in the comparison
        :param new_tree: The tree to show as new in the comparison
        :param to_file: File to write comparisons to
        :param path_encoding: Character encoding to use for writing paths
        :param external_diff_options: If supplied, use the installed diff
            binary to perform file comparison, using supplied options.
        :param old_label: Prefix to use for old file labels
        :param new_label: Prefix to use for new file labels
        :param using: Commandline to use to invoke an external diff tool
        Ncst|||||��dS)z}:param path_encoding: not used but required
                        to match the signature of internal_diff.
                N)rv)ZolabZolinesZnlabZnlinesr,r-r.�Zoptsrr�	diff_file�sz.DiffTree.from_trees_options.<locals>.diff_filer�)NN)r�r�rnr0r�)
r�r�r�r,r-r�r(r*r�r.rrr�rrrr��s�
��zDiffTree.from_trees_optionsc	CsNz2|�||�W|jD]}|��qS]}|��q$n|jD]}|��q:0dS)z�Write tree diff to self.to_file

        :param specific_files: the specific files to compare (recursive)
        :param extra_trees: extra trees to use for mapping paths to file_ids
        N)�
_show_diffr�r�)rr�r�r�rrrr��s

��
zDiffTree.show_diffcs�jj�j||dd�}d}dd�}�fdd�}t||d�D�]�}|jd	ks:|jd	krVq:|jdd
kr��j��s�td|jdf�q:|j\}}	||�}
||	�}|jdduo�|j	d}|jdduo�|j	d}
|j
}|j}|jd|jdf|jd|jdfk}g}|�t
|d|d��|�r6d
d�|�f}nd}||
fdk�rh�j�d|d�d�|
f�nx||
fdk�r��j�d|d�d�|f�nJ|�r��j�d|d�d�|
||f�n �j�d|d�d�||f�|j�r��||	|d|d�d}|r:d}q:|S)NT)r�r�Zrequire_versionedrcSs|j\}}|}|dur|}|Sr�rR)�changer�r�rRrrr�changes_keys

z(DiffTree._show_diff.<locals>.changes_keycs|dur|��jd�SdS)Nr)r#r-rr�rr�get_encoded_pathsz-DiffTree._show_diff.<locals>.get_encoded_path)�key)NNr�z?Ignoring "%s" as symlinks are not supported on this filesystem.rs (properties changed: %s)s, r1)TFs=== removed %s '%s'
r�)FTs=== added %s '%s'
s=== renamed %s '%s' => '%s'%s
s=== modified %s '%s'%s
)r�Ziter_changesr��sortedZ	parent_id�kindZsupports_symlinksr
rRZ	versioned�
executable�namerlr��joinr,r&r#Zchanged_content�_diff)rr�r��iteratorZhas_changesr	r
rZoldpath�newpathZoldpath_encodedZnewpath_encodedZold_presentZnew_presentrr
ZrenamedZproperties_changedZprop_strrr�rrsp
�
��
(������zDiffTree._show_diffcCsH|durd}n|j�|�}|dur(d}n|j�|�}|�||||�dS)z�Perform a diff of a single file

        :param old_path: The path of the file in the old tree
        :param new_path: The path of the file in the new tree
        N)r�r
r�rr�rrrrcKsz
DiffTree.diffcCs<t�|j||||�}|tjur8|}|dur.|}t�|��dSr)r�r�r�r�rZNoDiffFound)rr�r�r�r�r�Z
error_pathrrrr[s�
zDiffTree._diff)r�NN)N)rrrrr�r�r�r�rrr�r�r�rrcrrrrrr��s
��

%
Er��default)r1r1r1r1rr!N)T)T)NNT)-Z
__future__rrrFrorjr�globalsr~r�registryrZsixishrZtracerr	r
r�rr�rr
r0r"rUrWr]rvr�r�r�r�r��objectr�r�r�r�r�r�r�r�Zformat_registry�registerrrrr�<module>sb
�
*�
E
&p�
u
�
&	)#(K$=