HEX
Server: LiteSpeed
System: Linux s787.bom1.mysecurecloudhost.com 4.18.0-477.13.1.lve.el8.x86_64 #1 SMP Thu Jun 1 16:40:47 EDT 2023 x86_64
User: mobilech (5348)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/git/refs/__pycache__/log.cpython-310.pyc
o

;jD1�
@s�ddgZddlmZddlZddlZddlmZddlmZm	Z	m
Z
ddlmZm
Z
mZmZmZmZmZddlmZmZmZmZmZdd	lmZer^dd
lmZddlmZmZddl m!Z!Gd
d�dee"e"eee#e#fe"f�Z$Gdd�dee$e�Z%dS)�RefLog�RefLogEntry�)�mmapN)�defenc)�Serializable�altz_to_utctz_str�
parse_date)�Actor�LockedFD�LockFile�assure_directory_exists�
bin_to_hex�file_contents_ro_filepath�to_native_path)�Iterator�List�Tuple�
TYPE_CHECKING�Union)�PathLike)�BytesIO)�GitConfigParser�SectionConstraint)�SymbolicReferencec@s�eZdZdZe�d�ZdZdefdd�Z	defdd�Z
edefd	d
��Zedefdd��Z
edefd
d��Zedeeeffdd��Zedefdd��Zedededededededdfdd��Zededdfdd��ZdS)rz;Named tuple allowing easy access to the revlog data fields.z^[0-9A-Fa-f]{40}$��returncCs|��S)z1Representation of ourselves in git reflog format.)�format��selfrr�@/opt/saltstack/salt/lib/python3.10/site-packages/git/refs/log.py�__repr__0szRefLogEntry.__repr__c
Cs8|j}|j}d�|j|j|j|j|dt|d�|j�S)z9:return: A string suitable to be placed in a reflog file.z{} {} {} <{}> {!s} {}	{}
r�)	�actor�timer�	oldhexsha�	newhexsha�name�emailr�message)rZactr#rrrr4s
�zRefLogEntry.formatcC�|dS)z>The hexsha to the commit the ref pointed to before the change.rrrrrrr$B�zRefLogEntry.oldhexshacCr))zAThe hexsha to the commit the ref now points to, after the change.r!rrrrrr%Gr*zRefLogEntry.newhexshacCr))z!Actor instance, providing access.�rrrrrr"Lr*zRefLogEntry.actorcCr))z~Time as tuple:

        * [0] = ``int(time)``
        * [1] = ``int(timezone_offset)`` in :attr:`time.altzone` format
        �rrrrrr#QszRefLogEntry.timecCr))z=Message describing the operation that acted on the reference.�rrrrrr(Zr*zRefLogEntry.messager$r%r"r#�	tz_offsetr(cCs,t|t�std|��t|||||f|f�S)z/:return: New instance of a :class:`RefLogEntry`zNeed actor instance, got %s)�
isinstancer	�
ValueErrorr)�clsr$r%r"r#r.r(rrr�new_s
zRefLogEntry.new�linec
Cs�|�t�}|�dd�}t|�dkr|dd}}nt|�dkr$|\}}ntdt|���|dd�}|dd	�}||fD]}|j�|�sKtd
|f��q<|�dd�}	|	d
krZtd��t	�
|d|	d��}
t||	dd��\}}t|||
||f|f�S)z�:return: New :class:`RefLogEntry` instance from the given revlog line.

        :param line:
            Line bytes without trailing newline

        :raise ValueError:
            If `line` could not be parsed.
        �	r!rNr+z5Line must have up to two TAB-separated fields. Got %s�(�)�QzInvalid hexsha: %r�>�R���zMissing token: >)
�decoder�split�lenr0�repr�_re_hexsha_only�match�findr	Z_from_stringrr)
r1r3Zline_str�fields�info�msgr$r%ZhexshaZ	email_endr"r#r.rrr�	from_lineos&


�zRefLogEntry.from_lineN)�__name__�
__module__�__qualname__�__doc__�re�compiler?�	__slots__�strr r�propertyr$r%r	r"r�intr#r(�classmethodr2�bytesrErrrrr)sD
�������cs2eZdZdZdZd,deedfddf�fdd�
Zd,deedfddfdd	�Zd-d
d�Z	e
deddfdd
��Ze
dddefdd��Z
e
deedefdeefdd��Ze
dededdfdd��Zdeddfdd�Ze
	d.deedddfded ed!ed"ed#eddfd$d%��Zd/d&d'�Zd0d(d)�Zd0d*d+�Z�ZS)1rakA reflog contains :class:`RefLogEntry`\s, each of which defines a certain state
    of the head in question. Custom query methods allow to retrieve log entries by date
    or by other criteria.

    Reflog entries are ordered. The first added entry is first in the list. The last
    entry, i.e. the last change of the head or reference, is last in the list.
    )�_pathN�filepathrcst��|�}|S�N)�super�__new__)r1rS�inst��	__class__rrrV�szRefLog.__new__cCs||_|dur
|��dSdS)z�Initialize this instance with an optional filepath, from which we will
        initialize our data. The path is also used to write changes back using the
        :meth:`write` method.N)rR�_read_from_file)rrSrrr�__init__�s�zRefLog.__init__cCsNz
