HEX
Server: Apache
System: Linux infong-uk86 4.4.400-icpu-106 #2 SMP Mon Sep 15 08:23:40 UTC 2025 x86_64
User: u44115835 (4976590)
PHP: 8.4.17
Disabled: NONE
Upload Files
File: //kunden/lib/python3/dist-packages/breezy/__pycache__/inter.cpython-39.pyc
a

�*�^&�@sLdZddlmZddlmZddlmZGdd�de�ZGdd	�d	e�Z	d
S)zInter-object utility class.�)�absolute_import�)�BzrError)�LogicalLockResultc@seZdZdZdd�ZdS)�NoCompatibleInterzLNo compatible object available for operations from %(source)r to %(target)r.cCs||_||_dS)N��source�target��selfrr	�r�./usr/lib/python3/dist-packages/breezy/inter.py�__init__szNoCompatibleInter.__init__N)�__name__�
__module__�__qualname__Z_fmtrrrrr
rsrc@s\eZdZdZdd�Zdd�Zedd��Zdd	�Zd
d�Z	edd
��Z
dd�Zedd��ZdS)�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.
    cCs||_||_dS)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.
        Nrr
rrr
r;s
zInterObject.__init__cCs4|�z
|�Wnty.|j���Yn0dS)z@Take out two locks, rolling back the first if the second throws.N)�	Exceptionr�unlock)rZlock_sourceZlock_targetrrr
�_double_lockHs

zInterObject._double_lockcCs8t|j�D]}|�||�r
|||�Sq
t||��dS)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.
        N)�reversed�_optimisersZ
is_compatibler)�klassrr	Zproviderrrr
�getSszInterObject.getcCs|�|jj|jj�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.
        )rr�	lock_readr	rr�rrrr
rdszInterObject.lock_readcCs|�|jj|jj�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.
        )rrrr	�
lock_writerrrrrr
rmszInterObject.lock_writecCs|j�|�dS)z"Register an InterObject optimiser.N)r�append�rZ	optimiserrrr
�register_optimiservszInterObject.register_optimisercCs*z|j��W|j��n|j��0dS)z'Release the locks on source and target.N)r	rrrrrr
r{szInterObject.unlockcCs|j�|�dS)z$Unregister an InterObject optimiser.N)r�removerrrr
�unregister_optimiser�sz InterObject.unregister_optimiserN)
rrr�__doc__rr�classmethodrrrrrr!rrrr
r#s

		
rN)
r"Z
__future__r�errorsr�lockrr�objectrrrrr
�<module>s