§
    cÌcì  ã                   ó    — d Z ddlmZmZmZmZ ddlmZ ddlm	Z	 ddl
mZ  G d„ de¦  «        Z ed	¦  «        Z G d
„ dee         ¦  «        ZdS )zInter-object utility class.é    )ÚGenericÚTypeVarÚListÚTypeé   )ÚBzrError)ÚLogicalLockResult)Úget_named_objectc                   ó   — e Zd ZdZd„ ZdS )ÚNoCompatibleInterzLNo compatible object available for operations from %(source)r to %(target)r.c                 ó"   — || _         || _        d S ©N©ÚsourceÚtarget©Úselfr   r   s      ú./usr/lib/python3/dist-packages/breezy/inter.pyÚ__init__zNoCompatibleInter.__init__   s   € ØˆŒØˆŒˆˆó    N)Ú__name__Ú
__module__Ú__qualname__Ú_fmtr   © r   r   r   r      s*   € € € € € ð€Dðð ð ð ð r   r   ÚTc                   ó   — e Zd ZU dZeed<   eed<   eed                  ed<   dedefd„Zd„ Z	e
dedefd„¦   «         Ze
d	„ ¦   «         Ze
d
„ ¦   «         Zd„ Zd„ Ze
d„ ¦   «         Ze
d„ ¦   «         Zd„ Ze
d„ ¦   «         ZdS )ÚInterObjecta\  This class represents operations taking place between two objects.

    Its instances have methods like join or copy_content or fetch, and contain
    references to the source and target objects these operations can be
    carried out between.

    Often we will provide convenience methods on the objects which carry out
    operations with another of similar type - they will always forward to
    a subclass of InterObject - i.e.
    InterVersionedFile.get(other).method_name(parameters).

    If the source and target objects implement the locking protocol -
    lock_read, lock_write, unlock, then the InterObject's lock_read,
    lock_write and unlock methods may be used.

    When looking for an inter, the most recently registered types are tested
    first.  So typically the most generic and slowest InterObjects should be
    registered first.
    r   r   zInterObject[T]Ú_optimisersc                 ó"   — || _         || _        dS )a¥  Construct a default InterObject instance. Please use 'get'.

        Only subclasses of InterObject should call
        InterObject.__init__ - clients should call InterFOO.get where FOO
        is the base type of the objects they are interacting between. I.e.
        InterVersionedFile or InterRepository.
        get() is a convenience class method which will create an optimised
        InterFOO if possible.
        Nr   r   s      r   r   zInterObject.__init__D   s   € ð ˆŒØˆŒˆˆr   c                 ó€   —  |¦   «          	  |¦   «          dS # t           $ r | j                             ¦   «          ‚ w xY w)z@Take out two locks, rolling back the first if the second throws.N)Ú	Exceptionr   Úunlock)r   Úlock_sourceÚlock_targets      r   Ú_double_lockzInterObject._double_lockQ   sU   € àˆ‰Œˆð	ØˆK‰MŒMˆMˆMˆMøÝð 	ð 	ð 	ð ŒK×ÒÑ Ô Ð Øð		øøøs   Œ
 ˜%=c                 ó0  — t          t          | j        ¦  «        ¦  «        D ]e\  }}t          |t          ¦  «        r't          |d         |d         ¦  «        }|| j        | <   |                     ||¦  «        r |||¦  «        c S Œft          ||¦  «        ‚)a•  Retrieve a Inter worker object for these objects.

        :param source: the object to be the 'source' member of
                       the InterObject instance.
        :param target: the object to be the 'target' member of
                       the InterObject instance.

        If an optimised worker exists it will be used otherwise
        a default Inter worker instance will be created.
        r   r   )Ú	enumerateÚreversedr   Ú
