a
    dl                     @   s   d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	 ddl
mZmZmZmZmZmZmZ ddlmZ erxdd	lmZ eZd
ZdZdZdZdZdZG dd deZG dd deZ G dd de Z!G dd de!Z"dS )z.Module with additional types used by the index    )b2a_hex)Path   )packunpack)Blob)
NamedTupleSequenceTYPE_CHECKINGTupleUnioncastList)PathLike)Repo)
BlobFilterBaseIndexEntry
IndexEntry	StageTypei  i 0  i @  i      c                   @   s@   e Zd ZdZdZee ddddZee	e
f eddd	ZdS )
r   z
    Predicate to be used by iter_blobs allowing to filter only return blobs which
    match the given list of directories or files.

    The given paths are given relative to the repository.
    pathsN)r   returnc                 C   s
   || _ dS )z
        :param paths:
            tuple or list of paths which are either pointing to directories or
            to files relative to the current repository
        N)r   )selfr    r   V/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/git/index/typ.py__init__.   s    zBlobFilter.__init__)
stage_blobr   c                 C   s   |d j }t|tr|nt|}| jD ]V}t|tr8|nt|}|j}|j}t|t|kr^q&tdd t||D r& dS q&dS )Nr   c                 s   s   | ]\}}||kV  qd S )Nr   ).0ijr   r   r   	<genexpr>@       z&BlobFilter.__call__.<locals>.<genexpr>TF)path
isinstancer   r   partslenallzip)r   r   Zblob_pathlikeZ	blob_pathZpathliker"   Zfilter_partsZ
blob_partsr   r   r   __call__6   s    

zBlobFilter.__call__)__name__
__module____qualname____doc__	__slots__r	   r   r   r   r   r   boolr(   r   r   r   r   r   #   s   r   c                   @   s   e Zd ZU dZeed< eed< eed< eed< edddZ	eed< edddZ
eed	< dZeed
< dZeed< dZeed< dZeed< dZeed< dS )BaseIndexEntryHelperzTyped namedtuple to provide named attribute access for BaseIndexEntry.
    Needed to allow overriding __new__ in child class to preserve backwards compat.modebinshaflagsr"   >LLr   ctime_bytesmtime_bytesdevinodeuidgidsizeN)r)   r*   r+   r,   int__annotations__bytesr   r   r4   r5   r6   r7   r8   r9   r:   r   r   r   r   r/   E   s   
r/   c                       s   e Zd ZdZeeeeeef eeeeeeeeeeeef f d d fddZ	e
dddZe
ddd	Zee
dd
dZeedddZedeed dddZdedddZ  ZS )r   aq  Small Brother of an index entry which can be created to describe changes
    done to the index in which case plenty of additional information is not required.

    As the first 4 data members match exactly to the IndexEntry type, methods
    expecting a BaseIndexEntry can also handle full IndexEntries even if they
    use numeric indices for performance reasons.
    )	inp_tupler   c                    s   t  j| g|R  S )zOOverride __new__ to allow construction from a tuple for backwards compatibility)super__new__)clsr>   	__class__r   r   r@   `   s    zBaseIndexEntry.__new__r   c                 C   s   d| j | j| j| jf S )Nz%o %s %i	%sr0   hexshastager"   r   r   r   r   __str__j   s    zBaseIndexEntry.__str__c                 C   s   d| j | j| j| jf S )Nz(%o, %s, %i, %s)rE   rH   r   r   r   __repr__m   s    zBaseIndexEntry.__repr__c                 C   s   t | jdS )zhex version of our shaascii)r   r1   decoderH   r   r   r   rF   p   s    zBaseIndexEntry.hexshac                 C   s   | j t@ t? S )a  Stage of the entry, either:

            * 0 = default stage
            * 1 = stage before a merge or common ancestor entry in case of a 3 way merge
            * 2 = stage of entries from the 'left' side of the merge
            * 3 = stage of entries from the right side of the merge

        :note: For more information, see http://www.kernel.org/pub/software/scm/git/docs/git-read-tree.html
        )r2   CE_STAGEMASKCE_STAGESHIFTrH   r   r   r   rG   u   s    zBaseIndexEntry.stager   blobrG   r   c                 C   s   | |j |j|t> |jfS )z9:return: Fully equipped BaseIndexEntry at the given stage)r0   r1   rN   r"   )rA   rP   rG   r   r   r   	from_blob   s    zBaseIndexEntry.from_blobr   )repor   c                 C   s   t || j| j| jS )z7:return: Blob using the information of this index entry)r   r1   r0   r"   )r   rR   r   r   r   to_blob   s    zBaseIndexEntry.to_blob)r   )r)   r*   r+   r,   r   r   r;   r=   r   r@   strrI   rJ   propertyrF   rG   classmethodr   rQ   rS   __classcell__r   r   rB   r   r   V   s"   

r   c                   @   sp   e Zd ZdZeeeef dddZeeeef dddZe	dd dd	d
Z
e	deed dddZdS )r   zAllows convenient access to IndexEntry data without completely unpacking it.

    Attributes usully accessed often are cached in the tuple whereas others are
    unpacked on demand.

    See the properties for a mapping between names and tuple indices.rD   c                 C   s   t tttf td| jS )z{
        :return:
            Tuple(int_time_seconds_since_epoch, int_nano_seconds) of the
            file's creation timer3   )r   r   r;   r   r4   rH   r   r   r   ctime   s    zIndexEntry.ctimec                 C   s   t tttf td| jS )z1See ctime property, but returns modification timer3   )r   r   r;   r   r5   rH   r   r   r   mtime   s    zIndexEntry.mtimer   )baser   c                 C   s2   t ddd}t|j|j|j|j||dddddfS )z
        :return:
            Minimal entry as created from the given BaseIndexEntry instance.
            Missing values will be set to null-like values

        :param base: Instance of type BaseIndexEntryr3   r   )r   r   r0   r1   r2   r"   )rA   rZ   timer   r   r   	from_base   s    zIndexEntry.from_baser   rO   c                 C   s6   t ddd}t|j|j|t> |j||dddd|jfS )z7:return: Minimal entry resembling the given blob objectr3   r   )r   r   r0   r1   rN   r"   r:   )rA   rP   rG   r[   r   r   r   rQ      s    zIndexEntry.from_blobN)r   )r)   r*   r+   r,   rU   r   r;   rX   rY   rV   r\   r   rQ   r   r   r   r   r      s   
r   N)#r,   binasciir   pathlibr   utilr   r   Zgit.objectsr   typingr   r	   r
   r   r   r   r   Z	git.typesr   Zgit.repor   r;   r   __all__ZCE_NAMEMASKrM   ZCE_EXTENDEDZCE_VALIDrN   objectr   r/   r   r   r   r   r   r   <module>   s&   $"6