§
    cÌcqn  ã                   óî  — d dl Z d dlZd dlmZ d dlZddlmZ  ej         e¦   «         d¦  «         ddlmZm	Z	m
Z
  G d„ dej        ¦  «        Z G d	„ d
¦  «        Z G d„ de	j        ¦  «        Z G d„ d¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de
j        ¦  «        Z e¦   «         Ze                     e¦  «         e                     e¦  «         e                     ed¦  «         dS )é    N)ÚBytesIOé   )Úlazy_importa  
from breezy import (
    branch as _mod_branch,
    diff,
    email_message,
    gpg,
    revision as _mod_revision,
    timestamp,
    trace,
    )
from breezy.bzr import (
    rio,
    testament,
    )
from breezy.bzr.bundle import (
    serializer as bundle_serializer,
    )
)ÚerrorsÚhooksÚregistryc                   ó   — e Zd ZdZdZd„ ZdS )ÚIllegalMergeDirectivePayloadzBA merge directive contained something other than a patch or bundlez%Bad merge directive payload %(start)rc                 ó<   — t          j        | ¦  «         || _        d S ©N)r   ÚBzrErrorÚstart)Úselfr   s     ú8/usr/lib/python3/dist-packages/breezy/merge_directive.pyÚ__init__z%IllegalMergeDirectivePayload.__init__5   s   € ÝŒ˜ÑÔÐØˆŒ
ˆ
ˆ
ó    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú_fmtr   © r   r   r
   r
   0   s.   € € € € € ØLÐLà2€Dðð ð ð ð r   r
   c                   ó   — e Zd ZdZ	 dd„ZdS )ÚMergeRequestBodyParamsz1Parameter object for the merge_request_body hook.Nc	                 óv   — || _         || _        || _        || _        || _        || _        || _        || _        d S r   )ÚbodyÚ	orig_bodyÚ	directiveÚbranchÚtreeÚtoÚbasenameÚsubject)	r   r   r   r   r!   r"   r#   r   r    s	            r   r   zMergeRequestBodyParams.__init__=   s>   € àˆŒ	Ø"ˆŒØ"ˆŒØˆŒØˆŒ	ØˆŒØ ˆŒØˆŒˆˆr   r   ©r   r   r   r   r   r   r   r   r   r   :   s3   € € € € € Ø;Ð;ð #ð	ð 	ð 	ð 	ð 	ð 	r   r   c                   ó   — e Zd ZdZd„ ZdS )ÚMergeDirectiveHooksz!Hooks for MergeDirective classes.c                 óv   — t           j                             | dd¦  «         |                      ddd¦  «         d S )Nzbreezy.merge_directivezBaseMergeDirective.hooksÚmerge_request_bodyzÌCalled with a MergeRequestBodyParams when a body is needed for a merge request.  Callbacks must return a body.  If more than one callback is registered, the output of one callback is provided to the next.)r   é   r   )r   ÚHooksr   Úadd_hook©r   s    r   r   zMergeDirectiveHooks.__init__L   sQ   € ÝŒ×Ò˜TÐ#;Ø7ñ	9ô 	9ð 	9à�ŠØ ð%ð '1ñ	2ô 	2ð 	2ð 	2ð 	2r   Nr$   r   r   r   r&   r&   I   s)   € € € € € Ø+Ð+ð2ð 2ð 2ð 2ð 2r   r&   c                   óÀ   — e Zd ZdZ e¦   «         ZdZ	 	 dd„Zd„ Zd„ Z	d„ Z
dd„Zd	„ Ze	 	 dd„¦   «         Zd„ Zed„ ¦   «         Zed„ ¦   «         Zd„ Zdd„Zd„ Zdd„ZdS )ÚBaseMergeDirectivea  A request to perform a merge into a branch.

    This is the base class that all merge directive implementations
    should derive from.

    :cvar multiple_output_files: Whether or not this merge directive
        stores a set of revisions in more than one file
    FNc
                 óv   — || _         || _        || _        || _        || _        || _        || _        || _        dS )a  Constructor.

        :param revision_id: The revision to merge
        :param testament_sha1: The sha1 of the testament of the revision to
            merge.
        :param time: The current POSIX timestamp time
        :param timezone: The timezone offset
        :param target_branch: Location of branch to apply the merge to
        :param patch: The text of a diff or bundle
        :param source_branch: A public location to merge the revision from
        :param message: The message to use when committing this merge
        N)Úrevision_idÚtestament_sha1ÚtimeÚtimezoneÚtarget_branchÚpatchÚsource_branchÚmessage)
r   r0   r1   r2   r3   r4   r5   r6   r7   Úbundles
             r   r   zBaseMergeDirective.__init__e   sD   € ð 'ˆÔØ,ˆÔØˆŒ	Ø ˆŒØ*ˆÔØˆŒ
