File: //usr/lib/python3/dist-packages/hgext/__pycache__/extdiff.cpython-310.pyc
o
�]Lb�c � @ s0 d Z ddlmZ ddlZddlZddlZddlZddlZddlm Z ddl
mZmZ ddl
mZmZmZmZmZmZmZmZmZmZmZ ddlmZmZ i Ze�e�Zi Ze�e�Zedd d
dd� edd
dd� eddddd� edddd� dZ dd� Z!dd� Z"dGdd�Z#dd� Z$dd� Z%dd� Z&dHd d!�Z'd"d#g e d$�e d%�fd&d'g e d(�e d)�fd
d*d
e d+�e d,�fd
d-d
e d.�e d/�fd0d1d
e d2�e d)�fd
d3de d4�fd
d5de d6�fd
d7de d8�fgej( ej) Z*edd9d:d
e d;�e d<�fge* e d=�ej+dd>�d?d@� �Z,G dAdB� dBe-�Z.dCdD� Z/dEdF� Z0e.gZ1dS )IaB command to allow external programs to compare revisions
The extdiff Mercurial extension allows you to use external programs
to compare revisions, or revision with working directory. The external
diff programs are called with a configurable set of options and two
non-option arguments: paths to directories containing snapshots of
files to compare.
If there is more than one file being compared and the "child" revision
is the working directory, any modifications made in the external diff
program will be copied back to the working directory from the temporary
directory.
The extdiff extension also allows you to configure new diff commands, so
you do not need to type :hg:`extdiff -p kdiff3` always. ::
[extdiff]
# add new command that runs GNU diff(1) in 'context diff' mode
cdiff = gdiff -Nprc5
## or the old way:
#cmd.cdiff = gdiff
#opts.cdiff = -Nprc5
# add new command called meld, runs meld (no need to name twice). If
# the meld executable is not available, the meld tool in [merge-tools]
# will be used, if available
meld =
# add new command called vimdiff, runs gvimdiff with DirDiff plugin
# (see http://www.vim.org/scripts/script.php?script_id=102) Non
# English user, be sure to put "let g:DirDiffDynamicDiffText = 1" in
# your .vimrc
vimdiff = gvim -f "+next" \
"+execute 'DirDiff' fnameescape(argv(0)) fnameescape(argv(1))"
Tool arguments can include variables that are expanded at runtime::
$parent1, $plabel1 - filename, descriptive label of first parent
$child, $clabel - filename, descriptive label of child revision
$parent2, $plabel2 - filename, descriptive label of second parent
$root - repository root
$parent is an alias for $parent1.
The extdiff extension will look in your [diff-tools] and [merge-tools]
sections for diff tool arguments, when none are specified in [extdiff].
::
[extdiff]
kdiff3 =
[diff-tools]
kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child
If a program has a graphical interface, it might be interesting to tell
Mercurial about it. It will prevent the program from being mistakenly
used in a terminal-only environment (such as an SSH terminal session),
and will make :hg:`extdiff --per-file` open multiple file diffs at once
instead of one by one (if you still want to open file diffs one by one,
you can use the --confirm option).
Declaring that a tool has a graphical interface can be done with the
``gui`` flag next to where ``diffargs`` are specified:
::
[diff-tools]
kdiff3.diffargs=--L1 '$plabel1' --L2 '$clabel' $parent $child
kdiff3.gui = true
You can use -I/-X and list of file or directory names like normal
:hg:`diff` command. The extdiff extension makes snapshots of only
needed files, so running the external diff program will actually be
pretty fast (at least faster than having to compare the entire tree).
� )�absolute_importN)�_)�nullrev�short)�archival�cmdutil�encoding�error� filemerge� formatter�
logcmdutil�pycompat� registrar�scmutil�util)�procutil�
stringutil� extdiffs opts\..*� T)�default�generics gui\..*)r �
diff-toolss
.*\.diffargs$s .*\.gui$s ships-with-hg-corec C s t j�|j�}|dkr
d}|durd|t|�f }t j�||�}t �|� g }|dur;| �td�t |�t|�f � n| �td�t |� � |r�|j
�ddd � tj
|||d
t�||�|d� t|�D ]'} t�| �}
| �d|
� |du r�t j�||
�}|�||�| �t �|�f� qc||fS )
z�snapshot files as of some revision
if not using snapshot, -I/-X does not work and recursive diff
in tools like kdiff3 and meld displays too many files.r � rootNs %s.%ss( making snapshot of %d files from rev %s
s3 making snapshot of %d files from working directory
s uis archivemetaFs files)�match�subreposs %s
)�os�path�basename�rootr �join�mkdir�noter �len�ui� setconfigr �archiver �
matchfiles�sortedr �pconvert�append�wjoin�lstat)r# �repo�files�node�tmproot�listsubrepos�dirname�base�
fnsandstat�fn�wfn�dest� r7 �//usr/lib/python3/dist-packages/hgext/extdiff.py�snapshot� sJ
����
�
�r9 c sN ||||||||d��� �fdd�} d}
� s t �|
| �s | d7 } t �|
| | �S )N)s parents parent1� parent2s plabel1s plabel2s childs clabelr c s6 | � d�}| � d�}� s|dkr|S |t��| � S )N� � r: )�groupr �
shellquote)r �pre�key��do3way�replacer7 r8 �quote� s
zformatcmdline.<locals>.quotesJ (['"]?)([^\s'"$]*)\$(parent2|parent1?|child|plabel1|plabel2|clabel|root)\1s $parent1 $child)�re�search�sub)�cmdline� repo_rootrB �parent1�plabel1�parent2�plabel2�child�clabelrD �regexr7 rA r8 �
formatcmdline� s � �rQ c C s: t �|�}tjt �| �dt jt �|�t�t j|�d�}|S )zflike 'procutil.system', but returns the Popen object directly
so we don't have to wait on it.
T)�shell� close_fds�env�cwd) r �shellenviron�
subprocess�Popen�tonativestr�closefds�tonativeenvr
�rapply)�cmd�environrU rT �procr7 r7 r8 �_systembackground� s
�r` c C s g }t |�}tt|��D ]�\}}tj�||�}|| }tj�|�s$tj}d}d}|r>tj�| |�}|| }tj�|�s>tj}tj�|
|�}||
}|r�t d�||d |f }t d�}|�
d||f �}|dkr�|dkr�|�|�d D ]\}}|�d|t
�|�f � qr|�
d||f �}|dksk|dkr�n|dkr�q|d kr� n>t| ||||||||d
� }|s�|s�|�dt�|�|f � |j||dd
� q|�dt�|�|f � t||d�}|�|� q|�r|�d�� |D ]}|�� q�W d � d S 1 s�w Y d S d S )Nr s diff %s (%d of %d)� sZ [Yns?]$$ &Yes, show diff$$ &No, skip this diff$$ &Skip remaining diffs$$ &? (display help)s %s %sr<