
    +j              	       j   U d dl Z g dZe j        dk    re                    d           d dlmZ d dlZd dlmZ d dl	Z	d dl
Z
d dlZd dlmZ d dlmZ d dlZd dlZd dlZd dlZd dlZd dlZd dlmZmZ d dlZd d	lmZmZmZmZmZm Z m!Z!m"Z"m#Z# d d
l$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6 e2rd dl7m8Z8 d dl9m:Z:m;Z; d dl<m=Z= d dl>m?Z? d dl@mAZAmBZBmCZCmDZDmEZEmFZFmGZGmHZHmIZI  e3de4d         d          ZJ e
jK        eL          ZMdeNdeOdeOfdZPdeNdeOdeOfdZQ eQdd          ZR eQdd          ZS e3d          ZTde(deTf         de(deTf         fdZUejV        deEde*eEddf         fd             ZWejV        deNd!eNde*d"         fd#            ZXd$eEddfd%ZYd$eEddfd&ZZdod(e'd)e'd*e[de[fd+Z\d,eEd-eEdeEfd.Z]e j        dk    rd$eEdeNfd/Z^d$eEdeNfd0Z_e^Z`n
d$eEdeNfd1Z_e_Z`d,eEd-eEdeEfd2Zadpd$eEd4eOdeOfd5Zbde0eN         fd6Zcdqd7eNd$e.eE         de-eN         fd8Zdd9e.eN         d$eNdeNfd:Ze ejf        d;          d< d3f ejf        d=          eed3f ejf        d>          eed3f ejf        d?ejg                  d@ df ejf        dA          dB d3ffZhe1e1e/eN         e(eOf         df         eidC<   d$eNdeNfdDZj ejf        dE          Zkd$eEdeNfdFZli Zme)eNe.eO         f         eidG<   dHeNdeOfdIZne6dHddeDd3         fdJ            Zoe6dHeEdeOfdK            ZodHe4deEf         deOfdLZodeNfdMZpdNe4ejq        dOf         dPe%ddfdQZre6drd-ddReOddfdS            Zse6drd-eEdReOdeNfdT            Zsdsd-e4deEf         dReOde.eE         fdUZsdVe0eN         de-eN         fdWZt G dX dY          Zu G dZ d[eu          Zv G d\ d]          Zw G d^ d_          Zx G d` da          Zy G db dc          Zz G dd deez          Z{ G df dge-eJ                   Z|eI G dh dieF                      Z} G dj dke~          Z G dl dmen          ZdS )t    N)stream_copy	join_pathto_native_path_linuxjoin_path_nativeStatsIndexFileSHA1WriterIterableObjIterableListBlockingLockFileLockFileActorget_user_idassure_directory_existsRemoteProgressCallableRemoteProgressrmtreeunbare_repoHIDE_WINDOWS_KNOWN_ERRORSwin32to_native_path_windows)abstractmethod)wraps)Path)urlsplit
urlunsplit)		LazyMixinLockedFD
bin_to_hexfile_contents_rofile_contents_ro_filepath
hex_to_binmake_sha
to_bin_sha
to_hex_sha)AnyAnyStrBinaryIOCallableDict	GeneratorIOIteratorListOptionalPatternSequenceTupleTYPE_CHECKINGTypeVarUnioncastoverload)Git)GitConfigParserSectionConstraint)Remote)Repo)	Files_TDHas_id_attributeHSH_TDLiteralPathLikeProtocolSupportsIndexTotal_TDruntime_checkableT_IterableObj)r	   r=   T)bound	covariantnamedefaultreturnc                 &   	 t           j        |          }n# t          $ r |cY S w xY wt                              d|            |                                                                }|dv rdS |dv rdS t                              d| ||           |S )zRead a boolean flag from an environment variable.

    :return:
        The flag, or the `default` value if absent or ambiguous.
    zlThe %s environment variable is deprecated. Its effect has never been documented and changes without warning.>    0nofalseF>   1yestrueTz-%s has unrecognized value %r, treating as %r.)osenvironKeyError_loggerwarningstriplower)rH   rI   valueadjusted_values       K/home/wildlama/comfy/ComfyUI/.venv/lib/python3.11/site-packages/git/util.py_read_env_flagr]   s   s    