Ø*ˆÔØˆŒˆˆr   c                 ó*   — t          | j        ¦  «        ‚)úGSerialize as a list of lines

        :return: a list of lines
        )ÚNotImplementedErrorÚto_linesr,   s    r   r<   zBaseMergeDirective.to_lines}   ó   € õ
 " $¤-Ñ0Ô0Ð0r   c                 ó*   — t          | j        ¦  «        ‚)zjSerialize as a set of files.

        :return: List of tuples with filename and contents as lines
        )r;   Úto_filesr,   s    r   r?   zBaseMergeDirective.to_files„   r=   r   c                 ó   — dS )zpReturn the bundle for this merge directive.

        :return: bundle text or None if there is no bundle
        Nr   r,   s    r   Úget_raw_bundlez!BaseMergeDirective.get_raw_bundle‹   s	   € ð
 ˆtr   c                 óê  — t                                | j        | j        ¦  «        }t                               | j        || j        | j        ¬¦  «        }dD ]0}| j	        |         �!| 
                    || j	        |         ¦  «         Œ1|r| 
                    d| j        ¦  «         d| j        z   dz   g}|                     t                               |¦  «        ¦  «         |                     d¦  «         |S )r:   )r0   Ú	timestampr4   r1   )r6   r7   NÚbase_revision_ids   # ó   
s   # 
)rC   Úformat_patch_dater2   r3   ÚrioÚStanzar0   r4   r1   Ú__dict__ÚaddrD   Ú_format_stringÚextendÚto_patch_linesÚappend)r   Úbase_revisionÚtime_strÚstanzaÚkeyÚliness         r   Ú	_to_lineszBaseMergeDirective._to_lines’   sñ   € õ
 ×.Ò.¨t¬y¸$¼-ÑHÔHˆÝ—’¨Ô(8ÀHØ*.Ô*<Ø+/Ô+>ð ñ @ô @ˆð 0ð 	4ð 	4ˆCØŒ}˜SÔ!Ð-Ø—
’
˜3 ¤¨cÔ 2Ñ3Ô3Ð3øØð 	BØ�JŠJÐ)¨4Ô+@ÑAÔAÐAØ˜Ô,Ñ,¨uÑ4Ð5ˆØ�Š•S×'Ò'¨Ñ/Ô/Ñ0Ô0Ð0Ø�Š�WÑÔÐØˆr   c                 ó*   — t          | j        ¦  «        ‚)zzWrite this merge directive to a series of files in a directory.

        :param path: Filesystem path to write to
        )r;   Úwrite_to_directory)r   Úpaths     r   rV   z%BaseMergeDirective.write_to_directory¥   s   € õ
 " $Ô"9Ñ:Ô:Ð:r   r8   c
                 óü  — |}
|t           j        k    rd}
t          j                             ||
¦  «        }|€ t
          j                             |¦  «        }n|}|                     ¦   «         �|                     ¦   «         }|€d}n}| 	                    ¦   «         }| 
                    |j        |¦  «         |                     ¦   «         }|                     ||¦  «        }| j        | j        d„ dœ} ||         |||¦  «        }|�T|dk    rNt
          j                             |¦  «        }|j                             |¦  «        st#          j        ||¦  «        ‚ | ||                     ¦   «         |||||||	¦	  «	        S )a  Generate a merge directive from various objects

        :param repository: The repository containing the revision
        :param revision_id: The revision to merge
        :param time: The POSIX timestamp of the date the request was issued.
        :param timezone: The timezone of the request
        :param target_branch: The url of the branch to merge into
        :param patch_type: 'bundle', 'diff' or None, depending on the type of
            patch desired.
        :param local_target_branch: the submit branch, either itself or a local copy
        :param public_branch: location of a public branch containing
            the target revision.
        :param message: Message to use when committing the merge
        :return: The merge directive

        The public branch is always used if supplied.  If the patch_type is
        not 'bundle', the public branch must be supplied, and will be verified.

        If the message is not supplied, the message from revision_id will be
        used for the commit.
        Nc                 ó   — d S r   r   )ÚxÚyÚzs      r   ú<lambda>z1BaseMergeDirective.from_objects.<locals>.<lambda>Ù   s   € °$€ r   )r8   ÚdiffNr8   )Ú_mod_revisionÚNULL_REVISIONÚ	testamentÚStrictTestament3Úfrom_revisionÚ_mod_branchÚBranchÚopenÚget_public_branchÚlast_revisionÚfetchÚ
