
    d                     \    d Z ddlZddlmZ ddlmZmZ ddlmZm	Z	 dZ
 G d d	          ZdS )
zStash handling.    N   )GitFile)commit_treeiter_fresh_objects)drop_reflog_entryread_reflogs
   refs/stashc                   n    e Zd ZdZefdZed             Zd Ze	d             Z
d Zd Zdd	Zd
 Zd ZdS )StashzPA Git stash.

    Note that this doesn't currently update the working tree.
    c                 "    || _         || _        d S N)_ref_repo)selfreporefs      Q/home/feoh/.local/pipx/venvs/poetry/lib/python3.11/site-packages/dulwich/stash.py__init__zStash.__init__'   s    	


    c                     t           j                            | j                                        dt          j        | j                            S )Nlogs)ospathjoinr   	commondirfsdecoder   r   s    r   _reflog_pathzStash._reflog_path+   s;    w||J  ""FBK	,B,B
 
 	
r   c                     	 t          | j        d          5 }t          t          t	          |                              cd d d            S # 1 swxY w Y   d S # t
          $ r g cY S w xY w)Nrb)r   r   reversedlistr   FileNotFoundError)r   fs     r   stasheszStash.stashes1   s    	*D11 6Q[^^ 4 4556 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6  	 	 	III	s4   A )A A AA AA A)(A)c                      | |          S )z&Create a new stash from a Repo object. )clsr   s     r   	from_repozStash.from_repo8   s     s4yyr   c                 R   t          | j        d          5 }t          ||d           ddd           n# 1 swxY w Y   t          |           dk    r-t	          j        | j                   | j        j        | j        = dS |dk    r!| d         j	        | j        j        | j        <   dS dS )z Drop entry with specified index.zrb+T)rewriteNr   )
openr   r   lenr   remover   refsr   new_sha)r   indexr#   s      r   dropz
Stash.drop=   s    $#U++ 	6qa5555	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6 	6t99>>Id'(((
	*FA::)-aDJODI&&& :s   599c                 *    t          | j                  r   )NotImplementedErrorpopr   r0   s     r   r4   z	Stash.popH   s    !$(+++r   Nc           	      d   i }|||d<   |||d<   | j                                         }|                    | j         j                  } | j         j        d	d|d| j                                         gdd|}t          | j         j        t          |t          j	        | j         j
                  | j         j                            }|d| j                                         z   }| j                                         | j         j        | j        <    | j         j        d	| j        |||gdd|}	|	S )
zCreate a new stash.

        Args:
          committer: Optional committer name to use
          author: Optional author name to use
          message: Optional commit message
        N	committerauthors   Index stashT)r   treemessagemerge_heads	no_verify)object_stores   A stash on r&   )r   
open_indexcommitr=   	do_commitheadr   r   r   fsencoder   r.   r   )
r   r7   r8   r:   commit_kwargsr0   index_tree_idindex_commit_idstash_tree_idcids
             r   pushz
Stash.pushK   sa     )2M+&&,M(#
%%''TZ%<==.$*. 
"**+
 
 
 
 $J#DJO,,!Z4  
 
 ?$tz'8'88G &*Z__%6%6
	""dj" 
	()
 
 
 
 
r   c                 P    t          |                                           |         S r   )r!   r$   r5   s     r   __getitem__zStash.__getitem__   s    DLLNN##E**r   c                 ^    t          t          |                                                     S r   )r,   r!   r$   r   s    r   __len__zStash.__len__   s     4''(((r   )NNN)__name__
__module____qualname____doc__DEFAULT_STASH_REFr   propertyr   r$   classmethodr(   r1   r4   rH   rJ   rL   r&   r   r   r
   r
   !   s         
 "3     
 
 X

     [	9 	9 	9, , ,3 3 3 3j+ + +) ) ) ) )r   r
   )rP   r   filer   r0   r   r   reflogr   r   rQ   r
   r&   r   r   <module>rV      s   *   
			       2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2! c) c) c) c) c) c) c) c) c) c)r   