t|jddd�}Wn
tyYdSwz|�|�W|��dS|��w)NT)�streamZ
allow_mmap)rrR�OSError�_deserialize�close)rZfmaprrrrZ�s�zRefLog._read_from_filecCs||�S)a+
        :return:
            A new :class:`RefLog` instance containing all entries from the reflog at the
            given `filepath`.

        :param filepath:
            Path to reflog.

        :raise ValueError:
            If the file could not be read or was corrupted in some way.
        r)r1rSrrr�	from_file�s
zRefLog.from_file�refrcCst|�|j|j��S)a�
        :return:
            String to absolute path at which the reflog of the given ref instance would
            be found. The path is not guaranteed to point to a valid file though.

        :param ref:
            :class:`~git.refs.symbolic.SymbolicReference` instance

        :raise ValueError:
            If `ref.path` is invalid or escapes the repository's reflog directory.
        )rZ_get_validated_reflog_pathZrepo�path)r1rarrrrb�s
zRefLog.pathr\rccsP�tj}t|t�rt|�}t|t�sJ�n|}	|��}|s dS||���Vq)a-
        :return:
            Iterator yielding :class:`RefLogEntry` instances, one for each line read
            from the given stream.

        :param stream:
            File-like object containing the revlog in its native format or string
            instance pointing to a file to read.
        TN)rrEr/rMrr�readline�strip)r1r\Z	new_entry�_streamr3rrr�iter_entries�s�
�zRefLog.iter_entries�indexrcCs�t|d��>}|dkrt�|��|���Wd�St|d�D]}|��}|s4td|d�d���q"t�|���Wd�S1sFwYdS)a\
        :return:
            :class:`RefLogEntry` at the given index.

        :param filepath:
            Full path to the index file from which to read the entry.

        :param index:
            Python list compatible index, i.e. it may be negative to specify an entry
            counted from the end of the list.

        :raise IndexError:
            If the entry didn't exist.

        :note:
            This method is faster as it only parses the entry at index, skipping all
            other lines. Nonetheless, the whole file has to be read if the index is
            negative.
        �rbrNr!zIndex file ended at line z , before given index was reached)�openrrE�	readlinesrd�rangerc�
IndexError)r1rSrg�fp�ir3rrr�entry_at�s��$�zRefLog.entry_atcCsTt|�}t|dd�|jddd�}z|�|�|��WdSty)|���w)z�Write the contents of the reflog instance to a file at the given filepath.

        :param filepath:
            Path to file. Parent directories are assumed to exist.
        T��is_file)�writer\N)r
rri�
_serializeZcommit�
BaseExceptionZrollback)rrSZlfdrmrrr�to_files
�zRefLog.to_fileT�
config_readerrr�	oldbinsha�	newbinshar(rrcCs�t|�dkst|�dkrtd��t|dd�|�d�d}t|t�r%|}nt�|�}tt|��	d�t|��	d�|t
t���tj
f|f�}	|rrt|�}
|
��t|d�}z|�|	���t��W|��|
��|	S|��|
��w|	S)	a�Append a new log entry to the revlog at filepath.

        :param config_reader:
            Configuration reader of the repository - used to obtain user information.
            May also be an :class:`~git.util.Actor` instance identifying the committer
            directly or ``None``.

        :param filepath:
            Full path to the log file.

        :param oldbinsha:
            Binary sha of the previous commit.

        :param newbinsha:
            Binary sha of the current commit.

        :param message:
            Message describing the change to the reference.

        :param write:
            If ``True``, the changes will be written right away.
            Otherwise the change will not be written.

        :return:
            :class:`RefLogEntry` objects which was appended to the log.

        :note:
            As we are append-only, concurrent access is not a problem as we do not
            interfere with readers.
        �z&Shas need to be given in binary formatTrp�
r�ascii�ab)r=r0rr<r/r	�	committerrr
r;rO�_timer#�altzonerZ_obtain_lock_or_raiserirrr�encoderr_Z
_release_lock)r1rvrSrwrxr(rr�
first_liner}�entryZlf�fdrrr�append_entry,s6)

��

�
zRefLog.append_entrycCs"|jdur	td��|�|j�|S)zkWrite this instance's data to the file we are originating from.

        :return:
            self
        NzBInstance was not initialized with a path, use to_file(...) instead)rRr0rurrrrrrts
zRefLog.writecCs&|j}|D]}||���t��q|SrT)rrrr�r)rr\rr�errrrs�szRefLog._serializecCs|�|�|��|SrT)�extendrf)rr\rrrr^�szRefLog._deserializerT)rN)T)rr)r\rrr)rFrGrHrIrLrrrVr[rZrPr`rMrbrrrrfrOrorur	rQ�boolr�rrrsr^�
__classcell__rrrXrr�sF 
	"#��������
G
	)&�__all__rrJr#r~Z
git.compatrZgit.objects.utilrrrZgit.utilr	r
rrr
rr�typingrrrrrZ	git.typesr�iorZ
git.configrrZgit.refsrrMrOrrrrrr�<module>s$&m