repositoryÚ	get_graphÚfind_unique_lcaÚ_generate_bundleÚ_generate_diffÚhas_revisionr   ÚPublicBranchOutOfDateÚas_sha1)Úklassrj   r0   r2   r3   r4   Ú
patch_typeÚlocal_target_branchÚpublic_branchr7   Út_revision_idÚtÚsubmit_branchr5   Úsubmit_revision_idÚgraphÚancestor_idÚtype_handlerÚpublic_branch_objs                      r   Úfrom_objectszBaseMergeDirective.from_objects¬   s±  € ð2 $ˆØ�-Ô5Ò5Ð5Ø ˆMÝÔ&×4Ò4°ZÀÑOÔOˆØÐ&Ý'Ô.×3Ò3°MÑBÔBˆMˆMà/ˆMØ×*Ò*Ñ,Ô,Ð8Ø)×;Ò;Ñ=Ô=ˆMØÐØˆEˆEà!.×!<Ò!<Ñ!>Ô!>ÐØ×Ò˜]Ô5Ð7IÑJÔJÐJØ×(Ò(Ñ*Ô*ˆEØ×/Ò/°Ø0BñDô DˆKà&+Ô&<Ø$)Ô$8Ø"6Ð"6ð8ð 8ˆLð -�L Ô,¨Z¸Ø-8ñ:ô :ˆEð Ð$¨°xÒ)?Ð)?Ý +Ô 2× 7Ò 7¸Ñ FÔ FÐØ$Ô/×<Ò<¸[ÑIÔIð @ÝÔ2°=Ø3>ñ@ô @ð @ð ˆu�[ !§)¢)¡+¤+¨t°X¸}Ø˜J¨°wñ@ô @ð 	@r   c                 óx  — |                      ¦   «         \  }}| j        |k    r|g}n4	 |                     | j        ¦  «        }n# t          j        $ r dg}Y nw xY wt          j        dd|j        ¦  «                             d¦  «        }d 	                    |d 
                    d„ |D ¦   «         ¦  «        ¦  «        S )z¬Generate a suitable basename for storing this directive on disk

        :param branch: The Branch this merge directive was generated fro
        :return: A string
        Úmergez(\W+)ú-z{}-{}ú.c              3   ó4   K  — | ]}t          |¦  «        V — Œd S r   )Ústr)Ú.0Úns     r   ú	<genexpr>z3BaseMergeDirective.get_disk_name.<locals>.<genexpr>õ   s(   è è € Ð,CÐ,C¸­S°©V¬VÐ,CÐ,CÐ,CÐ,CÐ,CÐ,Cr   )Úlast_revision_infor0   Úrevision_id_to_dotted_revnor   ÚNoSuchRevisionÚreÚsubÚnickÚstripÚformatÚjoin)r   r   Úrevnor0   r�   s        r   Úget_disk_namez BaseMergeDirective.get_disk_nameæ   sÉ   € ð $×6Ò6Ñ8Ô8Ñˆˆ{ØÔ˜{Ò*Ð*Ø�GˆEˆEð"Ø×:Ò:¸4Ô;KÑLÔL��øÝÔ(ð "ð "ð "Ø ˜	���ð"øøøåŒv�h  V¤[Ñ1Ô1×7Ò7¸Ñ<Ô<ˆØ�~Š~˜d C§H¢HÐ,CÐ,C¸UÐ,CÑ,CÔ,CÑ$CÔ$CÑDÔDÐDs   ¨A ÁAÁAc                 óØ   — |                       |¦  «        }|                       |¦  «        }t          ¦   «         }t                               |||dd¬¦  «         |                     ¦   «         S )NÚ )Ú	old_labelÚ	new_label)Úrevision_treer   r^   Úshow_diff_treesÚgetvalue)rj   r0   r{   Útree_1Útree_2Úss         r   rn   z!BaseMergeDirective._generate_diff÷   s^   € à×)Ò)¨+Ñ6Ô6ˆØ×)Ò)¨+Ñ6Ô6ˆÝ‰IŒIˆÝ×Ò˜V V¨Q¸"ÈÐÑKÔKÐKØ�zŠz‰|Œ|Ðr   c                 ó€   — t          ¦   «         }t                               | |||¦  «         |                     ¦   «         S r   ©r   Úbundle_serializerÚwrite_bundler™   ©rj   r0   r{   rœ   s       r   rm   z#BaseMergeDirective._generate_bundleÿ   s:   € å‰IŒIˆÝ×&Ò& z°;Ø'2°Añ	7ô 	7ð 	7à�zŠz‰|Œ|Ðr   c                 óä   — t                                |                     ¦   «         ¦  «        }|                     d                     |                      ¦   «         ¦  «        t           j        ¦  «        S )z‡Serialize as a signed string.

        :param branch: The source branch, to get the signing strategy
        :return: a string
        r   )ÚgpgÚGPGStrategyÚget_config_stackÚsignr�   r<   Ú
MODE_CLEAR)r   r   Úmy_gpgs      r   Ú	to_signedzBaseMergeDirective.to_signed  sK   € õ —’ ×!8Ò!8Ñ!:Ô!:Ñ;Ô;ˆØ�{Š{˜3Ÿ8š8 D§M¢M¡O¤OÑ4Ô4µc´nÑEÔEÐEr   c                 óv  — |                      ¦   «                              d¦  «        }| j        �| j        }n&|j                             | j        ¦  «        }|j        }|r|                      |¦  «        }n'd                     |                      ¦   «         ¦  «        }t           
                    ||||¦  «        }|S )a!  Serialize as an email message.

        :param mail_to: The address to mail the message to
        :param branch: The source branch, to get the signing strategy and
            source email address
        :param sign: If True, gpg-sign the email
        :return: an email message
        ÚemailNr   )r¥   Úgetr7   rj   Úget_revisionr0   r©   r�   r<   Úemail_messageÚEmailMessage)	r   Úmail_tor   r¦   Ú	mail_fromr#   Úrevisionr   r7   s	            r   Úto_emailzBaseMergeDirective.to_email  s¬   € ð ×+Ò+Ñ-Ô-×1Ò1°'Ñ:Ô:ˆ	ØŒ<Ð#Ø”lˆGˆGàÔ(×5Ò5°dÔ6FÑGÔGˆHØÔ&ˆGØð 	-Ø—>’> &Ñ)Ô)ˆDˆDà—8’8˜DŸMšM™OœOÑ,Ô,ˆDÝ×,Ò,¨Y¸ÀØ-1ñ3ô 3ˆàˆr   c                 ó  — |                      | j        ¦  «        �sè| j        dk    �r˜t                               t          |                      ¦   «         ¦  «        ¦  «        }	 |                     |d¬¦  «         �n‰# t          j	        $ �r2 	 t          j                             | j        ¦  «        }n,# t          j        $ r t          j        | j        ¦  «        ‚w xY wg }d„ |j        D ¦   «         }|j        D ]:}|j        D ]0}||vr*|                      |¦  «        s|                     |¦  «         Œ1Œ;g }t'          ¦   «         }	t)          |¦  «        D ]1}||	v rŒ|                     |¦  «         |	                     |¦  «         Œ2|D ]}