4     OOv  
 [[]]((**N111u---tOOCT5RYZZZNs    $$c                 B    t           j        dk    ot          | |          S )a  Read a boolean flag from an environment variable on Windows.

    :return:
        On Windows, the flag, or the `default` value if absent or ambiguous.
        On all other operating systems, ``False``.

    :note:
        This only accesses the environment on Windows.
    r   )sysplatformr]   )rH   rI   s     r\   _read_win_env_flagra      s      <7"D~dG'D'DD    r   HIDE_WINDOWS_FREEZE_ERRORSTfunc.c           	      |     ddl m t                     dddt          dt          dt          f fd            }|S )	ztMethods with this decorator raise :exc:`~git.exc.InvalidGitRepositoryError` if
    they encounter a bare repository.   )InvalidGitRepositoryErrorselfr:   argskwargsrJ   c                 Z    | j         j        r dj        z             | g|R i |S )Nz/Method '%s' cannot operate on bare repositories)repobare__name__)ri   rj   rk   rh   re   s      r\   wrapperzunbare_repo.<locals>.wrapper   sK    9> 	o++,]`d`m,mnnntD*4***6***rb   )excrh   r   r%   rd   )re   rp   rh   s   ` @r\   r   r      sn     /.....
4[[+h +s +c +a + + + + + + [+ Nrb   new_dirc              #      K   t          j                    }t          j        |            	 | V  t          j        |           dS # t          j        |           w xY w)zContext manager to temporarily change directory.

    This is similar to :func:`contextlib.chdir` introduced in Python 3.11, but the
    context manager object returned by a single call to this function is not reentrant.
    N)rS   getcwdchdir)rr   old_dirs     r\   cwdrw      s]       ikkGHW
s   A ArZ   )NNNc              #      K   t          j        |           }|t           j        | <   	 dV  |t           j        | = dS |t           j        | <   dS # |t           j        | = n|t           j        | <   w xY w)z=Context manager to temporarily patch an environment variable.N)rS   getenvrT   )rH   rZ   	old_values      r\   	patch_envr{      s       	$IBJt)
4   (BJt 
4  (BJt((((s   A !A.pathc                    dt           dt          dt          ddfd}t          j        dk    rt          j        |            dS t          j        dk    rt          j        | |	           dS t          j        | |
           dS )zRemove the given directory tree recursively.

    :note:
        We use :func:`shutil.rmtree` but adjust its behaviour to see whether files that
        couldn't be deleted are read-only. Windows will not remove them in that case.
    functionr|   _excinforJ   Nc                     t          j        |t          j                   	  | |           dS # t          $ r"}t
          rddlm}  |d|           | d}~ww xY w)zuCallback for :func:`shutil.rmtree`.

        This works as either a ``onexc`` or ``onerror`` style callback.
        r   )SkipTestz%FIXME: fails with: PermissionError
  N)rS   chmodstatS_IWUSRPermissionErrorr   unittestr   )r~   r|   r   exr   s        r\   handlerzrmtree.<locals>.handler   s     	t|$$$	HTNNNNN 	 	 	( V------hLLLMMSUU	s   . 
AAAr   )      )onexc)onerror)r(   r@   r%   r_   r`   shutilr   version_info)r|   r   s     r\   r   r      s    ( ( c d    " |wd		W	$	$d'******dG,,,,,,rb   c                     t          j        |           r;t          j        dk    rt	          j        | d           t	          j        |            dS dS )zWEnsure file deleted also on *Windows* where read-only files need special
    treatment.r   i  N)ospisfiler_   r`   rS   r   remover|   s    r\   rmfiler      sP     z$ <7""HT5!!!
	$ rb      sourcedestination
chunk_sizec                     d}	 |                      |          }|                    |           |t          |          z  }t          |          |k     rnQ|S )zCopy all data from the `source` stream into the `destination` stream in chunks
    of size `chunk_size`.

    :return:
        Number of bytes written
    r   )readwritelen)r   r   r   brchunks        r\   r   r      sc     
BJ''%   
c%jju::
"" Irb   apc                     t          j        |           }|D ]e}t          j        |          }|s|                    d          r||dd         z  }<|dk    s|                    d          r||z  }]|d|z   z  }f|S )zmJoin path tokens together similar to osp.join, but always use ``/`` instead of
    possibly ``\`` on Windows./rg   NrL   )rS   fspath
