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__/walk.cpython-39.pyc
a

�~�_E>�@s�dZddlZddlZddlmZddlmZmZmZm	Z	ddl
mZddlm
Z
dZdZeefZd	ZGd
d�de�ZGdd
�d
e�ZGdd�de�Zdd�fdd�ZdS)z=General implementation of walking commits and their contents.�N)�chain)�RENAME_CHANGE_TYPES�tree_changes�tree_changes_for_merge�RenameDetector)�MissingCommitError)�Tag�dateZtopo�c@s*eZdZdZdd�Zd	dd�Zdd�ZdS)
�	WalkEntryz1Object encapsulating a single result from a walk.cCs(||_|j|_|j|_i|_|j|_dS�N)�commit�store�_store�get_parents�_get_parents�_changes�rename_detector�_rename_detector)�self�walkerr
�r�./usr/lib/python3/dist-packages/dulwich/walk.py�__init__5s
zWalkEntry.__init__Nc
	sL�j�|�}|du�rB�j}��|�s0t}d}n�t��|��dkr�t}�j��|�dj}|r�|��jj	|�\}}�j|}nvt
}�fdd���|�D�}|r��fdd�|D�}g}|D]:}	z|	��jj	|�\}}
Wnty�Yq�0|�|
�q�|j}|�r �j|}|��jj	|�\}}t
|�j||�jd��}|�j|<�j|S)a-Get the tree changes for this entry.

        Args:
          path_prefix: Portion of the path in the repository to
            use to filter changes. Must be a directory name. Must be
            a full, valid, path reference (no partial names or wildcards).
        Returns: For commits with up to one parent, a list of TreeChange
            objects; if the commit has no parents, these will be relative to
            the empty tree. For merge commits, a list of lists of TreeChange
            objects; see dulwich.diff.tree_changes_for_merge.
        N�rcsg|]}�j|j�qSr)r�tree��.0�p�rrr�
<listcomp>Ysz%WalkEntry.changes.<locals>.<listcomp>csg|]}�j|�qSr)rrrrrr \�)r)r�getr
rr�lenrrZlookup_path�__getitem__r�KeyError�append�listr)
rZpath_prefix�cachedr
Zchanges_func�parent�modeZsubtree_shaZparent_treesr�stZcommit_tree_shaZcommit_treerrr�changes<sX

�
��
��
zWalkEntry.changescCsd|jj|��fS)Nz!<WalkEntry commit=%s, changes=%r>)r
�idr,rrrr�__repr__us�zWalkEntry.__repr__)N)�__name__�
__module__�__qualname__�__doc__rr,r.rrrrr2s
9rc@s4eZdZdZdd�Zdd�Zdd�Zdd	�ZeZd
S)�_CommitTimeQueuez3Priority queue of WalkEntry objects by commit time.cCsx||_|j|_|j|_|j|_g|_t�|_	t�|_
t�|_|j|_
d|_t|_d|_t|j|j�D]}|�|�qddS)NF)�_walkerrrrr�excluded�	_excluded�_pq�set�_pq_set�_seen�_done�since�	_min_time�_last�_MAX_EXTRA_COMMITS�_extra_commits_left�_is_finishedr�include�_push)rr�	commit_idrrrr}sz_CommitTimeQueue.__init__cCs�z|j|}Wnty(t|��Yn0t|t�rH|�|jd�dS|}|j|jvr�|j|j	vr�t
�|j|j
|f�|j�|j�|j�|j�dS�Nr)rr%r�
isinstancerrC�objectr-r9r;�heapq�heappushr7�commit_time�addr:)rZ	object_id�objr
rrrrC�s
z_CommitTimeQueue._pushcCs^|j}|j}|g}|rZ|��}|�|�D].}||vrL||vrL|�|j|�|�|�q(qdSr)r6r:�poprr&rrK)rr
r5�seen�todor)rrr�_exclude_parents�sz!_CommitTimeQueue._exclude_parentscs.�jr
dS�j�r$t��j�\}}|j}�j�|�|�jvr@q
�j�|���	|�D]}��
|�qVd}|�jv}|r̈�|��jr�t
�fdd��jD��r̈jd\}}�jr�|j�jjkr�d}nd}�jdur�|j�jkr�d}|r�t�_n�jd8_�j�s�q$|s
|�_t�j|�Sq
d�_dS)NTc3s|]\}}|j�jvVqdSr)r-r6)r�_�crrr�	<genexpr>�s�z(_CommitTimeQueue.next.<locals>.<genexpr>rFr)rAr7rH�heappopr-r9�remover;rKrrCr6rP�allr>rJr=r?r@rr4)rrQr
Zsha�	parent_idZreset_extra_commitsZis_excluded�nrrr�next�sH


�

�z_CommitTimeQueue.nextN)	r/r0r1r2rrCrPrY�__next__rrrrr3zs5r3c@sdeZdZdZdeddddddddd�efdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�ZdS)�Walkerz�Object for performing a walk of commits in a store.

    Walker objects are initialized with a store and other options and can then
    be treated as iterators of Commit objects.
    NFcCs|jSr��parents�r
