§
    cÌc  ã                   ó¨   — d Z ddlZddlmZ ddlmZmZ ddlmZ  G d„ d¦  «        Z	 G d	„ d
e	¦  «        Z
 G d„ de
¦  «        Z G d„ de	¦  «        ZdS )aª  This module provides a transactional facility.

Transactions provide hooks to allow data objects (i.e. inventory weaves or
the revision-history file) to be placed in a registry and retrieved later
during the same transaction. Transactions in bzr are not atomic - they
depend on data ordering of writes, so we do not have commit or rollback
facilities at the transaction level.

Read only transactions raise an assert when objects are listed as dirty
against them - preventing unintended writes.

Write transactions preserve dirty objects in the cache, though due to the
write ordering approach we use for consistency 'dirty' is a misleading term.
A dirty object is one we have modified.

Both read and write transactions *may* flush unchanged objects out of
memory, unless they are marked as 'precious' which indicates that
repeated reads cannot be obtained if the object is ejected, or that
the object is an expensive one for obtaining.
é    Né   )Úerrors)ÚIdentityMapÚNullIdentityMap)Úmutterc                   ó   — e Zd ZdZdefd„ZdS )ÚTransactionzBase class for transactions.Úreturnc                 ó*   — t          | j        ¦  «        ‚©N)ÚNotImplementedErrorÚ	writeable©Úselfs    ú5/usr/lib/python3/dist-packages/breezy/transactions.pyr   zTransaction.writeable1   s   € Ý! $¤.Ñ1Ô1Ð1ó    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Úboolr   © r   r   r	   r	   .   s5   € € € € € Ø&Ð&ð2˜4ð 2ð 2ð 2ð 2ð 2ð 2r   r	   c                   óN   ‡ — e Zd ZdZd„ Zˆ fd„Zd„ Zdd„Zd„ Zd„ Z	d	„ Z
d
„ Zˆ xZS )ÚReadOnlyTransactionz*A read only unit of work for data objects.c                 ó   — dS )úClean up this transaction.Nr   r   s    r   ÚfinishzReadOnlyTransaction.finish8   ó   € € € r   c                 óÖ   •— t          ¦   «                              ¦   «          t          ¦   «         | _        t	          ¦   «         | _        g | _        d| _        t	          ¦   «         | _        d S )Néÿÿÿÿ)	ÚsuperÚ__init__r   ÚmapÚsetÚ_clean_objectsÚ_clean_queueÚ_limitÚ_precious_objects©r   Ú	__class__s    €r   r"   zReadOnlyTransaction.__init__;   sQ   ø€ Ý‰Œ×ÒÑÔÐÝ‘=”=ˆŒÝ!™eœeˆÔØˆÔØˆŒÝ!$¡¤ˆÔÐÐr   c                 ó   — || j         v S )z"Return True if an_object is clean.)r%   ©r   Ú	an_objects     r   Úis_cleanzReadOnlyTransaction.is_cleanC   ó   € à˜TÔ0Ð0Ð1r   Fc                 óÎ   — | j                              |¦  «         | j                             |¦  «         |r| j                             |¦  «         |                      ¦   «          dS )zœRegister an_object as being clean.

        If the precious hint is True, the object will not
        be ejected from the object identity map ever.
        N)r%   Úaddr&   Úappendr(   Ú_trim©r   r-   Úpreciouss      r   Úregister_cleanz"ReadOnlyTransaction.register_cleanG   sb   € ð 	Ô×Ò 	Ñ*Ô*Ð*ØÔ× Ò  Ñ+Ô+Ð+Øð 	2ØÔ"×&Ò& yÑ1Ô1Ð1Ø�
Š
‰Œˆˆˆr   c                 ó*   — t          j        |¦  «        ‚)z"Register an_object as being dirty.)r   ÚReadOnlyObjectDirtiedErrorr,   s     r   Úregister_dirtyz"ReadOnlyTransaction.register_dirtyS   s   € åÔ/°	Ñ:Ô:Ð:r   c                 óf   — |dk     rt          |¦  «        ‚|| _        |                      ¦   «          dS )zSet a new cache size.r    N)Ú
ValueErrorr'   r3   )r   Úsizes     r   Úset_cache_sizez"ReadOnlyTransaction.set_cache_sizeW   s1   € à�"Š9ˆ9Ý˜TÑ"Ô"Ð"ØˆŒØ�
Š
‰Œˆˆˆr   c                 óp  — | j         dk     s | j         t          | j        ¦  «        z
  dk    rdS t          | j        ¦  «        | j         z
  }d}|rä|t          | j        ¦  «        k     rÎt          j        dk    rd}nd}t          j        | j        |         ¦  «        |k    rs| j        |         | j        vr_| j        |         }| j                             |¦  «         | j        |= | j	         
                    |¦  «         t          d|¦  «         |dz  }n|dz  }|r|t          | j        ¦  «        k     °ÊdS dS dS dS )zTrim the cache back if needed.r   N)é   é   é   é   zremoved object %rr   )r'   Úlenr%   ÚsysÚversion_infoÚgetrefcountr&   r(   Úremover#   Úremove_objectr   )r   ÚneededÚoffsetÚref_thresholdÚremoveds        r   r3   zReadOnlyTransaction._trim^   sa  € àŒ;˜Š?ˆ?˜dœk­C°Ô0CÑ,DÔ,DÑDÀqÒHÐHØˆFÝ�TÔ(Ñ)Ô)¨D¬KÑ7ˆØˆØð 	˜¥# dÔ&9Ñ":Ô":Ò:Ð:õ Ô 7Ò*Ð*Ø !��ð !"�Ý” Ô 1°&Ô 9Ñ:Ô:¸mÒKÐKØ Ô-¨fÔ5¸Ô9OÐOÐOØÔ+¨FÔ3�ØÔ#×*Ò*¨7Ñ3Ô3Ð3ØÔ% fÐ-Ø”×&Ò& wÑ/Ô/Ð/ÝÐ*¨GÑ4Ô4Ð4Ø˜!‘��à˜!‘�ð- ð 	˜¥# dÔ&9Ñ":Ô":Ò:Ð:Ð:Ð:ð 	ð 	Ð:Ð:ð 	ð 	r   c                 ó   — dS )z+Read only transactions do not allow writes.Fr   r   s    r   r   zReadOnlyTransaction.writeable|   s   € àˆur   ©F)r   r   r   r   r   r"   r.   r6   r9   r=   r3   r   Ú__classcell__©r*   s   @r   r   r   5   s¬   ø€ € € € € Ø4Ð4ð)ð )ð )ð'ð 'ð 'ð 'ð 'ð2ð 2ð 2ð