startswithendswith)r   r   r|   bs       r\   r   r     s     9Q<<D 	 	IaLL 	<< 	AabbEMDDRZZ4==--ZAIDDC!GODDKrb   c                 V    t          j        |           } |                     dd          S )Nr   \rS   r   replacer   s    r\   r   r   $  s#    y||C&&&rb   c                 V    t          j        |           } |                     dd          S )Nr   r   r   r   s    r\   r   r   (  s#    y||D#&&&rb   c                 *    t          j        |           S N)rS   r   r   s    r\   r   r   /  s    yrb   c                 6    t          t          | g|R            S )zLike :func:`join_path`, but makes sure an OS native path is returned.

    This is only needed to play it safe on Windows and to ensure nice paths that only
    use ``\``.
    )to_native_pathr   )r   r   s     r\   r   r   5  s"     )A****+++rb   Fis_filec                     |rt          j        |           } t          j        |           st          j        | d           dS dS )a$  Make sure that the directory pointed to by path exists.

    :param is_file:
        If ``True``, `path` is assumed to be a file and handled correctly.
        Otherwise it must be a directory.

    :return:
        ``True`` if the directory was created, ``False`` if it already existed.
    T)exist_okF)r   dirnameisdirrS   makedirs)r|   r   s     r\   r   r   >  sJ      !{4  9T?? 
D4((((t5rb   c                      t           j                            dd           } | r6t          d |                     t           j                  D                       S t          j        dk    rdS dS )NPATHEXTc              3   >   K   | ]}|                                 V  d S r   )upper).0r   s     r\   	<genexpr>z&_get_exe_extensions.<locals>.<genexpr>T  s*      BB1QWWYYBBBBBBrb   r   )z.BATz.COMz.EXE )rS   rT   gettuplesplitpathsepr_   r`   )r   s    r\   _get_exe_extensionsr   Q  sb    jnnY--G BBbj(A(ABBBBBB		 	 ''rrb   programc                    t                      dt          dt          ffd}g }|st          j        d         }t          j        |                              t          j                  D ]c}|                    d          }|rJt          j
        ||           gfdD             z   D ]"} ||          r|                    |           #d|S )a6  Perform a path search to assist :func:`is_cygwin_git`.

    This is not robust for general use. It is an implementation detail of
    :func:`is_cygwin_git`. When a search following all shell rules is needed,
    :func:`shutil.which` can be used instead.

    :note:
        Neither this function nor :func:`shutil.which` will predict the effect of an
        executable search on a native Windows system due to a :class:`subprocess.Popen`
        call without ``shell=True``, because shell and non-shell executable search on
        Windows differ considerably.
    fpathrJ   c                      t          j                   oLt          j         t          j                  o-t
          j        dk    p pt           fdD                       S )Nr   c              3   f   K   | ]+}                                                     |          V  ,d S r   )r   r   )r   extr   s     r\   r   z,py_where.<locals>.is_exec.<locals>.<genexpr>p  s;      BwBwcf5;;==CYCYZ]C^C^BwBwBwBwBwBwrb   )r   r   rS   accessX_OKr_   r`   any)r   winprog_extss   `r\   is_execzpy_where.<locals>.is_execk  sh    Ju 	%)) 'w|+;wsBwBwBwBwjvBwBwBw?w?w		
rb   PATH"c                     g | ]}|	S r   r   )r   eexe_paths     r\   
<listcomp>zpy_where.<locals>.<listcomp>{  s"    "P"P"PaXXqq#9"P"P"Prb   )r   strboolrS   rT   r   r   r   rX   r   joinappend)r   r|   r   progsfolderfr   r   s         @@r\   py_wherer   [  s     '((L
s 
t 
 
 
 
 
 
 E "z&!)D//''
33 $ $c"" 	$x00HZ"P"P"P"P<"P"P"PP $ $71:: $LLOOOLrb   drivec                    t          j        |          r| s|}n|o7t          j        t          j        t          j        |                              }t          j        |          r| r|}n,t          |          }n| rd|                                 d|}t          j        |          }|	                    dd          S )Nz/proc/cygdrive/r   r   )
r   isabsnormpath
expandvars
expandusercygpathrY   rS   r   r   )r   r|   r   p_strs       r\   
_cygexpathr     s    
y <u < GS\#.1E1E"F"FGG9Q<< 	< AJJ 	< 	<*/++----;AIaLLE==s###rb   z*\\\\\?\\UNC\\([^\\]+)\\([^\\]+)(?:\\(.*))?c           	      @    d| d|d|                     dd          S )N//r   r   )r   )servershare	rest_paths      r\   <lambda>r     s,     &&&%%%IZIZ[_adIeIeIe*f rb   z\\\\\?\\(\w):[/\\](.*)z(\w):[/\\](.*)z	file:(.*)c                     | S r   r   )r   s    r\   r   r     s    	 rb   z(\w{2,}:.*)c                     | S r   r   )urls    r\   r   r     s    c rb   _cygpath_parsersc                    t          j        |           } |                     d          s_t          D ]G\  }}}|                    |           }|r* ||                                 } |rt          |           }  nHt          d|           } | S )zJUse :meth:`git.cmd.Git.polish_url` instead, that works on any environment.)z	/cygdriver   z/proc/cygdriveN)rS   r   r   r   matchgroupsr   r   )r|   regexparserrecurser   s        r\   r   r     s    9T??D??@AA 	*&6 	* 	*"E67KK%%E vu||~~. )"4==D	 dD))DKrb   z(?:/proc)?/cygdrive/(\w)(/.*)?c                     t          j        |           } t                              |           }|r2|                                \  }}|                                d|pd} |                     dd          S )N:rL   r   r   )rS   r   _decygpath_regexr   r   r   r   )r|   mr   r   s       r\   	decygpathr     sl    9T??Dt$$A :88::y++----b9<<T"""rb   _is_cygwin_cachegit_executablec                    t                               |           }|?d}	 t          j        |           }|s-t	          |           }|rt          j        |d                   nd}t          j        |d          }t          |                                          rt          j	        |t          j
                  s*t                              d| d           |t           | <   |S t          j        |gt          j        d          }|                                \  }}d	|v }n2# t"          $ r%}t                              d
|           Y d }~nd }~ww xY w|t           | <   |S )NFr   rL   unamez&Failed checking if running in CYGWIN: z is not an executableT)stdoutuniversal_newlinesCYGWINz/Failed checking if running in CYGWIN due to: %r)r   r   r   r   r   r   r   r   rS   r   r   rV   debug
subprocessPopenPIPEcommunicate	Exception)	r   	is_cygwingit_dirres	uname_cmdprocess	uname_out_r   s	            r\   _is_cygwin_gitr    sm    $$^44I		Qk.11G =~..14<#+c!f---" '22IOO++-- !")Irw2O2O !gyggghhh3< 0   &	{:?_cdddG"..00LIq I-II 	Q 	Q 	QMMKRPPPPPPPP	Q+4(s   CD! #=D! !
E+EEc                     d S r   r   r   s    r\   is_cygwin_gitr        ;>3rb   c                     d S r   r   r  s    r\   r  r    s    58Srb   c                     t                               dt          j        d|            t          j        dk    rdS | dS t	          t          |                     S )Nzsys.platform=z, git_executable=cygwinF)rV   r   r_   r`   r  r   r  s    r\   r  r    sZ    MMU#,UU>UUVVV
|xu		uc.11222rb   c                  T    t          j                    dt          j                    S )zM:return: String identifying the currently active system user as ``name@node``@)getpassgetuserr`   noder   rb   r\   r   r     s#    o''''99rb   proczGit.AutoInterruptrk   c                       | j         di | dS )zXWait for the process (clone, fetch, pull or push) and handle its errors
    accordingly.Nr   )wait)r  rk   s     r\   finalize_processr    s"     DIrb   expand_varsc                     d S r   r   r   r  s     r\   expand_pathr!    r  rb   c                     d S r   r   r   s     r\   r!  r!    s	     Crb   c                    t          | t                    r|                                 S 	 t          j        |           } |rt          j        |           } t          j        t          j        |                     S # t          $ r Y d S w xY wr   )	
isinstancer   resolver   r   r   r   abspathr  r   s     r\   r!  r!    s    !T yy{{N1 	"q!!A|CKNN+++   tts   AA; ;
B	B	cmdlinec                    g }t          |           D ]\  }}|                    |           	 t          |          }|j        |j        9|j        4|                    |j                            |j        d                    }|j        4|                    |j                            |j        d                    }t          |          ||<   # t          $ r Y w xY w|S )a>  Parse any command line argument and if one of the elements is an URL with a
    username and/or password, replace them by stars (in-place).

    If nothing is found, this just returns the command line as-is.

    This should be used for every log line that print a command line, as well as
    exception messages.
    Nz*****)netloc)
	enumerater   r   passwordusername_replacer)  r   r   
ValueError)r'  new_cmdlineindexto_parser   s        r\   remove_password_if_presentr2    s     K$W--  x8$$$	8$$C|#(<|'ll#**<*<S\7*S*SlTT|'ll#**<*<S\7*S*SlTT!+CK 	 	 	H	 s   CBC
C! C!c                   F   e Zd ZU dZdZeed<   d  ee          D             \	  ZZ	Z
ZZZZZZee	z  Ze ZdZdZdZ ej        d          Z ej        d	          ZddZded
dfdZd
eegdf         fdZded
dfdZ 	 	 ddede!ee"f         de!ee"df         ded
df
dZ#dS )r   zHandler providing an interface to parse progress information emitted by
    :manpage:`git-push(1)` and :manpage:`git-fetch(1)` and to dispatch callbacks
    allowing subclasses to react to the progress.	   _num_op_codesc                     g | ]}d |z  S )rg   r   )r   xs     r\   r   zRemoteProgress.<listcomp>K  s    ...Aa...rb   zdone.z, )	_cur_line	_seen_opserror_linesother_linesz%(remote: )?([\w\s]+):\s+()(\d+)()(.*)z2(remote: )?([\w\s]+):\s+(\d+)% \((\d+)/(\d+)\)(.*)rJ   Nc                 >    g | _         d | _        g | _        g | _        d S r   )r9  r8  r:  r;  ri   s    r\   __init__zRemoteProgress.__init__[  s&    $&(,&(&(rb   linec                    t          |t                    r|                    d          }n|}|| _        | j                            d          r!| j                            | j                   dS d\  }}| j                            |          }|| j	                            |          }|s1| 
                    |           | j                            |           dS d}|                                \  }}}	}}}
|dk    r|| j        z  }n}|dk    r|| j        z  }nl|dk    r|| j        z  }n[|d	k    r|| j        z  }nJ|d
k    r|| j        z  }n9|dk    r|| j        z  }n(|dk    r|| j        z  }n| 
                    |           dS || j        vr$| j                            |           || j        z  }|
d}
|
                                }
|
                    | j                  r'|| j        z  }|
dt5          | j                            }
|
                    | j                  }
|                     ||ot;          |          |ot;          |          |
           dS )a^  Parse progress information from the given line as retrieved by
        :manpage:`git-push(1)` or :manpage:`git-fetch(1)`.

        - Lines that do not contain progress info are stored in :attr:`other_lines`.
        - Lines that seem to contain an error (i.e. start with ``error:`` or ``fatal:``)
          are stored in :attr:`error_lines`.
        zutf-8)zerror:zfatal:N)NNr   zCounting objectszCompressing objectszWriting objectszReceiving objectszResolving deltaszFinding sourceszChecking out filesrL   )r$  bytesdecoder8  r   r:  r   re_op_relativer   re_op_absoluteline_droppedr;  r   COUNTINGCOMPRESSINGWRITING	RECEIVING	RESOLVINGFINDING_SOURCESCHECKING_OUTr9  BEGINrX   r   
DONE_TOKENENDr   TOKEN_SEPARATORupdatefloat)ri   r?  line_str	cur_count	max_countr   op_code_remoteop_name_percentmessages              r\   _parse_progress_linez#RemoteProgress._parse_progress_linea  s    dE"" 	{{7++HHH!>$$%9:: 	##DN333F)	9#))(33='--h77E 	h'''##H---F DILLNNA(Iy' (((t}$GG---t''GG)))t|#GG+++t~%GG***t~%GG)))t++GG,,,t((GG h''' F $.((N!!'***tz!G ?G --//DO,, 	7txG5T_!5!5 556G-- 455*%	***%	**		
 	
 	
 	
 	
rb   c                 &     dt           ddf fd}|S )z
        :return:
            A progress handler suitable for :func:`~git.cmd.handle_process_output`,
            passing lines on to this progress handler in a suitable format.
        r?  rJ   Nc                 R                         |                                           S r   )r[  rstrip)r?  ri   s    r\   r   z3RemoteProgress.new_message_handler.<locals>.handler  s    ,,T[[]];;;rb   )r&   )ri   r   s   ` r\   new_message_handlerz"RemoteProgress.new_message_handler  s6    	<& 	<T 	< 	< 	< 	< 	< 	<
 rb   c                     dS )zICalled whenever a line could not be understood and was therefore dropped.Nr   )ri   r?  s     r\   rE  zRemoteProgress.line_dropped  s    rb   rL   rV  rT  rU  rZ  c                     dS )a  Called whenever the progress changes.

        :param op_code:
            Integer allowing to be compared against Operation IDs and stage IDs.

            Stage IDs are :const:`BEGIN` and :const:`END`. :const:`BEGIN` will only be
            set once for each Operation ID as well as :const:`END`. It may be that
            :const:`BEGIN` and :const:`END` are set at once in case only one progress
            message was emitted due to the speed of the operation. Between
            :const:`BEGIN` and :const:`END`, none of these flags will be set.

            Operation IDs are all held within the :const:`OP_MASK`. Only one Operation
            ID will be active per call.

        :param cur_count:
            Current absolute count of items.

        :param max_count:
            The maximum count of items we expect. It may be ``None`` in case there is no
            maximum number of items or if it is (yet) unknown.

        :param message:
            In case of the :const:`WRITING` operation, it contains the amount of bytes
            transferred. It may possibly be used for other purposes as well.

        :note:
            You may read the contents of the current line in
            :attr:`self._cur_line <_cur_line>`.
        Nr   )ri   rV  rT  rU  rZ  s        r\   rQ  zRemoteProgress.update  s
    H 	rb   rJ   NNrL   )$ro   
