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/dulwich/__pycache__/index.cpython-39.pyc
a

�~�_:i�
@s�dZddlZddlZddlZddlZddlZddlmZmZm	Z	m
Z
mZmZm
Z
mZmZmZe
rlddlmZddlmZddlmZmZmZmZmZmZddlmZmZe�dgd	��Z d
Z!dZ"dZ#d
Z$dd�Z%dd�Z&dd�Z'dd�Z(dd�Z)dd�Z*ed�dd�Z+dd�Z,daeeeee-d�d d!�Z.dbee
e/e fee-dd"�d#d$�Z0e-e-d%�d&d'�Z1Gd(d)�d)e2�Z3d*eee/e/e-fe/d+�d,d-�Z4d*e3e/d.�d/d0�Z5dcee/e	e/gee/e-ffd*ee/eeeee/ee/feee-ee-feee/ee/ffd2�d3d4�Z6dde/e-ee-d5�d6d7�Z7ded:d;�Z8d<Z9d=d>�Z:d?d@�Z;e:fdAdB�Z<d8e:fdCdD�Z=dfdEdF�Z>dgdGdH�Z?dIdJ�Z@dKdL�ZAdhe3dM�dNdO�ZBejC�DdP�ZEe/dQ�dRdS�ZFdTdU�ZGdidVdW�ZHdjed*dX�dYdZ�ZId[d\�ZJdkd]d^�ZKd_d`�ZLdS)lz%Parser for the git index file format.�N)
�Any�BinaryIO�Callable�Dict�List�Optional�
TYPE_CHECKING�Iterable�Iterator�Tuple)�BaseObjectStore)�GitFile)�Blob�S_IFGITLINK�S_ISGITLINK�Tree�
hex_to_sha�
sha_to_hex)�
SHA1Reader�
SHA1Writer�
IndexEntry)
�ctime�mtime�dev�ino�mode�uid�gid�size�sha�flagsi0i�i@�cCs<z|�dd�\}}Wnty.d|fYS0||fSdS)z�Split a /-delimited path into a directory part and a basename.

    Args:
      path: The path to split.
    Returns:
      Tuple with directory name and basename
    �/��N)�rsplit�
ValueError)�path�dirname�basename�r*�//usr/lib/python3/dist-packages/dulwich/index.py�	pathsplitIs
r,cGsd�dd�|D��S)zJoin a /-delimited path.

    r"cSsg|]}|r|�qSr*r*)�.0�pr*r*r+�
<listcomp>]r$zpathjoin.<locals>.<listcomp>)�join)�argsr*r*r+�pathjoinYsr2cCst�d|�d��S)zRead a cache time.

    Args:
      f: File-like object to read from
    Returns:
      Tuple with seconds and nanoseconds
    �>LL�)�struct�unpack�read��fr*r*r+�read_cache_time`sr:cCspt|t�r|df}n@t|t�rBt|d�\}}t|�t|d�f}nt|t�sTt|��|�tjdg|�R��dS)z�Write a cache time.

    Args:
      f: File-like object to write to
      t: Time to write (as int, float or tuple with secs and nsecs)
    rg�?iʚ;r3N)	�
isinstance�int�float�divmod�tuple�	TypeError�writer5�pack)r9�tZsecsZnsecsr*r*r+�write_cache_timeks



rDcCs�|��}t|�}t|�}t�d|�d��\}}}}}}	}
}|�|d@�}|��|dd@}
|�||
|���|||||||||	t|
�|d@fS)z�Read an entry from a cache file.

    Args:
      f: File-like object to read from
    Returns:
      tuple with: device, inode, mode, uid, gid, size, sha, flags
    z>LLLLLL20sH�.i�r4�����)�tellr:r5r6r7r)r9�beginoffsetrrrrrrrrrr �name�	real_sizer*r*r+�read_cache_entry|s��rLc
Cs�|��}|\}}}}}}}	}
}}}
t||�t||�t|�|
d@B}
|�t�d|d@|d@||	|
|t|�|
�	�|�|�|��|dd@}|�d|||���dS)z�Write an index entry to a file.

    Args:
      f: File object
      entry: Entry to write, tuple with:
        (name, ctime, mtime, dev, ino, mode, uid, gid, size, sha, flags)
    rGs>LLLLLL20sHl��r4rF�N)rHrD�lenrAr5rBr)r9�entryrIrJrrrrrrrrrr rKr*r*r+�write_cache_entry�s

�
rPr8ccs\|�d�}|dkrtd|��t�d|�d��\}}|dvs@J�t|�D]}t|�VqHdS)z4Read an index file, yielding the individual entries.��DIRCzInvalid index file header: %r�>LLr4)r#r!N)r7�AssertionErrorr5r6�rangerL)r9�header�versionZnum_entries�ir*r*r+�
read_index�s
rYcCs.i}t|�D]}t|dd��||d<q|S)zcRead an index file and return it as a dictionary.

    Args:
      f: File object to read from
    r#Nr)rYr)r9�ret�xr*r*r+�read_index_dict�sr\)r9�entriesrWcCsF|durt}|�d�|�t�d|t|���|D]}t||�q2dS)z�Write an index file.

    Args:
      f: File-like object to write to
      version: Version number to write
      entries: Iterable over the entries to write
    NrRrS)�DEFAULT_VERSIONrAr5rBrNrP)r9r]rWr[r*r*r+�write_index�s

r_)r9r]rW�returncCs<g}t|�D]}|�|ft||��qt|||d�dS)z@Write an index file based on the contents of a dictionary.

    �rWN)�sorted�appendr?r_)r9r]rWZentries_listrJr*r*r+�write_index_dict�srd)rr`cCsJt�|�rtjSt�|�r tjSt|�r,tStjdB}|d@rF|dO}|S)z�Cleanup a mode value.

    This will return a mode that can be stored in a tree object.

    Args:
      mode: Mode to clean up.
    Returns:
      mode
    i��@�I)�stat�S_ISLNK�S_IFLNK�S_ISDIR�S_IFDIRrr�S_IFREG)rrZr*r*r+�cleanup_mode�s



