https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/hgext/infinitepush/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/hgext/infinitepush/__pycache__/store.cpython-310.pyc
o

�]Lb��@s�ddlmZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZm
Z
Gdd�de�ZGd	d
�d
e�ZGdd�de�ZGd
d�de�Zddd�ZGdd�de�ZdS)�)�absolute_importN)�hex)�open)�pycompat)�hashutil�procutilc@�eZdZdS)�BundleWriteExceptionN��__name__�
__module__�__qualname__�rr�:/usr/lib/python3/dist-packages/hgext/infinitepush/store.pyr	�r	c@r)�BundleReadExceptionNr
rrrrrrrc@s2eZdZdZejZejdd��Zejdd��Z	dS)�abstractbundlestorea6Defines the interface for bundle stores.

    A bundle store is an entity that stores raw bundle data. It is a simple
    key-value store. However, the keys are chosen by the store. The keys can
    be any Python object understood by the corresponding bundle index (see
    ``abstractbundleindex`` below).
    cC�dS)z�Write bundle data to the store.

        This function receives the raw data to be written as a str.
        Throws BundleWriteException
        The key of the written data MUST be returned.
        Nr)�self�datarrr�write(�zabstractbundlestore.writecCr)z�Obtain bundle data for a key.

        Returns None if the bundle isn't known.
        Throws BundleReadException
        The returned object should be a file object supporting read()
        and close().
        Nr)r�keyrrr�read1rzabstractbundlestore.readN)
rrr
�__doc__�abc�ABCMeta�
__metaclass__�abstractmethodrrrrrrrs
rc@s8eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�ZdS)
�filebundlestorezkbundle store in filesystem

    meant for storing bundles somewhere on disk and on network filesystems
    cCsT||_||_|�dd�|_|js|jj�dd�|_tj�|j�s(t�	|j�dSdS)Ns
scratchbranchs	storepathsscratchbranchessfilebundlestore)
�ui�repo�
configpath�	storepath�vfs�join�os�path�exists�makedirs)rr r!rrr�__init__Bs��zfilebundlestore.__init__cCs"tj�|j|dd�|dd��S)z�First two bytes of the hash are the name of the upper
        level directory, next two bytes are the name of the
        next level directoryr��)r&r'r%r#)r�	hashvaluerrr�_dirpathMs"zfilebundlestore._dirpathcCstj�|�|�|�S)N)r&r'r%r.)r�filenamerrr�	_filepathSszfilebundlestore._filepathcCsrtt�|����}|�|�}tj�|�st�|�t	|�
|�d��}|�|�Wd�|S1s2wY|S)Nswb)rr�sha1�digestr.r&r'r(r)rr0r)rrr/�dirpath�frrrrVs


��zfilebundlestore.writecCsVz t|�|�d��
}|��Wd�WS1swYWdSty*YdSw)Nsrb)rr0r�IOError)rrr4rrrrbs(��zfilebundlestore.readN)	rrr
rr*r.r0rrrrrrr<srcCsLg}|D]}|r|dkr|�|�q|r|dkr|�|�q|�|�q|S)z�Formats `args` with Infinitepush replacements.

    Hack to get `str.format()`-ed strings working in a BC way with
    bytes.
    s
{filename}s{handle})�append)�argsr/�handle�formatted_args�argrrr�format_placeholders_argsjsr;c@s,eZdZdd�Zdd�Zdd�Zdd�Zd	S)
�externalbundlestorecCs||_||_||_||_dS)a6
        `put_binary` - path to binary file which uploads bundle to external
            storage and prints key to stdout
        `put_args` - format string with additional args to `put_binary`
                     {filename} replacement field can be used.
        `get_binary` - path to binary file which accepts filename and key
            (in that order), downloads bundle from store and saves it to file
        `get_args` - format string with additional args to `get_binary`.
                     {filename} and {handle} replacement field can be used.
        N)�put_args�get_args�
put_binary�
get_binary)rr?r=r@r>rrrr*|s
zexternalbundlestore.__init__cCs<tjt�tj|�tjtjdd�}|��\}}|j}|||fS)NT)�stdout�stderr�	close_fds)	�
subprocess�Popenr�rapplyr�tonativestr�PIPE�communicate�
returncode)rr7�prArBrJrrr�_call_binary�s�
z externalbundlestore._call_binarycCs�t���K}|�|�|��|�d�t|j|jd�}|�|j	g|�\}}}|dkr1t
d|��|��}t|�dkrF|dWd�St
d|j	|f��1sRwYdS)Nr)r/s&Failed to upload to external store: %s�sBad output from %s: %s)
r�
namedtempfiler�flush�seekr;r=�namerLr?r	�
splitlines�len)rr�tempr9rJrArB�stdout_linesrrrr�s,


�

�����zexternalbundlestore.writecCsrt���+}t|j|j|d�}|�|jg|�\}}}|dkr$td|��|��Wd�S1s2wYdS)N)r/r8rs*Failed to download from external store: %s)	rrNr;r>rQrLr@rr)rr8rTr9rJrArBrrrr�s

�

��$�zexternalbundlestore.readN)rrr
r*rLrrrrrrr<{s
r<)NN)�
__future__rrr&rD�mercurial.noder�mercurial.pycompatr�	mercurialr�mercurial.utilsrr�	Exceptionr	r�objectrrr;r<rrrr�<module>s
.

https://t.me/RX1948 - 2025