|                     |j        |
¦  «         Œ|                     |d¬¦  «         Y nHw xY wt          j                             | j        ¦  «        }|                     |j        | j        ¦  «         | j        S )z0Install revisions and return the target revisionr8   F)Ústream_inputc                 ó   — h | ]	}|j         ’Œ
S r   ©r0   )r…   Úrs     r   ú	<setcomp>z7BaseMergeDirective.install_revisions.<locals>.<setcomp>9  s,   € ð (@ð (@ð (@¸!¨¬ð (@ð (@ð (@r   )ro   r0   rs   rŸ   Úread_bundler   rA   Úinstall_revisionsr   ÚRevisionNotPresentrd   re   rf   r4   ÚNotBranchErrorÚTargetNotBranchÚreal_revisionsÚ
parent_idsrN   ÚsetÚreversedrJ   ri   rj   r6   )r   Útarget_repoÚinforx   Úmissing_revisionsÚbundle_revisionsr²   Ú	parent_idÚunique_missingÚunique_missing_setÚmissing_revisionr6   s               r   r»   z$BaseMergeDirective.install_revisions&  s}  € à×'Ò'¨Ô(8Ñ9Ô9ñ &	NØŒ (Ò*Ñ*Ý(×4Ò4Ý˜D×/Ò/Ñ1Ô1Ñ2Ô2ñ4ô 4�ðLØ×*Ò*¨;ÀUÐ*ÑKÔKÐKÑKøÝÔ0ð Lñ Lð LðIå'Ô.×3Ò3°DÔ4FÑGÔGð &˜øå!Ô0ð Ið Ið IÝ$Ô4°TÔ5GÑHÔHÐHðIøøøà(*Ð%ð(@ð (@Ø+/Ô+>ð(@ñ (@ô (@Ð$à$(Ô$7ð Dð D˜Ø)1Ô)<ð Dð D˜IØ )Ð1AÐ AÐ AØ,7×,DÒ,DÀYÑ,OÔ,Oð !Bà 1× 8Ò 8¸Ñ CÔ CÐ CøðDð
 &(�NÝ),©¬Ð&Ý$,Ð->Ñ$?Ô$?ð 9ð 9˜Ø#Ð'9Ð9Ð9Ø$Ø&×-Ò-¨hÑ7Ô7Ð7Ø*×.Ò.¨xÑ8Ô8Ð8Ð8Ø,:ð <ð <Ð(Ø#×)Ò)¨-Ô*BØ*:ñ<ô <ð <ð <à×*Ò*¨;ÀUÐ*ÑKÔKÐKÐKÐKð7Løøøõ: !,Ô 2× 7Ò 7¸Ô8JÑ KÔ K�Ø×!Ò! -Ô":¸DÔ<LÑMÔMÐMØÔÐs+   Á"A; Á;F=Â$B1Â0F=Â1)CÃC F=Æ<F=c                 óP  — |                       |¦  «        }d}| j        �|| j        z  }n6|j                             | j        ¦  «        }||                     ¦   «         z  }t          |dd¦  «        r4|}	| j        d         D ]#}
t          ||	| |||||¦  «        } |
|¦  «        }Œ$nCt          | j        d         ¦  «        dk    r%t                               d|j        j        ¦  «         |                     ||d                     |                      ¦   «         ¦  «        ||¦  «         dS )	aj  Compose a request to merge this directive.

        :param mail_client: The mail client to use for composing this request.
        :param to: The address to compose the request to.
        :param branch: The Branch that was used to produce this directive.
        :param tree: The Tree (if any) for the Branch used to produce this
            directive.
        z[MERGE] NÚsupports_bodyFr(   r   z[Cannot run merge_request_body hooks because mail client %s does not support message bodies.r   )r’   r7   rj   r­   r0   Úget_summaryÚgetattrr   r   ÚlenÚtraceÚwarningÚ	__class__r   Úcompose_merge_requestr�   r<   )r   Úmail_clientr!   r   r   r    r"   r#   r²   r   ÚhookÚparamss               r   rÓ   z(BaseMergeDirective.compose_merge_requestQ  sN  € ð ×%Ò% fÑ-Ô-ˆØˆØŒ<Ð#Ø�t”|Ñ#ˆGˆGàÔ(×5Ò5°dÔ6FÑGÔGˆHØ�x×+Ò+Ñ-Ô-Ñ-ˆGÝ�; °Ñ7Ô7ð 
	:ØˆIØœ
Ð#7Ô8ð $ð $�Ý/°°iÀØ02°H¸gÀvØ04ñ6ô 6�ð �t˜F‘|”|��ð	$õ
 �”Ð0Ô1Ñ2Ô2°QÒ6Ð6Ý�MŠMð Hà%Ô/Ô8ñ:ô :ð :ð 	×)Ò)¨"¨gØ*-¯(ª(°4·=²=±?´?Ñ*CÔ*CØ*2°Dñ	:ô 	:ð 	:ð 	:ð 	:r   )NNNN)F)r8   NNNr   )r   r   r   r   r&   r   Úmultiple_output_filesr   r<   r?   rA   rT   rV   Úclassmethodr~   r’   Ústaticmethodrn   rm   r©   r³   r»   rÓ   r   r   r   r.   r.   W   s]  € € € € € ðð ð  ÐÑ!Ô!€Eà!Ðð ;?Ø&*ðð ð ð ð01ð 1ð 1ð1ð 1ð 1ðð ð ðð ð ð ð&;ð ;ð ;ð à/7ØKOð7@ð 7@ð 7@ñ „[ð7@ðrEð Eð Eð" ðð ñ „\ðð ðð ñ „\ððFð Fð Fðð ð ð ð.) ð ) ð ) ðV:ð :ð :ð :ð :ð :r   r.   c                   ó˜   — e Zd ZdZdZ	 	 dd„Zd„ Zd„ Zd„ Z e	e¦  «        Z
