§
    cÌcê2  ã                   ó(  — d Z ddlZddlmZmZ ddlZddlmZ ddlZddl	m
Z
mZmZmZmZmZmZ ddlmZ ddlmZ  G d	„ d
e¦  «        Zd„ Zd„ Zddddœz  Zedfd„Zedfd„Zeddfd„Zd„ Z	 dd„Z G d„ de¦  «        Z e¦   «         Zdd„Zdd„Z dS )zCommit message editor support.é    N)ÚBytesIOÚStringIO)Úcallé   )ÚbeddingÚcmdlineÚconfigÚosutilsÚtraceÚ	transportÚui)ÚBzrError)ÚHooksc                   ó   — e Zd ZdZdS )ÚBadCommitMessageEncodingzUThe specified commit message contains characters unsupported by the current encoding.N)Ú__name__Ú
__module__Ú__qualname__Ú_fmt© ó    ú2/usr/lib/python3/dist-packages/breezy/msgeditor.pyr   r   )   s   € € € € € ð €D€D€Dr   r   c               #   ó€  K  — 	 t           j        d         dfV — n# t          $ r Y nw xY wt          j        ¦   «                              d¦  «        } | �| t          j        ¦   «         fV — dD ])}|t           j        v rt           j        |         d|z   fV — Œ*t          j	        dk    rdD ]}|dfV — Œ	dS d	D ]}|dfV — Œ	dS )
zDReturn sequence of possible editor binaries for the current platformÚ
BRZ_EDITORz$BRZ_EDITORÚeditorN)ÚVISUALÚEDITORú$Úwin32)zwordpad.exeznotepad.exe)z/usr/bin/editorÚviÚpicoÚnanoÚjoe)
ÚosÚenvironÚKeyErrorr	   ÚGlobalStackÚgetr   Úconfig_pathÚsysÚplatform)ÚeÚvarnamer   s      r   Ú_get_editorr.   /   s$  è è € ðÝŒj˜Ô&¨Ð5Ð5Ð5Ð5Ð5øÝð ð ð Øˆðøøøõ 	ÔÑÔ× Ò  Ñ*Ô*€AØ€}Ø•Ô$Ñ&Ô&Ð&Ð&Ð&Ð&à%ð 5ð 5ˆØ•b”jÐ Ð Ý”*˜WÔ% s¨W¡}Ð4Ð4Ð4Ð4øå
„|�wÒÐØ2ð 	ð 	ˆFØ˜$�,ÐÐÐÐð	ð 	ð Gð 	ð 	ˆFØ˜$�,ÐÐÐÐð	ð 	s   „ ›
(§(c                 ój  — t          ¦   «         D ]‚\  }}t          j        |¦  «        }	 t          || gz   ¦  «        }nD# t          $ r7}|�+t          j        d|›d|›dt          |¦  «        ›d�¦  «         Y d}~Œjd}~ww xY w|dk    r dS |dk    rŒ‚ t          d	t          j
        ¦   «         z  ¦  «        ‚)
z4Try to execute an editor to edit the commit message.NzCould not start editor "z" (specified by z): ú
r   Té   ztCould not start any editor.
Please specify one with:
 - $BRZ_EDITOR
 - editor=/some/path in %s
 - $VISUAL
 - $EDITOR)r.   r   Úsplitr   ÚOSErrorr   ÚwarningÚstrr   r   r)   )ÚfilenameÚ	candidateÚcandidate_sourceÚedargsÚxr,   s         r   Ú_run_editorr;   F   sû   € å'2¡}¤}ð ð Ñ#ˆ	Ð#Ý”˜yÑ)Ô)ˆð	Ý�V˜x˜jÑ(Ñ)Ô)ˆAˆAøÝð 		ð 		ð 		ØÐ+õ ”�à �y�yÐ"2Ð"2Ð"2µC¸±F´F°F°Fð<ñ=ô =ð =ð ˆHˆHˆHˆHøøøøð		øøøð �Š6ˆ6Ø�4�4Ø�#ŠXˆXØàÝ