__module____qualname____doc__r5  int__annotations__rangerM  rO  rF  rG  rH  rI  rJ  rK  rL  
STAGE_MASKOP_MASKrN  rP  	__slots__recompilerD  rC  r>  r&   r[  r(   r   r_  rE  r4   rR  rQ  r   rb   r\   r   r   ;  s        5 5 M3 	/.}--...
JkGJOI  RZ HIINRZ UVVN) ) ) )W
 W
D W
 W
 W
 W
rXseTk%:          .2$ $$ e$$ eT)*	$
 $ 
$ $ $ $ $ $rb   r   c                   D     e Zd ZdZdZdeddf fdZdededdfd	Z xZ	S )
r   a  A :class:`RemoteProgress` implementation forwarding updates to any callable.

    :note:
        Like direct instances of :class:`RemoteProgress`, instances of this
        :class:`CallableRemoteProgress` class are not themselves directly callable.
        Rather, instances of this class wrap a callable and forward to it. This should
        therefore not be confused with :class:`git.types.CallableProgress`.
    	_callablefnrJ   Nc                 V    || _         t                                                       d S r   )rq  superr>  )ri   rr  	__class__s     r\   r>  zCallableRemoteProgress.__init__  s&    rb   rj   rk   c                       | j         |i | d S r   rp  )ri   rj   rk   s      r\   rQ  zCallableRemoteProgress.update  s    ''''''rb   )