ed„ ¦   «         Zed	„ ¦   «         Zd
„ Zed„ ¦   «         Zd„ ZdS )ÚMergeDirectivea%  A request to perform a merge into a branch.

    Designed to be serialized and mailed.  It provides all the information
    needed to perform a merge automatically, by providing at minimum a revision
    bundle or the location of a branch.

    The serialization format is robust against certain common forms of
    deterioration caused by mailing.

    The format is also designed to be patch-compatible.  If the directive
    includes a diff or revision bundle, it should be possible to apply it
    directly using the standard patch program.
    s   Bazaar merge directive format 1Nc                 óä   — t                                | ||||||||	¦	  «	         |dvrt          |¦  «        ‚|dk    r|€t          j        ¦   «         ‚|�|€t          j        |¦  «        ‚|| _        dS )a}  Constructor.

        :param revision_id: The revision to merge
        :param testament_sha1: The sha1 of the testament of the revision to
            merge.
        :param time: The current POSIX timestamp time
        :param timezone: The timezone offset
        :param target_branch: Location of the branch to apply the merge to
        :param patch: The text of a diff or bundle
        :param patch_type: None, "diff" or "bundle", depending on the contents
            of patch
        :param source_branch: A public location to merge the revision from
        :param message: The message to use when committing this merge
        )Nr^   r8   r8   N)r.   r   Ú
ValueErrorr   ÚNoMergeSourceÚPatchMissingrs   )r   r0   r1   r2   r3   r4   r5   rs   r6   r7   r8   s              r   r   zMergeDirective.__init__ƒ  s’   € õ" 	×#Ò# D¨+°~ÀtØ$,¨m¸UÀMÐSZñ	\ô 	\ð 	\àÐ5Ð5Ð5Ý˜ZÑ(Ô(Ð(Ø˜Ò!Ð! mÐ&;ÝÔ&Ñ(Ô(Ð(ØÐ! e mÝÔ% jÑ1Ô1Ð1Ø$ˆŒˆˆr   c                 ó"   — d | _         d | _        d S r   )r5   rs   r,   s    r   Úclear_payloadzMergeDirective.clear_payloadž  s   € ØˆŒ
ØˆŒˆˆr   c                 ó   — | j         S r   )r8   r,   s    r   rA   zMergeDirective.get_raw_bundle¢  s
   € ØŒ{Ðr   c                 ó*   — | j         dk    r| j        S d S )Nr8   )rs   r5   r,   s    r   Ú_bundlezMergeDirective._bundle¥  s   € ØŒ?˜hÒ&Ð&Ø”:Ðà�4r   c                 ó>  — t          |¦  «        }d}|D ]v}|                     d¦  «        rIt                               |dd…                              ¦   «         ¦  «                             |¦  «        c S |p|                     ¦   «         }Œwt          j        |¦  «        ‚)z‰Deserialize a MergeRequest from an iterable of lines

        :param lines: An iterable of lines
        :return: a MergeRequest
        r   s    # Bazaar merge directive format é   N)	ÚiterÚ
startswithÚ_format_registryr¬   ÚrstripÚ_from_linesrŽ   r   ÚNotAMergeDirective)rr   rS   Ú	line_iterÚ	firstlineÚlines        r   Ú
from_lineszMergeDirective.from_lines­  s¢   € õ ˜‘K”Kˆ	Øˆ	Øð 	2ð 	2ˆDØ�ŠÐBÑCÔCð Ý'×+Ò+¨D°°°¬H¯OªOÑ,=Ô,=Ñ>Ô>×JÒJØñô ð ð ð à!Ð1 T§Z¢Z¡\¤\ˆIˆIÝÔ'¨	Ñ2Ô2Ð2r   c                 óÂ  — t                                |¦  «        }t          |¦  «        }t          |¦  «        dk    rd }d }nnd                     |¦  «        }	 t
                               t          |¦  «        ¦  «         d}n.# t          j	        t          j
        t          j        f$ r d}Y nw xY wt                               |                     d¦  «        ¦  «        \  }}i }dD ]+}		 |                     |	¦  «        ||	<   Œ# t          $ r Y Œ(w xY w|d                              d¦  «        |d<   d	|v r|d	                              d