ð ,õ Ô&Ñ(Ô(ñ)ñ *ô *ð *s   ©=½
A>Á-A9Á9A>z%(bar)s %(msg)s %(bar)sz--------------z+This line and the following will be ignored)ÚbarÚmsgc                 óÂ   — |�&|                      t          j        ¦   «         ¦  «        }|                       t          j        ¦   «         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_messages      r   Úedit_commit_messagerF   f   sT   € ð( Ð Ø%×,Ò,­WÔ-FÑ-HÔ-HÑIÔIˆØ�Š�wÔ8Ñ:Ô:¸IÑFÔF€HÝ& x°¸]ÑKÔKÐKr   c                 ó²  — d}	 t          | ||¦  «        \  }}|sJ	 |�E	 t          j        |¦  «         dS # t          $ r!}t	          j        d||¦  «         Y d}~dS d}~ww xY wdS t          j        |¦  «        }t          j	        t          j
        |¦  «        ¦  «        }|                     |¦  «        }t          |¦  «        sJ	 |�E	 t          j        |¦  «         dS # t          $ r!}t	          j        d||¦  «         Y d}~dS d}~ww xY wdS |                     |¦  «        }	|	|k    rkt          j                             ddi ¦  «        sJ	 |�E	 t          j        |¦  «         dS # t          $ r!}t	          j        d||¦  «         Y d}~dS d}~ww xY wdS d}
g }d\  }}t!          j        |dt          j        ¦   «         ¬	¦  «        5 }	 |D ]N}|                     ¦   «         }|
s
|dk    rd
}
nŒ"|r||k    r n#|dz  }|dk    r|}|                     |¦  «         ŒOn# t*          $ r t-          ¦   «         ‚w xY wddd¦  «         n# 1 swxY w Y   t/          |¦  «        dk    rJ	 |�E	 t          j        |¦  «         dS # t          $ r!}t	          j        d||¦  «         Y d}~dS d}~ww xY wdS ||d…= |d                              d¦  «        snd                     d                     |¦  «        d¦  «        |�C	 t          j        |¦  «         S # t          $ r }t	          j        d||¦  «         Y d}~S d}~ww xY wS d                     |¦  «        |�C	 t          j        |¦  «         S # t          $ r }t	          j        d||¦  «         Y d}~S d}~ww xY wS # |�C	 t          j        |¦  «         w # t          $ r }t	          j        d||¦  «         Y d}~w d}~ww xY ww xY w)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 anywayzbreezy.msgeditor.unchangedÚ F)r   r   Úrb)ÚmodeÚencodingTr   r   éÿÿÿÿr0   z{}{})Ú&_create_temp_file_with_commit_templater$   Úunlinkr3   r   r4   r
   Úbasenamer   Úget_transport_from_pathÚdirnameÚ	get_bytesr;   r   Ú