rrr�<lambda>�r!zWalker.<lambda>cCs�|tvrtd|��||_t|t�r*|g}||_t|p8g�|_||_||_	||_
|r\t|�p^d|_|	rr|srt|�}||_
||_|	|_|
|_||_d|_|
|�|_t��|_dS)a�Constructor.

        Args:
          store: ObjectStore instance for looking up objects.
          include: Iterable of SHAs of commits to include along with their
            ancestors.
          exclude: Iterable of SHAs of commits to exclude along with their
            ancestors, overriding includes.
          order: ORDER_* constant specifying the order of results.
            Anything other than ORDER_DATE may result in O(n) memory usage.
          reverse: If True, reverse the order of output, requiring O(n)
            memory.
          max_entries: The maximum number of entries to yield, or None for
            no limit.
          paths: Iterable of file or subtree paths to show entries for.
          rename_detector: diff.RenameDetector object for detecting
            renames.
          follow: If True, follow path across renames/copies. Forces a
            default rename_detector.
          since: Timestamp to list commits after.
          until: Timestamp to list commits before.
          get_parents: Method to retrieve the parents of a commit
          queue_cls: A class to use for a queue of commits, supporting the
            iterator protocol. The constructor takes a single argument, the
            Walker.
        zUnknown walk order %sNr)�
ALL_ORDERS�
ValueErrorrrF�bytesrBr8r5�order�reverse�max_entries�pathsrrr�followr<�until�_num_entries�_queue�collections�deque�
_out_queue)rrrBZexcludercrdrerfrrgr<rhrZ	queue_clsrrrr�s*!

zWalker.__init__cCsJ|durdS|jD]2}||kr$dS|�|�r|t|�dkrdSqdS)NFT�/)rf�
startswithr#)rZchanged_pathZ
followed_pathrrr�
_path_matches%s

�zWalker._path_matchescCs`|sdS|jj}|jj}|�|�rN|jrJ|jtvrJ|j�|�|j�	|�dS|�|�r\dSdS)NFT)
�old�path�newrprg�typerrfrKrU)r�changeZold_path�new_pathrrr�_change_matches0s

zWalker._change_matchescCs�|j}|jdur |j|jkr dS|jdur:|j|jkr:dS|j|jvrJdS|jdurXdSt|�|��dkr�|�	�D] }|D]}|�
|�rzdSqzqrn|�	�D]}|�
|�r�dSq�dS)a	Determine if a walk entry should be returned..

        Args:
          entry: The WalkEntry to consider.
        Returns: True if the WalkEntry should be returned by this walk, or
            False otherwise (e.g. if it doesn't match any requested paths).
        NFTr)r
r<rJrhr-r5rfr#rr,rw)r�entryr
Zpath_changesrurrr�_should_return?s$


zWalker._should_returncCs�|j}|dus|j|kr~t|j�}|dur6|j�|�|dusLt|j�tkr|jsVdS|j��}|�	|�r|jd7_|SqdSrE)
rerirYrjrmr&r#r?�popleftry)rrerxrrr�_next`s


zWalker._nextcCs,|jtkrt||j�}|jr(tt|��}|S)aPossibly reorder a results iterator.

        Args:
          results: An iterator of WalkEntry objects, in the order returned
            from the queue_cls.
        Returns: An iterator or list of WalkEntry objects, in the order
            required by the Walker.
        )rc�
ORDER_TOPO�
_topo_reorderrrd�reversedr')rZresultsrrr�_reorderos
	
zWalker._reordercCst|�t|jd���Sr)�iterrr{rrrr�__iter__~szWalker.__iter__)
r/r0r1r2�
ORDER_DATEr3rrprwryr{rr�rrrrr[�s�
:!r[cCs|jSrr\r^rrrr_�r!r_ccs�t��}i}t�t�}|D].}|�|�||j�D]}||d7<q2q|r�|��}|j}|j}||rt|||<qJ||�D]6}	||	d8<||	s||�|	d�}
|
r||�	|
�q||VqJdS)a�Reorder an iterable of entries topologically.

    This works best assuming the entries are already in almost-topological
    order, e.g. in commit time order.

    Args:
      entries: An iterable of WalkEntry objects.
      get_parents: Optional function for getting the parents of a commit.
    Returns: iterator over WalkEntry objects from entries in FIFO order, except
        where a parent would be yielded before any of its children.
    rN)
rkrl�defaultdict�intr&r
rzr-rM�
appendleft)�entriesrrO�pendingZnum_childrenrxrr
rDrWZparent_entryrrrr}�s*

r})r2rkrH�	itertoolsrZdulwich.diff_treerrrrZdulwich.errorsrZdulwich.objectsrr�r|r`r?rGrr3r[r}rrrr�<module>sHj