¦  «        |d	<   t#          d||||dœ|¤ŽS )Nr   r   r8   r^   rC   )r0   r1   r4   r6   r7   r0   úutf-8r1   Úascii)r2   r3   rs   r5   r   )rG   Úread_patch_stanzaÚlistrÏ   r�   rŸ   rº   r   r   Ú
NotABundleÚBundleNotSupportedÚ	BadBundlerC   Úparse_patch_dater¬   ÚKeyErrorÚencoderÛ   )
rr   rí   rQ   Úpatch_linesr5   rs   r2   r3   ÚkwargsrR   s
             r   rë   zMergeDirective._from_lines½  s   € å×&Ò& yÑ1Ô1ˆÝ˜9‘o”oˆÝˆ{ÑÔ˜qÒ Ð ØˆEØˆJˆJà—H’H˜[Ñ)Ô)ˆEð&Ý!×-Ò-­g°e©n¬nÑ=Ô=Ð=ð
 &�
�
øõ	 Ô%¥vÔ'@ÝÔ$ð&ð $ð $ð $à#�
�
�
ð$øøøõ
 #×3Ò3°F·J²J¸{Ñ4KÔ4KÑLÔL‰ˆˆhØˆð0ð 	ð 	ˆCðØ$Ÿjšj¨™oœo��s‘�øÝð ð ð Ø�ðøøøà & }Ô 5× <Ò <¸WÑ EÔ Eˆˆ}ÑØ˜vÐ%Ð%Ø'-Ð.>Ô'?×'FÒ'FÀwÑ'OÔ'OˆFÐ#Ñ$Ýð L 4°(Ø)3¸5ðLð LØDJðLð Lð 	Ls$   Á'B Â(B-Â,B-Ã'D Ä 
DÄDc                 ó–   — |                       ¦   «         }| j        �-|                     | j                             d¦  «        ¦  «         |S )NT)rT   r5   rL   Ú
splitlines©r   rS   s     r   r<   zMergeDirective.to_linesÛ  s@   € Ø—’Ñ Ô ˆØŒ:Ð!Ø�LŠL˜œ×.Ò.¨tÑ4Ô4Ñ5Ô5Ð5Øˆr   c                 ó‚   — t          ¦   «         }t                               | |||d¦  «         |                     ¦   «         S )Nz0.9rž   r¡   s       r   rm   zMergeDirective._generate_bundleá  s<   € å‰IŒIˆÝ×&Ò& z°;Ø'2°A°uñ	>ô 	>ð 	>à�zŠz‰|Œ|Ðr   c                 ó   — d| j         dfS )ú}Provide data for performing a merge

        Returns suggested base, suggested target, and patch verification status
        NÚinapplicabler·   ©r   rj   s     r   Úget_merge_requestz MergeDirective.get_merge_requestè  s   € ð
 �TÔ% ~Ð5Ð5r   ©NNNNN)r   r   r   r   rK   r   rá   rA   rä   Úpropertyr8   rØ   rð   rë   r<   rÙ   rm   r  r   r   r   rÛ   rÛ   q  sï   € € € € € ðð ð 8€Nð 8<Ø:>ð%ð %ð %ð %ð6ð ð ðð ð ðð ð ð ˆX�gÑÔ€Fàð3ð 3ñ „[ð3ð ðLð Lñ „[ðLð:ð ð ð ðð ñ „\ðð6ð 6ð 6ð 6ð 6r   rÛ   c                   ó’   — e Zd ZdZ	 	 dd„Zd„ Z ee¦  «        Zd„ Zd„ Z	e
d„ ¦   «         Zd„ Ze
	 	 	 dd
„¦   «         Zd„ Zd„ Zd„ ZdS )ÚMergeDirective2s-   Bazaar merge directive format 2 (Bazaar 0.90)Nc                 ó”   — |€|	€t          j        ¦   «         ‚t                               | ||||||||¦	  «	         |	| _        |
| _        d S r   )r   rÞ   r.   r   r8   rD   )r   r0   r1   r2   r3   r4   r5   r6   r7   r8   rD   s              r   r   zMergeDirective2.__init__ô  sa   € ð Ð  V ^ÝÔ&Ñ(Ô(Ð(Ý×#Ò# D¨+°~ÀtØ$,¨m¸UÀMÐSZñ	\ô 	\ð 	\àˆŒØ 0ˆÔÐÐr   c                 ó*   — | j         �dS | j        �dS d S )Nr8   r^   )r8   r5   r,   s    r   Ú_patch_typezMergeDirective2._patch_typeþ  s!   € ØŒ;Ð"Ø�8ØŒZÐ#Ø�6à�4r   c                 ó"   — d | _         d | _        d S r   )r5   r8   r,   s    r   rá   zMergeDirective2.clear_payload  s   € ØˆŒ
ØˆŒˆˆr   c                 óF   — | j         €d S t          j        | j         ¦  «        S r   )r8   Úbase64Ú	b64decoder,   s    r   rA   zMergeDirective2.get_raw_bundle  s"   € ØŒ;ÐØ�4åÔ# D¤KÑ0Ô0Ð0r   c                 óP  — t                                |¦  «        }d }d }	 t          |¦  «        }|                     d¦  «        rLg }|D ]0}|                     d¦  «        r|} n|                     |¦  «         Œ1d }d                     |¦  «        }|�:|                     d¦  «        rd                     |¦  «        }n t          |¦  «        ‚n# t          $ r Y nw xY wt           	                    | 
                    d¦  «        ¦  «        \  }}	i }
dD ]+}	 | 
                    |¦  «        |