ui_factoryÚconfirm_actionÚcodecsÚopenrA   ÚstripÚappendÚUnicodeDecodeErrorr   ÚlenÚendswithÚformatÚjoin)rC   rD   rE   ÚmsgfilenameÚhasinfor,   rO   Úmsg_transportÚreference_contentÚedited_contentÚstartedr=   ÚlastlineÚnlinesÚfÚlineÚstripped_lines                    r   rB   rB   €   sK  € ð* €Kð>HÝEØ�j -ñ 1ô  1Ñˆ�Wàð 	Øðj Ð"ðHÝ”	˜+Ñ&Ô&Ð&Ð&Ð&øÝð Hð Hð HÝ”Ø6¸ÀQñHô Hð Hð Hð Hð Hð Hð Hð HøøøøðHøøøð #Ð"õi Ô# KÑ0Ô0ˆÝ!Ô9ÝŒO˜KÑ(Ô(ñ*ô *ˆà)×3Ò3°HÑ=Ô=ÐÝ˜;Ñ'Ô'ð 	Øð^ Ð"ðHÝ”	˜+Ñ&Ô&Ð&Ð&Ð&øÝð Hð Hð HÝ”Ø6¸ÀQñHô Hð Hð Hð Hð Hð Hð Hð HøøøøðHøøøð #Ð"ð] '×0Ò0°Ñ:Ô:ˆØÐ.Ò.Ð.Ý”=×/Ò/Ø;Ø,Øñô ð ð ðJ Ð"ðHÝ”	˜+Ñ&Ô&Ð&Ð&Ð&øÝð Hð Hð HÝ”Ø6¸ÀQñHô Hð Hð Hð Hð Hð Hð Hð HøøøøðHøøøð #Ð"ðI ˆØˆØÑˆ�&ÝŒ[˜¨4½'Ô:SÑ:UÔ:UÐVÑVÔVð 	1ÐZ[ð1Øð %ð %�DØ$(§J¢J¡L¤L�Mà"ð %Ø(¨BÒ.Ð.Ø&*˜G˜Gà$ð ð  =°JÒ#>Ð#>Ø˜Ø˜a‘K�Fà$¨Ò*Ð*Ø#)˜Ø—J’J˜tÑ$Ô$Ð$Ð$øøÝ%ð 1ð 1ð 1Ý.Ñ0Ô0Ð0ð1øøøð'	1ð 	1ð 	1ñ 	1ô 	1ð 	1ð 	1ð 	1ð 	1ð 	1ð 	1øøøð 	1ð 	1ð 	1ð 	1õ, ˆs‰8Œ8�qŠ=ˆ=Øð Ð"ðHÝ”	˜+Ñ&Ô&Ð&Ð&Ð&øÝð Hð Hð HÝ”Ø6¸ÀQñHô Hð Hð Hð Hð Hð Hð Hð HøøøøðHøøøð #Ð"ð ��	�	ˆNà�2Œw×Ò Ñ%Ô%ð 	 Ø—=’= §¢¨¡¤¨tÑ4Ô4ð
 Ð"ðHÝ”	˜+Ñ&Ô&Ð&Ð&øÝð Hð Hð HÝ”Ø6¸ÀQñHô Hð Hð Hð Hð Hð Hð HøøøøðHøøøð #ð —7’7˜3‘<”<ð Ð"ðHÝ”	˜+Ñ&Ô&Ð&Ð&øÝð Hð Hð HÝ”Ø6¸ÀQñHô Hð Hð Hð Hð Hð Hð HøøøøðHøøøð #øˆ;Ð"ðHÝ”	˜+Ñ&Ô&Ð&Ð&øÝð Hð Hð HÝ”Ø6¸ÀQñHô Hð Hð Hð Hð Hð Hð HøøøøðHøøøð #øøøs  „N ž4 ´
A¾AÁAÁ$AN ÃC Ã
DÃ&DÄDÄ<N ÅE" Å"
FÅ,FÆFÆ1N ÇH?ÇAHÈH?ÈH0È0H?È3N È?IÉN ÉIÉN É!I7 É7
J"ÊJÊJ"Ê'AN Ë2LÌ
L1ÌL,Ì,L1Ì5N ÍM!Í!
NÍ+NÎNÎOÎN(Î'OÎ(
OÎ2OÏOÏOÏOc                 óp  — ddl }|                     d|d¬¦  «        \  }}t          j        |d¦  «        5 }|�|                     d|z  ¦  «         | �I| dk    rCd}d	|                     t          j        ¦   «         ¦  «        | fz  }	|                     |	¦  «         nd
}ddd¦  «         n# 1 swxY w Y   ||fS )a  Create 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)
    r   Nzbzr_log.T)ÚprefixÚdirÚtextÚwbs   %s
rH   s   

%s

%sF)ÚtempfileÚmkstempr$   ÚfdopenÚwriter@   r
   rA   )
rC   rD   rE   Útmpdirrn   Ú
tmp_filenor^   Úmsgfiler_   Útrailers
             r   rM   rM   ×   s  € ð$ €O€O€OØ&×.Ò.°jØ39Àð /ñ Fô FÑ€J�å	Œ�:˜tÑ	$Ô	$ð 
¨ØÐ$Ø�MŠM˜' MÑ1Ñ2Ô2Ð2àÐ H°¢N NØˆGØ%Ø×!Ò!¥'Ô";Ñ"=Ô"=Ñ>Ô>Àð)Jñ JˆGà�MŠM˜'Ñ"Ô"Ð"Ð"àˆGð
ð 
ð 
ñ 
ô 
ð 
ð 
ð 
ð 
ð 
ð 
øøøð 
ð 
ð 
ð 
ð ˜Ð!Ð!s   µA(B)Â)B-Â0B-c                 óp   — ddl m} t          ¦   «         } || ||d¬¦  «         |                     ¦   «         S )zoPrepare a template file for a commit into a branch.

    Returns a unicode string containing the template.
    r   )Úshow_tree_statusT)Úspecific_filesÚto_fileÚverbose)Ústatusrw   r   Úgetvalue)Úworking_treerx   rw   Ú