ro   rd  re  rf  rl  r(   r>  r%   rQ  __classcell__ru  s   @r\   r   r     s          I8       (C (3 (4 ( ( ( ( ( ( ( (rb   r   c            
          e Zd ZdZ ej        d          Z ej        d          ZdZdZ	dZ
dZdZd	Zd
Zdee         d	ee         ddfdZdedefdZdedefdZdefdZdefdZdefdZededd fd            Ze	 ddededed         dd fd            Zedded         dd fd            Zedded         dd fd            ZdS )r   zActors hold information about a person acting on the repository. They can be
    committers and authors or anything with a name and an email as mentioned in the git
    log entries.z<(.*)>z(.*) <(.*?)>GIT_AUTHOR_NAMEGIT_AUTHOR_EMAILGIT_COMMITTER_NAMEGIT_COMMITTER_EMAILrH   emailrH   r~  rJ   Nc                 "    || _         || _        d S r   r  )ri   rH   r~  s      r\   r>  zActor.__init__  s    	


rb   otherc                 B    | j         |j         k    o| j        |j        k    S r   r  ri   r  s     r\   __eq__zActor.__eq__!  s    yEJ&D4:+DDrb   c                     | |k     S r   r   r  s     r\   __ne__zActor.__ne__$  s    EM""rb   c                 8    t          | j        | j        f          S r   )hashrH   r~  r=  s    r\   __hash__zActor.__hash__'  s    TY
+,,,rb   c                 "    | j         r| j         ndS rc  )rH   r=  s    r\   __str__zActor.__str__*  s     I-tyy2-rb   c                 (    d| j         d| j        dS )Nz<git.Actor "z <z>">r  r=  s    r\   __repr__zActor.__repr__-  s     *.)))TZZZ@@rb   stringc                 &   | j                             |          }|r'|                                \  }}t          ||          S | j                            |          }|r#t          |                    d          d          S t          |d          S )zCreate an :class:`Actor` from a string.

        :param string:
            The string, which is expected to be in regular git format::

                John Doe <jdoe@example.com>

        :return:
            :class:`Actor`
        rg   N)name_email_regexsearchr   r   name_only_regexgroup)clsr  r   rH   r~  s        r\   _from_stringzActor._from_string0  s      ''// 	'((**KD%u%%%#**622A /QWWQZZ...&&&rb   env_name	env_emailconfig_reader)Nr8   r9   c                    t          dd          }d dt          ffddt          ffd}d|| j        |fd|| j        ffD ]\  }}}}		 t          j        |         }
t          |||
           ,# t          $ rq |C	 |                    d|          }
n# t          $ r  |	            }
Y nw xY wt          |||
           t          ||          st          || |	                       Y w xY w|S )NrL   rJ   c                  (     st                        S r   )r   )user_ids   r\   default_emailz(Actor._main_actor.<locals>.default_emailS  s     (%--Nrb   c                  J                                       d          d         S )Nr  r   )r   )r  s   r\   default_namez'Actor._main_actor.<locals>.default_nameY  s"     =??((--a00rb   rH   r~  user)r   r   	conf_name
conf_emailrS   rT   setattrrU   r   r  getattr)r  r  r  r  actorr  attrevarcvarrI   valr  r  s              @@r\   _main_actorzActor._main_actorI  sl    b"	s 	 	 	 	 	 		1c 	1 	1 	1 	1 	1 	1 Xs}l;i?*
 	4 	4%D$g4j&tS)))) 	4 	4 	4 ,(+//==$ ( ( (%gii(E4---ud++ 4E4333	4 s6   #A11C,>BC,B,)C,+B,,=C,+C,c                 D    |                      | j        | j        |          S )a  
        :return:
            :class:`Actor` instance corresponding to the configured committer. It
            behaves similar to the git implementation, such that the environment will
            override configuration values of `config_reader`. If no value is set at all,
            it will be generated.

        :param config_reader:
            ConfigReader to use to retrieve the values from in case they are not set in
            the environment.
        )r  env_committer_nameenv_committer_emailr  r  s     r\   	committerzActor.committerq  s!     s5s7NP]^^^rb   c                 D    |                      | j        | j        |          S )zSame as :meth:`committer`, but defines the main author. It may be specified
        in the environment, but defaults to the committer.)r  env_author_nameenv_author_emailr  s     r\   authorzActor.author  s      s2C4H-XXXrb   r   ) ro   rd  re  rf  rm  rn  r  r  r  r  r  r  r  r  rl  r.   r   r>  r%   r   r  r  rg  r  r  r  classmethodr  r4   r  r  r  r   rb   r\   r   r     sI        
 !bj++O!rz/22 (O)-/ IJ!IXc] 8C= T    EC ED E E E E#C #D # # # #-# - - - -. . . . .A# A A A A '# '' ' ' ' ['0 
 NR	% %% % IJ	%
 
% % % [%N _ _e,X&Y _el _ _ _ [_ Y Y5)U#V Ybi Y Y Y [Y Y Yrb   r   c                   ^    e Zd ZdZdZdedeeef         ddfdZ	e
dd	d
edd fd            ZdS )r   a  Represents stat information as presented by git at the end of a merge. It is
    created from the output of a diff operation.

    Example::

     c = Commit( sha1 )
     s = c.stats
     s.total         # full-stat-dict
     s.files         # dict( filepath : stat-dict )

    ``stat-dict``

    A dictionary with the following keys and values::

      deletions = number of deleted lines as int
      insertions = number of inserted lines as int
      lines = total number of lines changed as int, or deletions + insertions
      change_type = type of change as str, A|C|D|M|R|T|U|X|B

    ``full-stat-dict``

    In addition to the items in the stat-dict, it features additional information::

     files = number of changed files as int
    totalfilesr  r  rJ   Nc                 "    || _         || _        d S r   r  )ri   r  r  s      r\   r>  zStats.__init__  s    