|<   Œ# t          $ r Y Œ(w xY w|
d                              d¦  «        |
d<   |
d                              d¦  «        |
d<   d	|
v r|
d	                              d
¦  «        |
d	<    | d||	||dœ|
¤ŽS )Ns   # Begin patchs   # Begin bundler   rC   )r0   r1   r4   r6   r7   rD   r0   rò   rD   r1   ró   )r2   r3   r5   r8   r   )rG   rô   Únextrè   rN   r�   r
   ÚStopIterationrC   rù   r¬   rú   rû   )rr   rí   rQ   r5   r8   r   rü   rï   r2   r3   rý   rR   s               r   rë   zMergeDirective2._from_lines  s  € å×&Ò& yÑ1Ô1ˆØˆØˆð	>Ý˜‘O”OˆEð ×ÒÐ 0Ñ1Ô1ð 	.Ø �Ø%ð !ð !�DØ—’Ð'8Ñ9Ô9ð Ø $˜Ø˜Ø×&Ò& tÑ,Ô,Ð,Ð,à �EØŸš Ñ-Ô-�ØÐ Ø×#Ò#Ð$5Ñ6Ô6ð >Ø ŸXšX iÑ0Ô0�F�Få6°uÑ=Ô=Ð=ð	 !øõ ð 	ð 	ð 	ØˆDð	øøøõ$ #×3Ò3°F·J²J¸{Ñ4KÔ4KÑLÔL‰ˆˆhØˆðDð 	ð 	ˆCðØ$Ÿjšj¨™oœo��s‘�øÝð ð ð Ø�ðøøøà & }Ô 5× <Ò <¸WÑ EÔ Eˆˆ}ÑàÐ%Ô&×-Ò-¨gÑ6Ô6ð 	Ð!Ñ"à˜vÐ%Ð%Ø'-Ð.>Ô'?×'FÒ'FÀwÑ'OÔ'OˆFÐ#Ñ$Øˆuð ˜$¨¸Àvð ð Øðð ð 	s#    C Ã
CÃCÄD-Ä-
D:Ä9D:c                 óV  — |                       d¬¦  «        }| j        �B|                     d¦  «         |                     | j                             d¦  «        ¦  «         | j        �B|                     d¦  «         |                     | j                             d¦  «        ¦  «         |S )NT)rO   s   # Begin patch
s   # Begin bundle
)rT   r5   rN   rL   rÿ   r8   r   s     r   r<   zMergeDirective2.to_lines;  s”   € Ø—’¨T�Ñ2Ô2ˆØŒ:Ð!Ø�LŠLÐ+Ñ,Ô,Ð,Ø�LŠL˜œ×.Ò.¨tÑ4Ô4Ñ5Ô5Ð5ØŒ;Ð"Ø�LŠLÐ,Ñ-Ô-Ð-Ø�LŠL˜œ×/Ò/°Ñ5Ô5Ñ6Ô6Ð6Øˆr   Tc                 óŒ  — t          j        ¦   «         5 }|                     |                     ¦   «         ¦  «         |}|dk    rd}t          j                             ||¦  «        }|€ t          j         	                    |¦  «        }n|}|                     | 
                    ¦   «         ¦  «         |                     ¦   «         �|                     ¦   «         }|                     ¦   «         }|                     |j        ¦  «        }|                     ||¦  «        }|€|}||fdk    r|                     |j        |¦  «         |r|                      |||¦  «        }nd}|r*t%          j        |                      |||¦  «        ¦  «        }nd}|	�w|sut          j         	                    |	¦  «        }|                     | 
                    ¦   «         ¦  «         |j                             |¦  «        st-          j        |	|¦  «        ‚|                     ¦   «         }ddd¦  «         n# 1 swxY w Y    | |||||||	|
||¦
  «
        S )a	  Generate a merge directive from various objects

        :param repository: The repository containing the revision
        :param revision_id: The revision to merge
        :param time: The POSIX timestamp of the date the request was issued.
        :param timezone: The timezone of the request
        :param target_branch: The url of the branch to merge into
        :param include_patch: If true, include a preview patch
        :param include_bundle: If true, include a bundle
        :param local_target_branch: the target branch, either itself or a local copy
        :param public_branch: location of a public branch containing
            the target revision.
        :param message: Message to use when committing the merge
        :return: The merge directive

        The public branch is always used if supplied.  If no bundle is
        included, the public branch must be supplied, and will be verified.

        If the message is not supplied, the message from revision_id will be
        used for the commit.
        s   null:N)FF)Ú
