§
    cÌc}4  ã                   óV   — d Z ddlmZmZmZmZ  G d„ d¦  «        Z G d„ d¦  «        ZdS )z5Utility for create branches with particular contents.é   )Ú
controldirÚcommitÚerrorsÚrevisionc                   óZ   — e Zd ZdZdd„Zdd„Zdd„Z	 dd„Zd„ Zd	„ Z		 	 	 dd
„Z
d„ Zd„ ZdS )ÚBranchBuildera?  A BranchBuilder aids creating Branches with particular shapes.

    The expected way to use BranchBuilder is to construct a
    BranchBuilder on the transport you want your branch on, and then call
    appropriate build_ methods on it to get the shape of history you want.

    This is meant as a helper for the test suite, not as a general class for
    real data.

    For instance:

    >>> from breezy.transport.memory import MemoryTransport
    >>> builder = BranchBuilder(MemoryTransport("memory:///"))
    >>> builder.start_series()
    >>> builder.build_snapshot(None, [
    ...     ('add', ('', b'root-id', 'directory', '')),
    ...     ('add', ('filename', b'f-id', 'file', b'content\n'))],
    ...     revision_id=b'rev-id')
    b'rev-id'
    >>> builder.build_snapshot([b'rev-id'],
    ...     [('modify', ('filename', b'new-content\n'))],
    ...     revision_id=b'rev2-id')
    b'rev2-id'
    >>> builder.finish_series()
    >>> branch = builder.get_branch()

    :ivar _tree: This is a private member which is not meant to be modified by
        users of this class. While a 'series' is in progress, it should hold a
        MemoryTree with the contents of the last commit (ready to be modified
        by the next build_snapshot command) with a held write lock. Outside of
        a series in progress, it should be None.
    Nc                 óˆ  — |�*|�t          d¦  «        ‚|�t          d¦  «        ‚|| _        nŽ|                     d¦  «        s|                     d¦  «         |€d}t	          |t
          ¦  «        rt          j                             |¦  «        }t          j	         
                    |j        |d¬¦  «        | _        d| _        dS )a  Construct a BranchBuilder on transport.

        :param transport: The transport the branch should be created on.
            If the path of the transport does not exist but its parent does
            it will be created.
        :param format: Either a BzrDirFormat, or the name of a format in the
            controldir format registry for the branch to be built.
        :param branch: An already constructed branch to use.  This param is
            mutually exclusive with the transport and format params.
        Nz/branch and format kwargs are mutually exclusivez2branch and transport kwargs are mutually exclusiveú.ÚdefaultF)ÚformatÚforce_new_tree)ÚAssertionErrorÚ_branchÚhasÚmkdirÚ
isinstanceÚstrr   Úformat_registryÚmake_controldirÚ
ControlDirÚcreate_branch_convenienceÚbaseÚ_tree)ÚselfÚ	transportr   Úbranchs       ú6/usr/lib/python3/dist-packages/breezy/branchbuilder.pyÚ__init__zBranchBuilder.__init__=   sÞ   € ð ÐØÐ!Ý$ØEñGô Gð GàÐ$Ý$ØHñJô Jð Jà!ˆDŒLˆLà—=’= Ñ%Ô%ð %Ø—’ Ñ$Ô$Ð$Øˆ~Ø"�Ý˜&¥#Ñ&Ô&ð LÝ#Ô3×CÒCÀFÑKÔK�Ý%Ô0×JÒJØ” v¸eð Kñ Eô EˆDŒLàˆŒ
ˆ
ˆ
ó    Fc                 óÄ  — |�\t          |¦  «        dk    rt          j        }n|d         }|| j                             ¦   «         k    r|                      ||¬¦  «         | j                             ¦   «         }|                     ¦   «         5  |�|                     ||¬¦  «         | 	                    d¦  «          | j
        |fi |¤Žcddd¦  «         S # 1 swxY w Y   dS )a	  Build a commit on the branch.

        This makes a commit with no real file content for when you only want
        to look at the revision graph structure.

        :param commit_kwargs: Arguments to pass through to commit, such as
             timestamp.
        Né    ©Úallow_leftmost_as_ghostÚ )Úlenr   ÚNULL_REVISIONr   Úlast_revisionÚ_move_branch_pointerÚcreate_memorytreeÚ