rb   rm   r;   textc                    dddddi d}|                                 D ]}|                    d          \  }}}}|dk    rt          |          pd}	|dk    rt          |          pd}
|d         dxx         |	z  cc<   |d         dxx         |
z  cc<   |d         d	xx         |	|
z   z  cc<   |d         d
xx         dz  cc<   |	|
|	|
z   |d}||d
         |                                <   t	          |d         |d
                   S )zCreate a :class:`Stats` object from output retrieved by
        :manpage:`git-diff(1)`.

        :return:
            :class:`git.Stats`
        r   )
insertions	deletionslinesr  r  	-r  r  r  r  r  rg   )r  r  r  change_type)
splitlinesr   rg  rX   r   )r  rm   r  hshr?  r  raw_insertionsraw_deletionsfilenamer  r  
files_dicts               r\   _list_from_stringzStats._list_from_string  sg    %&AANN
 
 OO%% 	8 	8DEIZZPTEUEUB[.-'3.F3~3F3FK!J%,C]1C1CHqIL&&&*4&&&L%%%2%%%L!!!Z)%;;!!!L!!!Q&!!!(&#i/*	$ $J .8CL))**S\3w<000rb   )ro   rd  re  rf  rl  rC   r)   r@   r<   r>  r  r   r  r   rb   r\   r   r     s         4 #Ih tHh4F/G D     1V 13 17 1 1 1 [1 1 1rb   r   c                   Z    e Zd ZdZdZdeddfdZdedefdZ	de
fd	Zde
fd
ZdefdZdS )r   a  Wrapper around a file-like object that remembers the SHA1 of the data written to
    it. It will write a sha when the stream is closed or if asked for explicitly using
    :meth:`write_sha`.

    Only useful to the index file.

    :note:
        Based on the dulwich project.
    )r   sha1r   rJ   Nc                 <    || _         t          d          | _        d S )Nrb   )r   r"   r  )ri   r   s     r\   r>  zIndexFileSHA1Writer.__init__  s    SMM			rb   datac                 j    | j                             |           | j                            |          S r   )r  rQ  r   r   )ri   r  s     r\   r   zIndexFileSHA1Writer.write  s,    	v||D!!!rb   c                 l    | j                                         }| j                            |           |S r   )r  digestr   r   ri   shas     r\   	write_shazIndexFileSHA1Writer.write_sha  s.    i  S