contextlibÚ	ExitStackÚenter_contextÚ
lock_writera   rb   rc   rd   re   rf   Ú	lock_readrg   rh   rk   rj   rl   ri   rn   r  Ú	b64encoderm   ro   r   rp   rq   )rr   rj   r0   r2   r3   r4   Úinclude_patchÚinclude_bundlert   ru   r7   rD   Ú
exit_stackrv   rw   rx   ry   rz   r{   r5   r8   r}   r1   s                          r   r~   zMergeDirective2.from_objectsE  sÀ  € õ4 Ô!Ñ#Ô#ð )	) zØ×$Ò$ Z×%:Ò%:Ñ%<Ô%<Ñ=Ô=Ð=Ø'ˆMØ˜hÒ&Ð&Ø $�ÝÔ*×8Ò8¸Ø9FñHô HˆAà"Ð*Ý +Ô 2× 7Ò 7¸Ñ FÔ F��à 3�Ø×$Ò$ ]×%<Ò%<Ñ%>Ô%>Ñ?Ô?Ð?Ø×.Ò.Ñ0Ô0Ð<Ø -× ?Ò ?Ñ AÔ A�Ø!.×!<Ò!<Ñ!>Ô!>ÐØ×(Ò(¨Ô)AÑBÔBˆEØ×/Ò/°Ø0BñDô DˆKàÐ'Ø#.Ð Ø˜~Ð.°.Ò@Ð@Ø× Ò  Ô!9Ð;MÑNÔNÐNØð Ø×,Ò,¨Z¸Ø-=ñ?ô ?��ð �àð ÝÔ)¨%×*@Ò*@ÀÈ[ØALñ+Nô +Nñ Oô O��ð �àÐ(°Ð(Ý$/Ô$6×$;Ò$;¸MÑ$JÔ$JÐ!Ø×(Ò(Ð):×)DÒ)DÑ)FÔ)FÑGÔGÐGØ(Ô3×@Ò@Ø#ñ%ô %ð Då Ô6°}Ø7BñDô Dð DàŸYšY™[œ[ˆNðS)	)ð )	)ð )	)ñ )	)ô )	)ð )	)ð )	)ð )	)ð )	)ð )	)ð )	)øøøð )	)ð )	)ð )	)ð )	)ðT ˆu�[ .°$¸Ø" E¨=¸'À6Ø%ñ'ô 'ð 	's   ”HH'È'H+È.H+c                 ó
  — |                       || j        | j        ¦  «        }t          j        dd| j        ¦  «        }t          j        dd|¦  «        }t          j        dd|¦  «        }t          j        dd|¦  «        }||k    S )Ns   
?rE   s    *
)rn   r0   rD   r‹   rŒ   r5   )r   rj   Úcalculated_patchÚstored_patchs       r   Ú_verify_patchzMergeDirective2._verify_patch�  s†   € Ø×.Ò.¨z¸4Ô;KØ/3Ô/DñFô FÐõ ”v˜h¨¨t¬zÑ:Ô:ˆÝœ6 (¨EÐ3CÑDÔDÐåœ6 '¨5Ð2BÑCÔCÐÝ”v˜g u¨lÑ;Ô;ˆØ  LÒ0Ð1r   c                 óJ   — |                       |¦  «        }| j        | j        |fS )r  )Ú_maybe_verifyrD   r0   )r   rj   Úverifieds      r   r  z!MergeDirective2.get_merge_request˜  s*   € ð
 ×%Ò% jÑ1Ô1ˆØÔ$ dÔ&6¸Ð@Ð@r   c                 óF   — | j         �|                      |¦  «        rdS dS dS )Nr&  Úfailedr  )r5   r#  r  s     r   r%  zMergeDirective2._maybe_verify   s/   € ØŒ:Ð!Ø×!Ò! *Ñ-Ô-ð  Ø!�zà�xà!�>r   r  )TTNNNN)r   r   r   rK   r   r  r  rs   rá   rA   rØ   rë   r<   r~   r#  r  r%  r   r   r   r
  r
  ð  sþ   € € € € € àE€Nð IMØ/3ð1ð 1ð 1ð 1ðð ð ð �˜+Ñ&Ô&€Jðð ð ð1ð 1ð 1ð ð&ð &ñ „[ð&ðPð ð ð àGKØKOØ&*ðE'ð E'ð E'ñ „[ðE'ðN	2ð 	2ð 	2ðAð Að Að"ð "ð "ð "ð "r   r
  c                   ó   — e Zd Zdd„ZdS )ÚMergeDirectiveFormatRegistryNc                 óZ   — |€|j         }t          j                             | ||¦  «         d S r   )rK   r   ÚRegistryÚregister)r   r   Úformat_strings      r   r-  z%MergeDirectiveFormatRegistry.register¬  s1   € ØÐ Ø%Ô4ˆMÝÔ×"Ò" 4¨¸	ÑBÔBÐBÐBÐBr   r   )r   r   r   r-  r   r   r   r*  r*  ª  s.   € € € € € ðCð Cð Cð Cð Cð Cr   r*  s-   Bazaar merge directive format 2 (Bazaar 0.19))r  r  Úior   r‹   r”   r   Úglobalsr   r   r   r   r
   r   r*   r&   r.   rÛ   r
  r,  r*  ré   r-  r   r   r   ú<module>r1     sT  ðð" €€€Ø Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø 	€	€	€	à Ð Ð Ð Ð Ð Ø €Ô ˜˜™	œ	ð $ñ ô ð ð$ð ð ð ð ð ð ð ð ð ðð ð ð ð  6¤?ñ ô ð ðð ð ð ð ñ ô ð ð2ð 2ð 2ð 2ð 2˜%œ+ñ 2ô 2ð 2ðW:ð W:ð W:ð W:ð W:ñ W:ô W:ð W:ðt|6ð |6ð |6ð |6ð |6Ð'ñ |6ô |6ð |6ð~w"ð w"ð w"ð w"ð w"Ð(ñ w"ô w"ð w"ðtCð Cð Cð Cð C 8Ô#4ñ Cô Cð Cð 0Ð/Ñ1Ô1Ð Ø × Ò ˜.Ñ )Ô )Ð )Ø × Ò ˜/Ñ *Ô *Ð *ð × Ò ˜/ØJñLô Lð Lð Lð Lr   