rmc@s�eZdZdZdd�Zedd��Zdd�Zdd	�d
d�Zdd
�Z	e
d	�dd�Zee
d�dd�Zeed	�dd�Zeed�dd�Zee
d�dd�Zeeeee
fd	�dd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd/d+d,�Zd-d.�ZdS)0�IndexzA Git Index file.cCs ||_d|_|��|��dS)zVOpen an index file.

        Args:
          filename: Path to the index file
        N)�	_filename�_version�clearr7)�self�filenamer*r*r+�__init__�szIndex.__init__cCs|jS�N)ro�rrr*r*r+r'sz
Index.pathcCsd|jj|jfS)Nz%s(%r))�	__class__�__name__rorvr*r*r+�__repr__szIndex.__repr__N)r`cCsBt|jd�}z&t|�}t||j|jd�W|��n
|��0dS)z(Write current contents of index to disk.�wbraN)r
rorrd�_bynamerp�close)rrr9r*r*r+rAs
zIndex.writecCs�tj�|j�sdSt|jd�}zbt|�}t|�D]}t|dd��||d<q0|�tj�	|j�|�
�d�|��W|��n
|��0dS)z)Read current contents of index from disk.N�rbr#r�)
�osr'�existsror
rrYrr7�getsizerHZ	check_shar|)rrr9r[r*r*r+r7s 
z
Index.readcCs
t|j�S)z%Number of entries in this index file.)rNr{rvr*r*r+�__len__sz
Index.__len__)rJr`cCs
|j|S)z�Retrieve entry by relative path.

        Returns: tuple with (ctime, mtime, dev, ino, mode, uid, gid, size, sha,
            flags)
        �r{�rrrJr*r*r+�__getitem__#szIndex.__getitem__cCs
t|j�S)z%Iterate over the paths in this index.)�iterr{rvr*r*r+�__iter__+szIndex.__iter__)r'r`cCs
||jS)z6Return the (git object) SHA1 for the object at a path.)r�rrr'r*r*r+�get_sha1/szIndex.get_sha1cCs
||jS)z4Return the POSIX file mode for the object at a path.�rr�r*r*r+�get_mode3szIndex.get_modeccs*|D] }||}||jt|j�fVqdS)z=Iterate over path, sha, mode tuples for use with commit_tree.N�rrmr)rrr'rOr*r*r+�iterobjects7szIndex.iterobjectscCsddl}|�dt�|��S)NrzUse iterobjects() instead.)�warnings�warn�PendingDeprecationWarningr�)rrr�r*r*r+�	iterblobs=szIndex.iterblobscCs
i|_dS)z$Remove all contents from this index.Nr�rvr*r*r+rqBszIndex.clearcCs0t|t�sJ�t|�dksJ�t|�|j|<dS)N�
)r;�bytesrNrr{)rrrJr[r*r*r+�__setitem__FszIndex.__setitem__cCst|t�sJ�|j|=dSru)r;r�r{r�r*r*r+�__delitem__LszIndex.__delitem__cCs
|j��Sru�r{�itemsrvr*r*r+�	iteritemsPszIndex.iteritemscCs
|j��Srur�rvr*r*r+r�SszIndex.itemscCs|��D]\}}|||<qdSru)r�)rrr]rJ�valuer*r*r+�updateVszIndex.updateFc#s@�fdd�}t�j��||||d�D]\}}}|||fVq$dS)aFind the differences between the contents of this index and a tree.

        Args:
          object_store: Object store to use for retrieving tree contents
          tree: SHA1 of the root tree
          want_unchanged: Whether unchanged files should be reported
        Returns: Iterator over tuples with (oldpath, newpath), (oldmode,
            newmode), (oldsha, newsha)
        cs�|}|jt|j�fSrur�)r'rOrvr*r+�lookup_entrydsz-Index.changes_from_tree.<locals>.lookup_entry)�want_unchangedN)�changes_from_treer{�keys)rr�object_store�treer�r�rJrrr*rvr+r�Zs
