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

�*�^3�@sdZddlmZddlZddlZddlmZddlZddlm	Z	m
Z
mZmZm
Z
mZmZddlmZddlmZdd	lmZmZGd
d�de�Zdd
�Zdd�Zdddd�Zedfdd�Zedfdd�Zeddfdd�Zdd�Zd%dd�ZGdd �d e�Z e �Zd&d!d"�Z!d'd#d$�Z"dS)(zCommit message editor support.�)�absolute_importN)�call�)�bedding�cmdline�config�osutils�trace�	transport�ui)�BzrError)�Hooks)�BytesIO�StringIOc@seZdZdZdS)�BadCommitMessageEncodingzUThe specified commit message contains characters unsupported by the current encoding.N)�__name__�
__module__�__qualname__Z_fmt�rr�2/usr/lib/python3/dist-packages/breezy/msgeditor.pyr+srccs�ztjddfVWnty&Yn0t���d�}|durL|t��fVdD]"}|tjvrPtj|d|fVqPtj	dkr�dD]}|dfVq�nd	D]}|dfVq�dS)
zDReturn sequence of possible editor binaries for the current platformZ
BRZ_EDITORz$BRZ_EDITOR�editorN)ZVISUALZEDITOR�$Zwin32)zwordpad.exeznotepad.exe)z/usr/bin/editorZviZpicoZnanoZjoe)
�os�environ�KeyErrorrZGlobalStack�getr�config_path�sys�platform)�eZvarnamerrrr�_get_editor1s

r cCs�t�D]�\}}t�|�}zt||g�}WnRty|}z:|durZt�d||t|�f�WYd}~q�WYd}~n
d}~00|dkr�dS|dkr�qqq�qtdt	�
���dS)z4Try to execute an editor to edit the commit message.Nz2Could not start editor "%s" (specified by %s): %s
rT�ztCould not start any editor.
Please specify one with:
 - $BRZ_EDITOR
 - editor=/some/path in %s
 - $VISUAL
 - $EDITOR)r r�splitr�OSErrorr	�warning�strrrr)�filename�	candidateZcandidate_sourceZedargs�xrrrr�_run_editorHs*
���r)z%(bar)s %(msg)s %(bar)sz--------------z+This line and the following will be ignored)Zbar�msgcCs2|dur|�t���}|�t��d�}t|||�S)a�Let the user edit a commit message in a temp file.

    This is run if they don't give a message or
    message-containing file on the command line.

    :param infotext:    Text to be displayed at bottom of message
                        for the user's reference;
                        currently similar to 'bzr status'.

    :param ignoreline:  The separator to use above the infotext.

    :param start_message:   The text to place above the separator, if any.
                            This will not be removed from the message
                            after the user has edited it.

    :return:    commit message or None.
    N�replace)�encoder�get_user_encoding�edit_commit_message_encoded)�infotext�
ignoreline�
start_messagerrr�edit_commit_messagehsr2cCs
d}�z�t|||�\}}|slW|durhzt�|�Wn2tyf}zt�d||�WYd}~n
d}~00dSt�|�}t�	t�
|��}|�|�}t|�s�W|dur�zt�|�Wn2ty�}zt�d||�WYd}~n
d}~00dS|�|�}	|	|k�rbt
j�ddi��sbW|du�r^zt�|�Wn4t�y\}zt�d||�WYd}~n
d}~00dSd}
g}d\}}
tj|dt��d	���}zh|D]^}|��}|
�s�|dk�r�d
}
n�q�|�r�||k�r��q�|
d7}
|dk�r�|
}|�|��q�Wnt�y
t��Yn0Wd�n1�s"0Yt|�dk�r�W|du�r�zt�|�Wn4t�y�}zt�d||�WYd}~n
d}~00dS||d�=|d
�d��s
dd�|�dfW|du�rzt�|�WSt�y}zt�d||�WYd}~Sd}~00Sd�|�W|du�rbzt�|�WSt�y`}zt�d||�WYd}~Sd}~00SW|du�rzt�|�Wn4t�y�}zt�d||�WYd}~n
d}~00nP|du�rzt�|�Wn4t�y}zt�d||�WYd}~n
d}~000dS)a�Let the user edit a commit message in a temp file.

    This is run if they don't give a message or
    message-containing file on the command line.

    :param infotext:    Text to be displayed at bottom of message
                        for the user's reference;
                        currently similar to 'bzr status'.
                        The string is already encoded

    :param ignoreline:  The separator to use above the infotext.

    :param start_message:   The text to place above the separator, if any.
                            This will not be removed from the message
                            after the user has edited it.
                            The string is already encoded

    :return:    commit message or None.
    Nz failed to unlink %s: %s; ignoredz)Commit message was not edited, use anywayzbreezy.msgeditor.unchanged�F)rr�rb)�mode�encodingTrr����
z%s%s)�&_create_temp_file_with_commit_templater�unlink�IOErrorr	r$r�basenamer
Zget_transport_from_path�dirnameZ	get_bytesr)rZ
ui_factoryZconfirm_action�codecs�openr-�strip�append�UnicodeDecodeErrorr�len�endswith�join)r/r0r1�msgfilename�hasinforr<Z
msg_transportZreference_contentZedited_contentZstartedr*ZlastlineZnlines�f�lineZ
stripped_linerrrr.�s��5��
�
/��

�%
��

,

��

��

��
��
�r.c
Cs�ddl}|jd|dd�\}}t�|d��`}|dur@|�d|�|durv|dkrvd}d	|�t���|f}	|�|	�nd
}Wd�n1s�0Y||fS)aCreate temp file and write commit template in it.

    :param infotext: Text to be displayed at bottom of message for the
        user's reference; currently similar to 'bzr status'.  The text is
        already encoded.

    :param ignoreline:  The separator to use above the infotext.

    :param start_message: The text to place above the separator, if any.
        This will not be removed from the message after the user has edited
        it.  The string is already encoded

    :return:    2-tuple (temp file name, hasinfo)
    rNzbzr_log.T)�prefix�dir�text�wbs%s