rb   c                 `    |                                  }| j                                         |S r   )r  r   closer  s     r\   r  zIndexFileSHA1Writer.close  s%    nn
rb   c                 4    | j                                         S r   )r   tellr=  s    r\   r  zIndexFileSHA1Writer.tell  s    v{{}}rb   )ro   rd  re  rf  rl  r+   r>  r&   rg  r   rA  r  r  r  r   rb   r\   r   r     s          I"" " " " " ""& "S " " " "5    
u    
c      rb   r   c                   ^    e Zd ZdZdZdeddfdZddZdefdZ	de
fd	Zdd
ZddZddZdS )r   a  Provides methods to obtain, check for, and release a file based lock which
    should be used to handle concurrent access to the same file.

    As we are a utility class to be derived from, we only use protected methods.

    Locks will automatically be released on destruction.
    
_file_path
_owns_lock	file_pathrJ   Nc                 "    || _         d| _        d S )NFr  )ri   r  s     r\   r>  zLockFile.__init__  s    #rb   c                 .    |                                   d S r   )_release_lockr=  s    r\   __del__zLockFile.__del__  s    rb   c                     d| j         z  S )z:return: Path to lockfilez%s.lock)r  r=  s    r\   _lock_file_pathzLockFile._lock_file_path  s    DO,,rb   c                     | j         S )z
        :return:
            True if we have a lock and if the lockfile still exists

        :raise AssertionError:
            If our lock-file does not exist.
        )r  r=  s    r\   	_has_lockzLockFile._has_lock   s     rb   c                 |   |                                  rdS |                                 }t          j        |          rt	          d| j        d|d          	 t          |d          5  	 ddd           n# 1 swxY w Y   n/# t          $ r"}t	          t          |                    |d}~ww xY wd| _	        dS )zCreate a lock file as flag for other instances, mark our instance as
        lock-holder.

        :raise IOError:
            If a lock was already present or a lock file could not be written.
        NzLock for file z did already exist, delete z in case the lock is illegalw)modeT)
r  r  r   r   IOErrorr  openOSErrorr   r  )ri   	lock_filer   s      r\   _obtain_lock_or_raisezLockFile._obtain_lock_or_raise
  s    >> 	F((**	:i   	'???III/  
	)ic***                 	) 	) 	)#a&&//q(	) s<   B ,A:.B :A>>B A>B 
B2B--B2c                 *    |                                  S )zThe default implementation will raise if a lock cannot be obtained.

        Subclasses may override this method to provide a different implementation.
        )r  r=  s    r\   _obtain_lockzLockFile._obtain_lock"  s    
 ))+++rb   c                     |                                  sdS |                                 }	 t          |           n# t          $ r Y nw xY wd| _        dS )z Release our lock if we have one.NF)r  r  r   r  r  )ri   lfps     r\   r  zLockFile._release_lock)  si    ~~ 	F ""$$	3KKKK 	 	 	D	s   < 
A	A	rb  )ro   rd  re  rf  rl  r@   r>  r  r   r  r   r  r  r  r  r   rb   r\   r   r     s          -I (  t           - - - - -4       0, , , ,           rb   r   c            	       T     e Zd ZdZdZdej        fdedede	ddf fd	Z
d fd
Z xZS )r   a  The lock file will block until a lock could be obtained, or fail after a
    specified timeout.

    :note:
        If the directory containing the lock was removed, an exception will be raised
        during the blocking period, preventing hangs as the lock can never be obtained.
    )_check_interval_max_block_timeg333333?r  check_interval_smax_block_time_srJ   Nc                 f    t                                          |           || _        || _        dS )a  Configure the instance.

        :param check_interval_s:
            Period of time to sleep until the lock is checked the next time.
            By default, it waits a nearly unlimited time.

        :param max_block_time_s:
            Maximum amount of seconds we may lock.
        N)rt  r>  r  r  )ri   r  r  r  ru  s       r\   r>  zBlockingLockFile.__init__C  s3     	###//rb   c                 T   t          j                     }|t          | j                  z   }	 	 t                                                       dS # t
          $ r}t          j                     }t          j        t          j        | 	                                                    s,d| 	                                ||z
  fz  }t          |          |||k    r,d||z
  | 	                                fz  }t          |          |t          j
        | j                   Y d}~nd}~ww xY w)zThis method blocks until it obtained the lock, or raises :exc:`IOError` if it
        ran out of time or if the parent directory was not available anymore.

        If this method returns, you are guaranteed to own the lock.
        TzVDirectory containing the lockfile %r was not readable anymore after waiting %g secondsz Waited %g seconds for lock at %rN)timerR  r  rt  r  r  r   r   r   r  sleepr  )ri   	starttimemaxtimer   curtimemsgru  s         r\   r  zBlockingLockFile._obtain_lockV  sD    IKK	eD$8999	$$&&&, +  1 1 1 )++yT-A-A-C-C!D!DEE .r,,..)+v C "#,,A- g%%<)+,,..@ C "#,,A-
4/00000000'1	s    A 
D&CD!!D&rb  )ro   rd  re  rf  rl  r_   maxsizer@   rR  rg  r>  r  rw  rx  s   @r\   r   r   8  s          7I
 #& #	0 00  0 	0
 
0 0 0 0 0 0&                   rb   r   c                        e Zd ZdZdZddededdf fdZddededd	fd
Zdede	fdZ
dedefdZdeeeeef         defdZdeeeeef         dd	fdZ xZS )r
   a  List of iterable objects allowing to query an object by id or by named index::

     heads = repo.heads
     heads.master
     heads['master']
     heads[0]

    Iterable parent objects:

    * :class:`Commit <git.objects.Commit>`
    * :class:`Submodule <git.objects.submodule.base.Submodule>`
    * :class:`Reference <git.refs.reference.Reference>`
    * :class:`FetchInfo <git.remote.FetchInfo>`
    * :class:`PushInfo <git.remote.PushInfo>`

    Iterable via inheritance:

    * :class:`Head <git.refs.head.Head>`
    * :class:`TagReference <git.refs.tag.TagReference>`
    * :class:`RemoteReference <git.refs.remote.RemoteReference>`

    This requires an ``id_attribute`` name to be set which will be queried from its
    contained items to have a means for comparison.

    A prefix can be specified which is to be used in case the id returned by the items
    always contains a prefix that does not matter to the user, so it can be left out.
    _id_attr_prefixrL   id_attrprefixrJ   zIterableList[T_IterableObj]c                 F    t                                          |           S r   )rt  __new__)r  r  r  ru  s      r\   r  zIterableList.__new__  s    wws###rb   Nc                 "    || _         || _        d S r   r  )ri   r  r  s      r\   r>  zIterableList.__init__  s    rb   r  c                     	 t                               | |          }|r|S n# t          t          f$ r Y nw xY w	 t	          | t          t          |                     dS # t          t          f$ r Y dS w xY w)NTF)list__contains__AttributeError	TypeErrorr  r5   r   )ri   r  rvals      r\   r  zIterableList.__contains__  s    	$$T400D 	* 	 	 	D	
	D$sD//***4	* 	 	 	55	s   " 66#A A43A4c                     | j         |z   }| D ]}t          || j                  |k    r|c S  t                              | |          S r   )r   r  r  r  __getattribute__)ri   r  items      r\   __getattr__zIterableList.__getattr__  sZ    |d" 	 	DtT]++t33 4 $$T4000rb   r0  c                 J   t          |t                    rt                              | |          S t          |t                    rt          d          	 t          | t          t          |                    S # t          $ r}t          d| j         |           |d }~ww xY w)NzIndex should be an int or strzNo item found with id )r$  rg  r  __getitem__slicer.  r  r5   r   r	  
IndexErrorr   )ri   r0  r   s      r\   r  zIterableList.__getitem__  s    eS!! 	X##D%000u%% 	X<===XtT#u%5%5666! X X X !O$,!O!O!OPPVWWXs   "A9 9
B"BB"c                 <   t          t          |          }t          |t                    rVd}| j        |z   }t          |           D ]"\  }}t          || j                  |k    r|} n#|dk    rt          d|z            t          
                    | |           d S )NzItem with name %s not found)r5   rg  r$  r   r   r*  r  r  r  r  __delitem__)ri   r0  delindexrH   ir  s         r\   r  zIterableList.__delitem__  s    U##eS!! 
	GH<%'D$T??  44//477 HE 8
 2~~ !>!EFFF 	x(((((rb   )rL   )ro   rd  re  rf  rl  r   r  r>  objectr   r  rE   r  r4   rB   rg  r  r  r  rw  rx  s   @r\   r
   r
   z  sA        8 (I$ $c $3 $8U $ $ $ $ $ $  S $     D    $1 1 1 1 1 1	X}c5#'E!F 	X= 	X 	X 	X 	X)}c5#'E!F )4 ) ) ) ) ) ) ) )rb   r
   c                       e Zd ZU dZdZeed<   eeddde	de	de
e         fd	                        Zeddde	de	dee         fd
            ZdS )r	   a  Defines an interface for iterable items, so there is a uniform way to retrieve
    and iterate items within the git repository.

    Subclasses:

    * :class:`Submodule <git.objects.submodule.base.Submodule>`
    * :class:`Commit <git.objects.Commit>`
    * :class:`Reference <git.refs.reference.Reference>`
    * :class:`PushInfo <git.remote.PushInfo>`
    * :class:`FetchInfo <git.remote.FetchInfo>`
    * :class:`Remote <git.remote.Remote>`
    r   _id_attribute_rm   r;   rj   rk   rJ   c                      t          d          )aS  Find (all) items of this type.

        Subclasses can specify `args` and `kwargs` differently, and may use them for
        filtering. However, when the method is called with no additional positional or
        keyword arguments, subclasses are obliged to to yield all items.

        :return:
            Iterator yielding Items
        To be implemented by SubclassNotImplementedErrorr  rm   rj   rk   s       r\   
iter_itemszIterableObj.iter_items  s     ""ABBBrb   c                 v    t          | j                  }|                     | j        |g|R i |           |S )a  Find (all) items of this type and collect them into a list.

        For more information about the arguments, see :meth:`iter_items`.

        :note:
            Favor the :meth:`iter_items` method as it will avoid eagerly collecting all
            items. When there are many items, that can slow performance and increase
            memory usage.

        :return:
            list(Item,...) list of item instances
        r
   r  extendr!  r  rm   rj   rk   out_lists        r\   
list_itemszIterableObj.list_items  sG     ".c.@!A!At=d===f==>>>rb   N)ro   rd  re  rf  rl  r   rh  r  r   r%   r,   rE   r!  r
   r'  r   rb   r\   r	   r	     s           ICf CS CC CH]D[ C C C ^ [C f S C LQ^D_    [  rb   r	   c                   *    e Zd ZdZdedededdfdZdS )IterableClassWatcherzbMetaclass that issues :exc:`DeprecationWarning` when :class:`git.util.Iterable`
    is subclassed.rH   basesclsdictrJ   Nc                 |    |D ]8}t          |          t          u r t          j        d| dt          d           9d S )Nz!GitPython Iterable subclassed by zq. Iterable is deprecated due to naming clash since v3.1.18 and will be removed in 4.0.0. Use IterableObj instead.   )
stacklevel)typer)  warningswarnDeprecationWarning)r  rH   r*  r+  bases        r\   r>  zIterableClassWatcher.__init__  se     		 		DDzz1110 0 0 0 '    		 		rb   )ro   rd  re  rf  r   r1   r)   r>  r   rb   r\   r)  r)    sN         
C 
 
 
 
 
 
 
 
 
rb   r)  c            	       j    e Zd ZdZdZdZedddededefd	            Zedddededefd
            Z	dS )IterablezDeprecated, use :class:`IterableObj` instead.

    Defines an interface for iterable items, so there is a uniform way to retrieve
    and iterate items within the git repository.
    r   z5attribute that most suitably identifies your instancerm   r;   rj   rk   rJ   c                      t          d          )zDeprecated, use :class:`IterableObj` instead.

        Find (all) items of this type.

        See :meth:`IterableObj.iter_items` for details on usage.

        :return:
            Iterator yielding Items
        r  r  r   s       r\   r!  zIterable.iter_items)  s     ""ABBBrb   c                 v    t          | j                  }|                     | j        |g|R i |           |S )a  Deprecated, use :class:`IterableObj` instead.

        Find (all) items of this type and collect them into a list.

        See :meth:`IterableObj.list_items` for details on usage.

        :return:
            list(Item,...) list of item instances
        r#  r%  s        r\   r'  zIterable.list_items6  sG     %S%788t=d===f==>>>rb   N)
ro   rd  re  rf  rl  r  r  r%   r!  r'  r   rb   r\   r5  r5    s          ILN
Cf 
CS 
CC 
CC 
C 
C 
C [
C f S C C    [  rb   r5  )	metaclass)r   )Fr   ).)T)r_   __all__r`   r   abcr   
contextlib	functoolsr   r  loggingrS   os.pathr|   r   pathlibr   rm  r   r   r  r  urllib.parser   r   r0  
gitdb.utilr   r   r   r   r    r!   r"   r#   r$   typingr%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   git.cmdr7   
git.configr8   r9   
git.remoter:   git.repo.baser;   	git.typesr<   r=   r>   r?   r@   rA   rB   rC   rD   rE   	getLoggerro   rV   r   r   r]   ra   r   rc   rd   r   contextmanagerrw   r{   r   r   rg  r   r   r   r   r   r   r   r   r   r   rn  Ir   rh  r   r   r   r   r  r  r   r  r  r!  r2  r   r   r   r   r   r   r   r
   r	   r/  r)  r5  r   rb   r\   <module>rK     s   



  * <7NN+,,,                   				              				        - - - - - - - - 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
                                       *  #========!!!!!!""""""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 u5V/Wcghhh '