�zIndex.changes_from_treecCst||���S)z�Create a new tree from an index.

        Args:
          object_store: Object store to save the tree in
        Returns:
          Root tree SHA
        ��commit_treer�)rrr�r*r*r+�commitlszIndex.commit)F)rx�
__module__�__qualname__�__doc__rt�propertyr'ryrAr7r<r�r�rr�r
r�r�r�r	rr�r�rqr�r�r�r�r�r�r�r*r*r*r+rn�s,
	
rnr)r��blobsr`cs^dii���fdd��|D]*\}}}t|�\}}�|�}||f||<q���fdd���d�S)z�Commit a new tree.

    Args:
      object_store: Object store to add trees to
      blobs: Iterable over blob path, sha, mode entries
    Returns:
      SHA1 of the created tree.
    r$csJ|�vr�|St|�\}}�|�}t|t�s2J�i}|||<|�|<|Sru)r,r;r�)r'r(r)rCZnewtree)�add_tree�treesr*r+r��szcommit_tree.<locals>.add_treecsbt�}�|��D]>\}}t|t�r:tj}�t||��}n|\}}|�|||�q��|�|j	Sru)
rr�r;�dictrgrkr2�add�
add_object�id)r'r�r)rOrr)�
build_treer�r�r*r+r��s

zcommit_tree.<locals>.build_tree)r,)r�r�r'rr�	tree_pathr)r�r*)r�r�r�r�r+r�wsr�)r��indexr`cCst||���S)z�Create a new tree from an index.

    Args:
      object_store: Object store to save the tree in
      index: Index file
    Note: This function is deprecated, use index.commit() instead.
    Returns: Root tree sha.
    r�)r�r�r*r*r+�commit_index�s	r�F)�namesr�r�r�r`c	cs�t|�}|dur�|�|�D]|\}}}z||�\}	}
Wn*ty^|df|df|dffVYq0|�|�|s~|	|ks~|
|kr||f||
f||	ffVq|D]@}z||�\}	}
Wnty�Yq�0d|fd|
fd|	ffVq�dS)a�Find the differences between the contents of a tree and
    a working copy.

    Args:
      names: Iterable of names in the working copy
      lookup_entry: Function to lookup an entry in the working copy
      object_store: Object store to use for retrieving tree contents
      tree: SHA1 of the root tree, or None for an empty tree
      want_unchanged: Whether unchanged files should be reported
    Returns: Iterator over tuples with (oldpath, newpath), (oldmode, newmode),
        (oldsha, newsha)
    N)�set�iter_tree_contents�KeyError�remove)r�r�r�r�r�Zother_namesrJrrZ	other_shaZ
other_moder*r*r+r��s 
r�)�hex_shar rcCs:|durt|j�}t|j|j|j|j||j|j|j	||�
S)z�Create a new index entry from a stat value.

    Args:
      stat_val: POSIX stat_result instance
      hex_sha: Hex sha of the object
      flags: Index flags
    N)
rm�st_moder�st_ctime�st_mtime�st_dev�st_ino�st_uid�st_gid�st_size)Zstat_valr�r rr*r*r+�index_entry_from_stat�s


�r�T�utf-8cCs zt�|�}Wnty$d}Yn0|��}t�|�rr|rFt�|�tjdkrd|�	|�}|�	|�}t�
||�n�|dur�|jt|�kr�t
|d��.}|��|kr�|Wd�SWd�n1s�0Yt
|d��}|�|�Wd�n1s�0Y|�rt�||�t�|�S)aSBuild a file or symlink on disk based on a Git object.

    Args:
      obj: The git object
      mode: File mode
      target_path: Path to write to
      honor_filemode: An optional flag to honor core.filemode setting in
        config file, default is core.filemode=True, change executable bit
    Returns: stat object for the file
    N�win32r}rz)r�lstat�FileNotFoundErrorZ
as_raw_stringrgrh�unlink�sys�platform�decode�symlinkr�rN�openr7rA�chmod)�blobrZtarget_path�honor_filemode�
tree_encodingZoldstat�contentsr9r*r*r+�build_file_from_blob�s*





0(r�)�.git�.s..r$cCs|��tvSru)�lower�INVALID_DOTNAMES)�elementr*r*r+�validate_path_element_defaultsr�cCs*|�d���}|tvrdS|dkr&dSdS)Ns. Fsgit~1T)�rstripr�r�)r��strippedr*r*r+�validate_path_element_ntfs sr�cCs&|�d�}|D]}||�sdSqdS)z2Default path validator that just checks for .git/.r"FTN)�split)r'Zelement_validator�partsr.r*r*r+�
validate_path)s

r�cCst|�}t|t�st�|�}|�|�D]�}t|j|�s8q&t||j�}tj�	tj�
|��sjt�tj�
|��t|j
�r�tj�|�s�t�|�t�|�}	n||j}
t|
|j
||d�}	|r�t|j
�r�|j
|	j|	j|	j|	j|	j|	j|	j|	j|	jf
}|	�|�}	t|	|jd�||j<q&|��dS)a�Generate and materialize index from a tree

    Args:
      tree_id: Tree to materialize
      root_path: Target dir for materialized index files
      index_path: Target path for generated index
      object_store: Non-empty object store holding tree contents
      honor_filemode: An optional flag to honor core.filemode setting in
        config file, default is core.filemode=True, change executable bit
      validate_path_element: Function to validate path elements to check
        out; default just refuses .git and .. directories.

    Note: existing index is wiped and contents are not merged
        in a working dir. Suitable only for fresh clones.
    )r�rN)rnr;r�r�fsencoder�r�r'�_tree_to_fs_pathr�r(�makedirsrr�isdir�mkdirr�rr�r�r��st_nlinkr�r�r��st_atimer�r�rwr�rA)�	root_pathZ
index_pathr�Ztree_idr�Zvalidate_path_elementr�rO�	full_path�st�objZst_tupler*r*r+�build_index_from_tree3s2





��
r�cCs�t|t�sJ�t�}t�|�rTtjdkrFt�|�}t�	|��
|�|_q�t�	|�|_n4t|d��}|�
�|_Wd�n1s~0Y|S)��Create a blob from a path and a stat object.

    Args:
      fs_path: Full file system path to file
      st: A stat object
    Returns: A `Blob` object
    r�r}N)r;r�rrgrhr�r�r�fsdecode�readlink�encode�datar�r7)�fs_pathrr�r�r9r*r*r+�blob_from_path_and_modeks


(r�cCst||j|�S)r�)r�r�)r�r�r�r*r*r+�blob_from_path_and_stat�sr�cCsrddlm}ddlm}t|t�s,t�|�}z||�}Wn|yLYdS0z
|��WSt	ylYdS0dS)z�Read the head commit of a submodule.

    Args:
      path: path to the submodule
    Returns: HEAD sha, None if not a valid head/repository
    r)�NotGitRepository)�RepoN)
Zdulwich.errorsr�Zdulwich.repor�r;�strrr��headr�)r'r�r�Zrepor*r*r+�read_submodule_head�s


r�cCs6tj�tj�|d��r.t|�}|j|kr2dSndSdS)a�Check if a directory has changed after getting an error.

    When handling an error trying to create a blob from a path, call this
    function. It will check if the path is a directory. If it's a directory
    and a submodule, check the submodule head to see if it's has changed. If
    not, consider the file as changed as Git tracked a file and not a
    directory.

    Return true if the given path should be considered as changed and False
    otherwise or if the path is not a directory.
    r�TF)rr'r�r0r�r)r�rOr�r*r*r+�_has_directory_changed�s

r�)r�c	cs�t|t�st�|�}|��D]�\}}t||�}zft�|�}t�|j	�rZt
||�rV|VWqt�|j	�svt�|j	�svWqt
||�}|dur�|||�}Wnty�|VYq0|j|jkr|VqdS)z�Walk through an index and check for differences against working tree.

    Args:
      index: index to check
      root_path: path in which to find files
    Returns: iterator over paths with unstaged changes
    N)r;r�rr�r�r�r�rgrjr�r��S_ISREGrhr�r�r�r)r�r�Zfilter_blob_callbackr�rOr�r�r�r*r*r+�get_unstaged_changes�s&	





r��ascii)r�cCs6t|t�sJ�tdkr$|�dt�}n|}tj�||�S)z�Convert a git tree path to a file system path.

    Args:
      root_path: Root filesystem path
      tree_path: Git tree path as bytes

    Returns: File system path.
    r")r;r��os_sep_bytes�replacerr'r0)r�r�Zsep_corrected_pathr*r*r+r��s
	r�cCs8t|t�st�|�}n|}tdkr0|�td�}n|}|S)z�Convert a file system path to a git tree path.

    Args:
      fs_path: File system path.

    Returns:  Git tree path as bytes
    r")r;r�rr�r�r�)r�Z
fs_path_bytesr�r*r*r+�_fs_to_tree_path�s
r�cCs�t|t�sJ�t�|�}t�|j�rbtj�tj�	|d��r^t
|�}|durNdSt||dtd�SdSt�
|j�szt�|j�r�t||�}|dur�|�|�t||jd�SdS)agCreate an index from a filesystem path.

    This returns an index value for files, symlinks
    and tree references. for directories and
    non-existant files it returns None

    Args:
      path: Path to create an index entry for
      object_store: Optional object store to
        save new blobs in
    Returns: An index entry; None for directories
    r�Nrr�)r;r�rr�rgrjr�r'r�r0r�r�rr�rhr�r�r�)r'r�r�r�r�r*r*r+�index_entry_from_path	s"

�

r��r�c
csN|D]D}t||�}zt||d�}Wnttfy<d}Yn0||fVqdS)z�Iterate over current versions of index entries on disk.

    Args:
      paths: Paths to iterate over
      root_path: Root path to access from
      store: Optional store to save new blobs in
    Returns: Iterator over path, index_entry
    r�N)r�r�r��IsADirectoryError)�pathsr�r�r'r.rOr*r*r+�iter_fresh_entries*s


rccsJddl}|�td�t||dd�D]"}|ddur>||d=q"|Vq"dS)aRIterate over versions of blobs on disk referenced by index.

    Don't use this function; it removes missing entries from index.

    Args:
      index: Index file
      root_path: Root path to access from
      include_deleted: Include deleted entries with sha and
        mode set to None
    Returns: Iterator over path, sha, mode
    rNzUse iter_fresh_objects instead.T)�include_deletedr#)r�r�r��iter_fresh_objects)r�r�r�rOr*r*r+�iter_fresh_blobs=s��
rccsRt|||d�D]>\}}|dur0|rL|ddfVqt|�}||jt|j�fVqdS)a7Iterate over versions of objecs on disk referenced by index.

    Args:
      root_path: Root path to access from
      include_deleted: Include deleted entries with sha and
        mode set to None
      object_store: Optional object store to report new items to
    Returns: Iterator over path, sha, mode
    r�N)rrrrmr)rr�rr�r'rOr*r*r+rTs�rcCs t||�D]\}}|||<q
dS)z�Refresh the contents of an index.

    This is the equivalent to running 'git commit -a'.

    Args:
      index: Index to update
      root_path: Root filesystem path
    N)r)r�r�r'rOr*r*r+�
refresh_indexis	r)N)N)F)N)Tr�)r�)r�)N)N)N)FN)Mr��collectionsrrgr5r��typingrrrrrrrr	r
rZdulwich.object_storerZdulwich.filer
Zdulwich.objectsrrrrrrZdulwich.packrr�
namedtuplerZFLAG_STAGEMASKZ
FLAG_VALIDZ
FLAG_EXTENDEDr^r,r2r:rDrLrPrYr\r<r_r�rdrm�objectrnr�r�r�r�r�r�r�r�r�r�r�r�r�r�r��sepr�r�r�r�r�rrrrr*r*r*r+�<module>s�0
 ������+�����0���
*	�
8

%
"���