lock_writeÚset_parent_idsÚaddÚ
_do_commit)r   Ú
parent_idsr#   Úcommit_kwargsÚbase_idÚtrees         r   Úbuild_commitzBranchBuilder.build_commit[   sH  € ð Ð!Ý�:‰Œ !Ò#Ð#Ý"Ô0��à$ Qœ-�Ø˜$œ,×4Ò4Ñ6Ô6Ò6Ð6Ø×)Ò)ØÐ5Lð *ñ Nô Nð NàŒ|×-Ò-Ñ/Ô/ˆØ�_Š_ÑÔð 	:ð 	:ØÐ%Ø×#Ò#ØØ,Cð $ñ Eô Eð Eð �HŠH�R‰LŒLˆLØ"�4”? 4Ð9Ð9¨=Ð9Ð9ð	:ð 	:ð 	:ð 	:ñ 	:ô 	:ð 	:ð 	:ð 	:ð 	:ð 	:ð 	:øøøð 	:ð 	:ð 	:ð 	:ð 	:ð 	:s   Â<CÃCÃCc                 ó’   — t          j        ¦   «         }|€"|€ d| j                             ¦   «         dz   fz  } |j         |f||dœ|¤ŽS )Nz	commit %dr   )Úmessage_callbackÚreporter)r   ÚNullCommitReporterr   Úrevno)r   r1   Úmessager4   Úkwargsr5   s         r   r-   zBranchBuilder._do_commitv   sk   € ÝÔ,Ñ.Ô.ˆØˆ?Ð/Ð7Ø! T¤\×%7Ò%7Ñ%9Ô%9¸AÑ%=Ð$?Ñ?ˆGØˆtŒ{˜7ð 8Ð5EØ$,ð8ð 8Ø06ð8ð 8ð 	8r   c                 ó(  — | j                              ¦   «         5  | j                              ¦   «         \  }}	 | j         j                             ¦   «         }|                     |||fg¦  «        }| j                              ||¦  «         n# t          j        $ r |s‚ d}Y nw xY wddd¦  «         n# 1 swxY w Y   | j	        �O| j          
                    ¦   «         }|                     ¦   «          | j	                             ¦   «          || _	        dS dS )z.Point self._branch to a different revision id.r   N)r   r*   Úlast_revision_infoÚ
repositoryÚ	get_graphÚfind_distance_to_nullÚset_last_revision_infor   ÚGhostRevisionsHaveNoRevnor   r)   Úunlock)r   Únew_revision_idr#   Ú	cur_revnoÚcur_revision_idÚgÚ	new_revnoÚnew_trees           r   r(   z"BranchBuilder._move_branch_pointer}   sk  € ð Œ\×$Ò$Ñ&Ô&ð 	ð 	ð *.¬×)HÒ)HÑ)JÔ)JÑ&ˆI�ðØ”LÔ+×5Ò5Ñ7Ô7�Ø×3Ò3Ø# ¸	Ð&BÐ%CñEô E�	à”×3Ò3°I¸ÑOÔOÐOÐOøÝÔ3ð ð ð Ø.ð ØØ�	�	�	ðøøøð	ð 	ð 	ñ 	ô 	ð 	ð 	ð 	ð 	ð 	ð 	øøøð 	ð 	ð 	ð 	ð Œ:Ð!ð ”|×5Ò5Ñ7Ô7ˆHØ×ÒÑ!Ô!Ð!ØŒJ×ÒÑÔÐØ!ˆDŒJˆJˆJð "Ð!s5   šB1¸ABÂ
B1ÂB"ÂB1Â!B"Â"B1Â1B5Â8B5c                 ó    — | j         �t          d¦  «        ‚| j                             ¦   «         | _         | j                              ¦   «          dS )z·We will be creating a series of commits.

        This allows us to hold open the locks while we are processing.

        Make sure to call 'finish_series' when you are done.
        Nz>You cannot start a new series while a series is already going.)r   r   r   r)   r*   ©r   s    r   Ústart_serieszBranchBuilder.start_series™   sR   € ð Œ:Ð!Ý ð "=ñ >ô >ð >à”\×3Ò3Ñ5Ô5ˆŒ
ØŒ
×ÒÑÔÐÐÐr   c                 óF   — | j                              ¦   «          d| _         dS )z;Call this after start_series to unlock the various objects.N)r   rA   rI   s    r   Úfinish_serieszBranchBuilder.finish_series¦   s!   € àŒ
×ÒÑÔÐØˆŒ
ˆ
ˆ
r   c
           
      óœ  — |�\t          |¦  «        dk    rt          j        }