H
%
% t     4
ES 
E4 
ED 
E 
E 
E 
E  /./JDQQ //0LdSS  GCLLhsAv& 8CF+;    $  i$(<=     
)C 
) 
)	2B(C 
) 
) 
) 
)- -d - - - -B d      x S Z]    $ x H    $ <7'X '# ' ' ' ''8 ' ' ' ' ' ,NN8      *N, ,h ,8 , , , , ( T d    &Xc]    # #c #(!3 #tCy # # # #L$hsm $3 $3 $ $ $ $. 	
@AA	f	f
 RZ)**Z%@RZ!""Z%8RZbd##&A&ADIRZ//E:E %gclHd:;S@A   # #    $ 2:?@@ #H # # # # # /1 $sHTN*+ 0 0 03 4    : 
 >$ >75> > > > 
 > 
 8( 8t 8 8 8 
 83%h"7 3D 3 3 3 3:S : : : :
5!13F!FG SV [_     
 > >4 >d >T > > > 
 > 
 8 $     

	 	5x( 	t 	xPXGY 	 	 	 	 $s)    Du u u u u u u up( ( ( ( (^ ( ( ((}Y }Y }Y }Y }Y }Y }Y }Y@=1 =1 =1 =1 =1 =1 =1 =1@               FK  K  K  K  K  K  K  K \> > > > >x > > >D[) [) [) [) [)4& [) [) [)| 1 1 1 1 1( 1 1 1h    4   "% % % % %- % % % % % %rb   