ð 
ð 
ð 
ð;ð ;ð ;ðð ð ðð ð ð<ð ð ð ð ð ð r   r   c                   ó:   ‡ — e Zd ZdZd„ Zˆ fd„Zd„ Zd„ Zd„ Zˆ xZ	S )ÚWriteTransactionz‰A write transaction

    - caches domain objects
    - clean objects can be removed from the cache
    - dirty objects are retained.
    c                 óT   — | j         D ]}t          |dd¦  «        }|�
 |¦   «          Œ dS ©r   Útransaction_finishedN©Ú_dirty_objectsÚgetattr©r   ÚthingÚcallbacks      r   r   zWriteTransaction.finish‰   óB   € àÔ(ð 	ð 	ˆEÝ˜uÐ&<¸dÑCÔCˆHØÐ#Ø�‘
”
�
øð	ð 	r   c                 ón   •— t          ¦   «                              ¦   «          t          ¦   «         | _        d S r   )r!   r"   r$   rW   r)   s    €r   r"   zWriteTransaction.__init__�   s+   ø€ Ý‰Œ×ÒÑÔÐÝ!™eœeˆÔÐÐr   c                 ó   — || j         v S )z"Return True if an_object is dirty.)rW   r,   s     r   Úis_dirtyzWriteTransaction.is_dirty”   r/   r   c                 ó   — | j                              |¦  «         |                      |¦  «        r:| j                             |¦  «         | j        | j                             |¦  «        = |                      ¦   «          dS )zÇRegister an_object as being dirty.

        Dirty objects are not ejected from the identity map
        until the transaction finishes and get informed
        when the transaction finishes.
        N)rW   r1   r.   r%   rG   r&   Úindexr3   r,   s     r   r9   zWriteTransaction.register_dirty˜   st   € ð 	Ô×Ò 	Ñ*Ô*Ð*Ø�=Š=˜Ñ#Ô#ð 	FØÔ×&Ò& yÑ1Ô1Ð1ØÔ! $Ô"3×"9Ò"9¸)Ñ"DÔ"DÐEØ�
Š
‰Œˆˆˆr   c                 ó   — dS )z Write transactions allow writes.Tr   r   s    r   r   zWriteTransaction.writeable¥   ó   € àˆtr   )
r   r   r   r   r   r"   r_   r9   r   rO   rP   s   @r   rR   rR   �   s~   ø€ € € € € ðð ðð ð ð$ð $ð $ð $ð $ð2ð 2ð 2ðð ð ðð ð ð ð ð ð r   rR   c                   óB   ‡ — e Zd ZdZd„ Zˆ fd„Zd	d„Zd„ Zd„ Zd„ Z	ˆ xZ
S )
ÚPassThroughTransactionzhA pass through transaction

    - nothing is cached.
    - nothing ever gets into the identity map.
    c                 óT   — | j         D ]}t          |dd¦  «        }|�
 |¦   «          Œ dS rT   rV   rY   s      r   r   zPassThroughTransaction.finish±   r\   r   c                 ó”   •— t          ¦   «                              ¦   «          t          ¦   «         | _        t	          ¦   «         | _        d S r   )r!   r"   r   r#   r$   rW   r)   s    €r   r"   zPassThroughTransaction.__init__¸   s8   ø€ Ý‰Œ×ÒÑÔÐÝ"Ñ$Ô$ˆŒÝ!™eœeˆÔÐÐr   Fc                 ó   — dS )z†Register an_object as being clean.

        Note that precious is only a hint, and PassThroughTransaction
        ignores it.
        Nr   r4   s      r   r6   z%PassThroughTransaction.register_clean½   r   r   c                 ó:   — | j                              |¦  «         dS )zvRegister an_object as being dirty.

        Dirty objects get informed
        when the transaction finishes.
        N)rW   r1   r,   s     r   r9   z%PassThroughTransaction.register_dirtyÄ   s!   € ð 	Ô×Ò 	Ñ*Ô*Ð*Ð*Ð*r   c                 ó   — dS )z#Do nothing, we are passing through.Nr   )r   Úignoreds     r   r=   z%PassThroughTransaction.set_cache_sizeÌ   r   r   c                 ó   — dS )z'Pass through transactions allow writes.Tr   r   s    r   r   z PassThroughTransaction.writeableÏ   rc   r   rN   )r   r   r   r   r   r"   r6   r9   r=   r   rO   rP   s   @r   re   re   ª   s’   ø€ € € € € ðð ðð ð ð$ð $ð $ð $ð $ð
ð ð ð ð+ð +ð +ð2ð 2ð 2ðð ð ð ð ð ð r   re   )r   rD   Ú r   Úidentitymapr   r   Útracer   r	   r   rR   re   r   r   r   ú<module>rp      s  ðð$ð ð* €
€
€
à Ð Ð Ð Ð Ð Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ø Ð Ð Ð Ð Ð ð2ð 2ð 2ð 2ð 2ñ 2ô 2ð 2ðIð Ið Ið Ið I˜+ñ Iô Ið IðX&ð &ð &ð &ð &Ð*ñ &ô &ð &ðR'ð 'ð 'ð 'ð '˜[ñ 'ô 'ð 'ð 'ð 'r   