n|d         }
|
| j                             ¦   «         k    r|                      |
|¬¦  «         | j        �| j        }n| j                             ¦   «         }|                     ¦   «         5  |�| 	                    ||¬¦  «         t          ¦   «         }|D �]<\  }}|dk    r…|\  }}}}|dk    r|j                             ||f¦  «         Œ6|j                             |¦  «         |j                             |¦  «         |j                             |¦  «         |�
||j        |<   Œ‘|dk    r|\  }}||j        |<   Œ§|dk    r|j                             |¦  «         ŒÈ|dk    r"|\  }}|j                             ||f¦  «         Œð|d	k    r&|                      ||¦  «         t          ¦   «         }�Œt+          d
                     |¦  «        ¦  «        ‚|                      ||¦  «         |                      |||	||||¬¦  «        cddd¦  «         S # 1 swxY w Y   dS )aÕ  Build a commit, shaped in a specific way.

        Most of the actions are self-explanatory.  'flush' is special action to
        break a series of actions into discrete steps so that complex changes
        (such as unversioning a file-id and re-adding it with a different kind)
        can be expressed in a way that will clearly work.

        :param parent_ids: A list of parent_ids to use for the commit.
            It can be None, which indicates to use the last commit.
        :param actions: A list of actions to perform. Supported actions are:
            ('add', ('path', b'file-id', 'kind', b'content' or None))
            ('modify', ('path', b'new-content'))
            ('unversion', 'path')
            ('rename', ('orig-path', 'new-path'))
            ('flush', None)
        :param message: An optional commit message, if not supplied, a default
            commit message will be written.
        :param message_callback: A message callback to use for the commit, as
            per mutabletree.commit.
        :param timestamp: If non-None, set the timestamp of the commit to this
            value.
        :param timezone: An optional timezone for timestamp.
        :param committer: An optional username to use for commit
        :param allow_leftmost_as_ghost: True if the leftmost parent should be
            permitted to be a ghost.
        :param revision_id: The handle for the new commit, can be None
        :return: The revision_id of the new commit
        Nr!   r"   r,   Ú	directoryÚmodifyÚ	unversionÚrenameÚflushzUnknown build action: "{}")r8   Úrev_idÚ	timestampÚtimezoneÚ	committerr4   )r%   r   r&   r   r'   r(   r   r)   r*   r+   Ú_PendingActionsÚto_add_directoriesÚappendÚto_add_filesÚto_add_file_idsÚto_add_kindsÚnew_contentsÚto_unversion_pathsr,   Ú	to_renameÚ_flush_pendingÚ
ValueErrorr   r-   )r   r.   Úactionsr8   rT   r#   rV   rU   r4   Úrevision_idr0   r1   ÚpendingÚactionÚinfoÚpathÚfile_idÚkindÚcontentÚfrom_relpathÚ
to_relpaths                        r   Úbuild_snapshotzBranchBuilder.build_snapshot«   sô  € ð> Ð!Ý�:‰Œ !Ò#Ð#Ý"Ô0��à$ Qœ-�Ø˜$œ,×4Ò4Ñ6Ô6Ò6Ð6Ø×)Ò)ØÐ5Lð *ñ Nô Nð Nð Œ:Ð!Ø”:ˆDˆDà”<×1Ò1Ñ3Ô3ˆDØ�_Š_ÑÔð &	3ð &	3ØÐ%Ø×#Ò#ØØ,Cð $ñ Eô Eð Eõ &Ñ'Ô'ˆGØ 'ð Rñ R‘�˜Ø˜U’?�?Ø37Ñ0�D˜' 4¨Ø˜{Ò*Ð*ØÔ2×9Ò9¸4À¸/ÑJÔJÐJÐJàÔ,×3Ò3°DÑ9Ô9Ð9ØÔ/×6Ò6°wÑ?Ô?Ð?ØÔ,×3Ò3°DÑ9Ô9Ð9Ø"Ð.Ø9@˜GÔ0°Ñ6øØ˜xÒ'Ð'Ø$(‘M�D˜'Ø18�GÔ(¨Ñ.Ð.Ø˜{Ò*Ð*ØÔ.×2Ò2°4Ñ8Ô8Ð8Ð8Ø˜xÒ'Ð'Ø/3Ñ,�L *ØÔ%×,Ò,¨l¸JÐ-GÑHÔHÐHÐHØ˜wÒ&Ð&Ø×'Ò'¨¨gÑ6Ô6Ð6Ý-Ñ/Ô/�G‘Gå$Ð%A×%HÒ%HÈÑ%PÔ%PÑQÔQÐQØ×Ò  gÑ.Ô.Ð.Ø—?’?Ø˜g¨kØ#¨hÀ)Ø!1ð #ñ 3ô 3ðG&	3ð &	3ð &	3ð &	3ñ &	3ô &	3ð &	3ð &	3ð &	3ð &	3ð &	3ð &	3øøøð &	3ð &	3ð &	3ð &	3ð &	3ð &	3s   ÂFIÉIÉIc                 óô  — |j         D ]¨\  }}|dk    ro|                     |¦  «        r#||j        v r|j                             |¦  «         |�|                     |gdg|g¬¦  «         Œa|                     |gdg¦  «         Œz|�|                     ||¦  «         Œ“|                     |¦  «         Œ©|j        D ]\  }}|                     ||¦  «         Œ|j        r|                     |j        ¦  «         |j	        r'|                     |j
        |j        |j        ¦  «         n |                     |j
        |j        ¦  «         |j                             ¦   «         D ]\  }}|                     ||¦  «         ŒdS )z@Flush the pending actions in 'pending', i.e. apply them to tree.r$   NrN   )Úids)rX   Úhas_filenamer^   Údiscardr,   r   r_   Ú
