
    .Ph                     4   d Z ddlmZ ddlmZmZmZ ddlmZm	Z	m
Z
 erddlmZmZ ddlmZ deeef         d	efd
Zdddeeef         d	dfdZdddeeef         d	dfdZded         deeef         d	dfdZ	 d)ded         ded         deeef         ded	eed         ed         ef         f
dZ	 d)ded         ded         deeee         f         defdZd Zddd eeef         d	ed!         fd"Z G d# d$e          Zd% Zddd&eeef         d	d!fd'Z d(S )*zObject specification.    )Iterator)TYPE_CHECKINGOptionalUnion   )CommitShaFileTree)RefRefsContainer)Repotextreturnc                 R    t          | dd           |                     d          } | S )Nencodeascii)getattrr   )r   s    R/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/dulwich/objectspec.pyto_bytesr   "   s*    tXt$$0{{7##K    repor   	objectishr	   c                 0    t          |          }| |         S )zParse a string referring to an object.

    Args:
      repo: A `Repo` object
      objectish: A string referring to an object
    Returns: A git object
    Raises:
      KeyError: If the object can not be found
    )r   )r   r   s     r   parse_objectr   (   s     ##I	?r   treeishr
   c                     t          |          }	 t          | |          }n# t          $ r Y nw xY w| |         }|j        dk    r| |j                 S |S )zParse a string referring to a tree.

    Args:
      repo: A `Repo` object
      treeish: A string referring to a tree
    Returns: A git object
    Raises:
      KeyError: If the object can not be found
    s   commit)r   	parse_refKeyError	type_nametree)r   r   os      r   
parse_treer"   6   sn     wGD'**   WA{iAF|Hs   " 
//	container)r   r   refspecr   c                     t          |          }|d|z   d|z   d|z   d|z   d|z   dz   g}|D ]
}|| v r|c S t          |          )zParse a string referring to a reference.

    Args:
      container: A RefsContainer object
      refspec: A string referring to a ref
    Returns: A ref
    Raises:
      KeyError: If the ref can not be found
    s   refs/s
   refs/tags/   refs/heads/s   refs/remotes/s   /HEAD)r   r   )r#   r$   possible_refsrefs       r   r   r   K   s     wG7 7"7"X-M   )JJJ 
7

r   Flh_containerrh_containerforcec                 H   t          |          }|                    d          rd}|dd         }d|v r|                    d          \  }}n|x}}|dk    rd}nt          | |          }|dk    rd}n+	 t          ||          }n# t          $ r d|vrd|z   }Y nw xY w|||fS )	a  Parse a reftuple spec.

    Args:
      lh_container: A RefsContainer object
      rh_container: A RefsContainer object
      refspec: A string
    Returns: A tuple with left and right ref
    Raises:
      KeyError: If one of the refs can not be found
       +Tr   N   :r      /r&   )r   
startswithsplitr   r   )r)   r*   r$   r+   lhrhs         r   parse_reftupler4   f   s      wG$ !""+ w==&&RRR	Syy|R((	Syy	)<,,BB 	) 	) 	)2~~#b(	) E?s   5B BBrefspecsc           	          t          |t                    s|g}g }|D ](}|                    t          | |||                     )|S )aX  Parse a list of reftuple specs to a list of reftuples.

    Args:
      lh_container: A RefsContainer object
      rh_container: A RefsContainer object
      refspecs: A list of refspecs or a string
      force: Force overwriting for all reftuples
    Returns: A list of refs
    Raises:
      KeyError: If one of the refs can not be found
    )r+   )
isinstancelistappendr4   )r)   r*   r5   r+   retr$   s         r   parse_reftuplesr;      s^    " h%% :
C U U

>,gUSSSTTTTJr   c                     t          |t                    s|g}g }|D ]%}|                    t          | |                     &|S )zParse a list of refspecs to a list of refs.

    Args:
      container: A RefsContainer object
      refspecs: A list of refspecs or a string
    Returns: A list of refs
    Raises:
      KeyError: If one of the refs can not be found
    )r7   r8   r9   r   )r#   r5   r:   r$   s       r   
parse_refsr=      sU     h%% :
C 2 2

9Y001111Jr   committishsr   c                 \    t          |          }t          t          | |          g          S )a@  Parse a string referring to a range of commits.

    Args:
      repo: A `Repo` object
      committishs: A string referring to a range of commits.
    Returns: An iterator over `Commit` objects
    Raises:
      KeyError: When the reference commits can not be found
      ValueError: If the range can not be parsed
    )r   iterparse_commit)r   r>   s     r   parse_commit_rangerB      s,     ;''KdK001222r   c                       e Zd ZdZddZdS )AmbiguousShortIdzThe short id is ambiguous.r   Nc                 "    || _         || _        d S )N)prefixoptions)selfrF   rG   s      r   __init__zAmbiguousShortId.__init__   s    r   )r   N)__name__
__module____qualname____doc__rI    r   r   rD   rD      s.        $$     r   rD   c                    g }|                      |          D ]/}| |         }t          ||          r|                    |           0|st          |          t	          |          dk    r|d         S t          ||          )z$Scan an object store for a short id.r   r   )iter_prefixr7   r9   r   lenrD   )object_storerF   tpr:   	object_idr!   s         r   scan_for_short_idrU      s    
C!--f55  	#a 	JJqMMM v
3xx1}}1v
63
'
''r   
committishc                    t          |          }	 | |         S # t          $ r Y nw xY w	 | t          | |                   S # t          $ r Y nw xY wt          |          dk    r`t          |          dk     rM	 t	          |d           	 t          | j        |t                    S # t          $ r Y nw xY w# t          $ r Y nw xY wt          |          )a'  Parse a string referring to a single commit.

    Args:
      repo: A` Repo` object
      committish: A string referring to a single commit.
    Returns: A Commit object
    Raises:
      KeyError: When the reference commits can not be found
      ValueError: If the range can not be parsed
       (      )	r   r   r   rQ   intrU   rR   r   
ValueError)r   rV   s     r   rA   rA      s    *%%JJ   IdJ//00   
:!J" 4 4	
B():JOOO     	 	 	D	 :

sA    
&&A   
AA7B3 B# #
B0/B03
C ?C N)F)!rM   collections.abcr   typingr   r   r   objectsr   r	   r
   refsr   r   r   r   strbytesr   r   r"   r   booltupler4   r8   r;   r=   rB   	ExceptionrD   rU   rA   rN   r   r   <module>rf      s  ,   $ $ $ $ $ $ 1 1 1 1 1 1 1 1 1 1 * * * * * * * * * * ((((((((5e$     v %s
*; 	    V eE3J&7 F    *,-8=c5j8I
   > 	' '/0'/0' 3:' 	'
 8E?HUOT12' ' ' '\ 	 /0/0 E4;&' 	   4  &3
3$S%Z03h3 3 3 3$    y   ( ( (v 5e+<       r   