isinstanceÚtupler
   Úis_compatibler   )Úklassr   r   ÚiÚproviders        r   ÚgetzInterObject.get]   s§   € õ %¥X¨eÔ.?Ñ%@Ô%@ÑAÔAð 	0ð 	0‰KˆAˆxÝ˜(¥EÑ*Ô*ð 1Ý+¨H°Q¬K¸À!¼ÑEÔE�Ø(0�Ô! 1 "Ñ%Ø×%Ò% f¨fÑ5Ô5ð 0Ø�x ¨Ñ/Ô/Ð/Ð/Ð/ð0å ¨Ñ/Ô/Ð/r   c                 ó*   — t          | j        ¦  «        ‚r   )ÚNotImplementedErrorr,   )Úclsr   r   s      r   r,   zInterObject.is_compatibleq   s   € å! #Ô"3Ñ4Ô4Ð4r   c              #   óŽ   K  — | j         D ]:}t          |t          ¦  «        rt          |d         |d         ¦  «        V — Œ6|V — Œ;d S )Nr   r   )r   r*   r+   r
   )r-   r/   s     r   Úiter_optimiserszInterObject.iter_optimisersu   s`   è è € àÔ)ð 	ð 	ˆHÝ˜(¥EÑ*Ô*ð Ý& x°¤{°H¸Q´KÑ@Ô@Ð@Ð@Ð@Ð@à����ð		ð 	r   c                 ó~   — |                       | j        j        | j        j        ¦  «         t	          | j        ¦  «        S )z§Take out a logical read lock.

        This will lock the source branch and the target branch. The source gets
        a read lock and the target a read lock.
        )r&   r   Ú	lock_readr   r	   r#   ©r   s    r   r7   zInterObject.lock_read}   s4   € ð 	×Ò˜$œ+Ô/°´Ô1FÑGÔGÐGÝ  ¤Ñ-Ô-Ð-r   c                 ó~   — |                       | j        j        | j        j        ¦  «         t          | j        ¦  «        S )z©Take out a logical write lock.

        This will lock the source branch and the target branch. The source gets
        a read lock and the target a write lock.
        )r&   r   r7   r   Ú
lock_writer	   r#   r8   s    r   r:   zInterObject.lock_write†   s4   € ð 	×Ò˜$œ+Ô/°´Ô1GÑHÔHÐHÝ  ¤Ñ-Ô-Ð-r   c                 ó:   — | j                              |¦  «         dS )z"Register an InterObject optimiser.N©r   Úappend©r-   Ú	optimisers     r   Úregister_optimiserzInterObject.register_optimiser�   ó!   € ð 	Ô× Ò  Ñ+Ô+Ð+Ð+Ð+r   c                 ó>   — | j                              ||f¦  «         d S r   r<   )r-   Úmodule_nameÚmember_names      r   Úregister_lazy_optimiserz#InterObject.register_lazy_optimiser”   s&   € ð 	Ô× Ò  +¨{Ð!;Ñ<Ô<Ð<Ð<Ð<r   c                 ó¨   — 	 | j                              ¦   «          | j                             ¦   «          dS # | j                             ¦   «          w xY w)z'Release the locks on source and target.N)r   r#   r   r8   s    r   r#   zInterObject.unlock™   sO   € ð	!ØŒK×ÒÑ Ô Ð àŒK×ÒÑ Ô Ð Ð Ð øˆDŒK×ÒÑ Ô Ð Ð øøøs	   ‚6 ¶Ac                 ó:   — | j                              |¦  «         dS )z$Unregister an InterObject optimiser.N)r   Úremover>   s     r   Úunregister_optimiserz InterObject.unregister_optimiser    rA   r   N)r   r   r   Ú__doc__r   Ú__annotations__r   r   r   r&   Úclassmethodr0   r,   r5   r7   r:   r@   rE   r#   rI   r   r   r   r   r   '   s^  € € € € € € ðð ð( €I€I�IØ€I€I�Ià�dÐ+Ô,Ô-Ð-Ð-Ñ-ð
˜qð ¨!ð ð ð ð ð	ð 	ð 	ð ð0˜1ð 0 að 0ð 0ð 0ñ „[ð0ð& ð5ð 5ñ „[ð5ð ðð ñ „[ðð.ð .ð .ð.ð .ð .ð ð,ð ,ñ „[ð,ð ð=ð =ñ „[ð=ð!ð !ð !ð ð,ð ,ñ „[ð,ð ,ð ,r   r   N)rJ   Útypingr   r   r   r   Úerrorsr   Úlockr	   Úpyutilsr
   r   r   r   r   r   r   ú<module>rQ      sâ   ðð" "Ð !à /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /Ð /à Ð Ð Ð Ð Ð Ø #Ð #Ð #Ð #Ð #Ð #Ø %Ð %Ð %Ð %Ð %Ð %ðð ð ð ð ˜ñ ô ð ð €GˆC�L„L€ð|,ð |,ð |,ð |,ð |,�'˜!”*ñ |,ô |,ð |,ð |,ð |,r   