rename_onerP   Úsupports_file_idsrZ   r\   r[   r]   ÚitemsÚput_file_bytes_non_atomic)r   r1   rd   rg   rh   rk   rl   rj   s           r   r`   zBranchBuilder._flush_pendingÿ   sº  € à$Ô7ð 	%ð 	%‰MˆD�'Ø�rŠzˆzØ×$Ò$ TÑ*Ô*ð =Ø  GÔ$>Ð>Ð>àÔ.×6Ò6°tÑ<Ô<Ð<àÐ&Ø—H’H˜d˜V k ]¸¸	�HÑBÔBÐBÐBà—H’H˜d˜V k ]Ñ3Ô3Ð3Ð3àÐ&Ø—J’J˜t WÑ-Ô-Ð-Ð-à—J’J˜tÑ$Ô$Ð$Ð$Ø(/Ô(9ð 	6ð 	6Ñ$ˆL˜*Ø�OŠO˜L¨*Ñ5Ô5Ð5Ð5ØÔ%ð 	7Ø�NŠN˜7Ô5Ñ6Ô6Ð6ØÔ!ð 	AØ�HŠH�WÔ)ØÔ)¨7Ô+BñDô Dð Dð Dð �HŠH�WÔ)¨7Ô+?Ñ@Ô@Ð@Ø$Ô1×7Ò7Ñ9Ô9ð 	:ð 	:‰MˆD�'Ø×*Ò*¨4°Ñ9Ô9Ð9Ð9ð	:ð 	:r   c                 ó   — | j         S )z)Return the branch created by the builder.)r   rI   s    r   Ú
get_branchzBranchBuilder.get_branch  s
   € àŒ|Ðr   )NNN)NF)NN)F)NNFNNNN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r2   r-   r(   rJ   rL   rm   r`   rw   © r   r   r   r      sÖ   € € € € € ðð ðBð ð ð ð<:ð :ð :ð :ð68ð 8ð 8ð 8ð 6;ð"ð "ð "ð "ð8 ð  ð  ðð ð ð
 KOØ@DØIMðR3ð R3ð R3ð R3ðh:ð :ð :ð<ð ð ð ð r   r   c                   ó   — e Zd ZdZd„ ZdS )rW   z£Pending actions for build_snapshot to take.

    This is just a simple class to hold a bunch of the intermediate state of
    build_snapshot in single object.
    c                 ó€   — g | _         g | _        g | _        g | _        i | _        t          ¦   «         | _        g | _        d S )N)rX   rZ   r[   r\   r]   Úsetr^   r_   rI   s    r   r   z_PendingActions.__init__)  sA   € Ø"$ˆÔØˆÔØ!ˆÔØˆÔØˆÔÝ"%¡%¤%ˆÔØˆŒˆˆr   N)rx   ry   rz   r{   r   r|   r   r   rW   rW   "  s-   € € € € € ðð ðð ð ð ð r   rW   N)r{   r$   r   r   r   r   r   rW   r|   r   r   ú<module>r€      s¬   ðð" <Ð ;ðð ð ð ð ð ð ð ð ð ð ð ðDð Dð Dð Dð Dñ Dô Dð DðNð ð ð ð ñ ô ð ð ð r   