status_tmps       r   Úmake_commit_message_templater   û   sT   € ð )Ð(Ð(Ð(Ð(Ð(Ý‘”€JØÐ�\°.Ø'°ð7ñ 7ô 7ð 7à×ÒÑ Ô Ð r   úutf-8c                 óö   — ddl m} t          | |¦  «        }|                     |d¦  «        }|rJt	          ¦   «         } ||                      ¦   «         | |||¬¦  «         |dz   |                     ¦   «         z   }|S )zXPrepare a template file for a commit into a branch.

    Returns an encoded string.
    r   )Úshow_diff_treesr?   )Úpath_encodingó   
)Údiffr‚   r   r@   r   Ú
basis_treer|   )r}   rx   r…   Úoutput_encodingr‚   ÚtemplateÚstreams          r   Ú$make_commit_message_template_encodedrŠ     sš   € ð &Ð%Ð%Ð%Ð%Ð%å+¨L¸.ÑIÔI€HØ�Š˜°	Ñ:Ô:€Hàð 8Ý‘”ˆØˆ˜×/Ò/Ñ1Ô1Ø$ f¨nØ&5ð	7ñ 	7ô 	7ð 	7ð ˜eÑ# f§o¢oÑ&7Ô&7Ñ7ˆà€Or   c                   ó   — e Zd ZdZd„ ZdS )Ú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
    c                 óŽ   — t          j        | dd¦  «         |                      ddd¦  «         |                      ddd¦  «         d	S )
zJCreate the default hooks.

        These are all empty initially.
        zbreezy.msgeditorÚhooksÚset_commit_messagea4  Set 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__Úadd_hook)Úselfs    r   r”   zMessageEditorHooks.__init__.  sl   € õ
 	Œ�tÐ/°Ñ9Ô9Ð9Ø�ŠØ ðIð ñ	ô 	ð 	ð 	�ŠØ%ðð ñ		ô 		ð 		ð 		ð 		r   N)r   r   r   Ú__doc__r”   r   r   r   rŒ   rŒ   &  s-   € € € € € ðð ðð ð ð ð r   rŒ   c                 óB   — d}t           d         D ]} || |¦  «        }Œ|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Ž   ©ÚcommitrE   Úhooks      r   r�   r�   L  s7   € ð
 €MÝÐ*Ô+ð 4ð 4ˆØ˜˜V ]Ñ3Ô3ˆˆØÐr   c                 óB   — d}t           d         D ]} || |¦  «        }Œ|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.
    Nr’   r™   rš   s      r   Ú generate_commit_message_templaterž   W  s7   € ð €MÝÐ/Ô0ð 4ð 4ˆØ˜˜V ]Ñ3Ô3ˆˆØÐr   )Nr€   )N)!r—   rU   Úior   r   r$   Ú
subprocessr   r*   rH   r   r   r	   r
   r   r   r   Úerrorsr   rŽ   r   r   r.   r;   ÚDEFAULT_IGNORE_LINErF   rB   rM   r   rŠ   rŒ   r�   rž   r   r   r   ú<module>r£      sE  ðð" %Ð $à €€€ðð ð ð ð ð ð ð ð 
€	€	€	Ø Ð Ð Ð Ð Ð Ø 
€
€
€
ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð ð ð  ð  ð  ð  ˜xñ  ô  ð  ðð ð ð.*ð *ð *ð8 0ØÐJÐKÐKñLÐ ð .AØ&*ðLð Lð Lð Lð4 6IØ.2ðTHð THð THð THðp 7JØ9=Ø26ð!"ð !"ð !"ð !"ðH!ð !ð !ð$ ELðð ð ð ð4 ð  ð  ð  ð  ˜ñ  ô  ð  ðF 	ÐÑÔ€ðð ð ð ð
ð 
ð 
ð 
ð 
ð 
r   