r3s

%s

%sF)�tempfileZmkstempr�fdopen�writer,rr-)
r/r0r1ZtmpdirrNZ
tmp_filenorFZmsgfilerGZtrailerrrrr9�s�
�"r9cCs*ddlm}t�}||||dd�|��S)zoPrepare a template file for a commit into a branch.

    Returns a unicode string containing the template.
    r)�show_tree_statusT)�specific_filesZto_file�verbose)ZstatusrQr�getvalue)�working_treerRrQZ
status_tmprrr�make_commit_message_template�s
�rV�utf-8cCsVddlm}t||�}|�|d�}|rRt�}||��||||d�|d|��}|S)zXPrepare a template file for a commit into a branch.

    Returns an encoded string.
    r)�show_diff_treesr+)Z
path_encoding�
)�diffrXrVr,rZ
basis_treerT)rUrRrZZoutput_encodingrX�template�streamrrr�$make_commit_message_template_encodeds
�r]c@seZdZdZdd�ZdS)�MessageEditorHooksz�A dictionary mapping hook name to a list of callables for message editor
    hooks.

    e.g. ['commit_message_template'] is the list of items to be called to
    generate a commit message template
    cCs.t�|dd�|�ddd�|�ddd�d	S)
zJCreate the default hooks.

        These are all empty initially.
        zbreezy.msgeditor�hooks�set_commit_messagea4Set a fixed commit message. set_commit_message is called with the breezy.commit.Commit object (so you can also change e.g. revision properties by editing commit.builder._revprops) and the message so far. set_commit_message must return the message to use or None if it should use the message editor as normal.)���commit_message_templatea�Called when a commit message is being generated. commit_message_template is called with the breezy.commit.Commit object and the message that is known so far. commit_message_template must return a new message to use (which could be the same as it was given). When there are multiple hooks registered for commit_message_template, they are chained with the result from the first passed into the second, and so on.)r�
N)r
�__init__Zadd_hook)�selfrrrre0s�	�zMessageEditorHooks.__init__N)rrr�__doc__rerrrrr^(sr^cCs d}tdD]}|||�}q|S)z�Sets the commit message.
    :param commit: Commit object for the active commit.
    :return: The commit message or None to continue using the message editor
    Nr`�r_�Zcommitr1�hookrrrr`Nsr`cCs d}tdD]}|||�}q|S)z�Generate a commit message template.

    :param commit: Commit object for the active commit.
    :param start_message: Message to start with.
    :return: A start commit message or None for an empty start commit message.
    Nrcrhrirrr� generate_commit_message_templateYsrk)NrW)N)N)#rgZ
__future__rr>r�
subprocessrrr3rrrrr	r
r�errorsrr_r
Zsixishrrrr r)ZDEFAULT_IGNORE_LINEr2r.r9rVr]r^r`rkrrrr�<module>s@$	��
�
X�
$�
#