U
    )3g                     @   s  d Z ddddddddd	d
ddddddddddddgZddlmZmZmZmZmZmZm	Z	m
Z
 ddlmZ ddlmZ ddlmZmZmZmZmZ ddlmZ erddlmZ G dd	 d	eZG dd
 d
eZG d d deZG d!d deeZG d"d deZG d#d deZ G d$d deZ!G d%d de!Z"G d&d de!Z#G d'd deZ$G d(d deZ%G d)d de%Z&G d*d de!Z'G d+d deZ(d,S )-z-Exceptions thrown throughout the git package.AmbiguousObjectNameBadName	BadObjectBadObjectTypeInvalidDBRootODBError
ParseErrorUnsupportedOperationGitErrorInvalidGitRepositoryErrorWorkTreeRepositoryUnsupportedNoSuchPathErrorUnsafeProtocolErrorUnsafeOptionErrorCommandErrorGitCommandNotFoundGitCommandErrorCheckoutError
CacheErrorUnmergedEntriesErrorHookExecutionErrorRepositoryDirtyError    )r   r   r   r   r   r   r   r   safe_decode)remove_password_if_present)ListSequenceTupleTYPE_CHECKINGUnion)PathLike)Repoc                   @   s   e Zd ZdZdS )r	   z&Base class for all package exceptions.N__name__
__module____qualname____doc__ r'   r'   +/tmp/pip-unpacked-wheel-3opeica4/git/exc.pyr	   =   s   c                   @   s   e Zd ZdZdS )r
   zAThrown if the given repository appears to have an invalid format.Nr"   r'   r'   r'   r(   r
   A   s   c                   @   s   e Zd ZdZdS )r   z:Thrown to indicate we can't handle work tree repositories.Nr"   r'   r'   r'   r(   r   E   s   c                   @   s   e Zd ZdZdS )r   z3Thrown if a path could not be access by the system.Nr"   r'   r'   r'   r(   r   I   s   c                   @   s   e Zd ZdZdS )r   zGThrown if unsafe protocols are passed without being explicitly allowed.Nr"   r'   r'   r'   r(   r   M   s   c                   @   s   e Zd ZdZdS )r   zEThrown if unsafe options are passed without being explicitly allowed.Nr"   r'   r'   r'   r(   r   Q   s   c                   @   sp   e Zd ZdZdZdeee eedf ef eee	de
f eeedf eeedf ddddZedd	d
ZdS )r   zBase class for exceptions thrown at every stage of :class:`~subprocess.Popen`
    execution.

    :param command:
        A non-empty list of argv comprising the command-line.
    zCmd('%s') failed%sN.commandstatusstderrstdoutreturnc              	   C   s  t |ttfs| }t|| _|| _|rt |trPdt|j	t
t|f }nLzdt| }W n: ttfk
r   t
t|}t |trd| n|}Y nX t
| jd | _ddd | jD | _|rd| pd	| _t
|}t
|}|rd
| pd| _|rd| p
d| _d S )Nz%s('%s')zexit code(%s)z'%s'r    c                 s   s   | ]}t |V  qd S Nr   ).0ir'   r'   r(   	<genexpr>{   s     z(CommandError.__init__.<locals>.<genexpr>z due to: %s!z
  stdout: '%s' z
  stderr: '%s')
isinstancetuplelistsplitr   r*   r+   	Exceptiontyper#   r   strint
ValueError	TypeError_cmdjoin_cmdline_causer-   r,   )selfr*   r+   r,   r-   sZstdout_decodeZstderr_decoder'   r'   r(   __init__e   s&    

zCommandError.__init__r.   c                 C   s"   | j d | j| j| j| j| jf S )Nz
  cmdline: %s%s%s)_msgr@   rC   rB   r-   r,   rD   r'   r'   r(   __str__   s    zCommandError.__str__)NNN)r#   r$   r%   r&   rH   r   r   r<   r   r=   r:   bytesrF   rJ   r'   r'   r'   r(   r   U   s      c                       sD   e Zd ZdZeee ee ef eeef dd fddZ	  Z
S )r   zThrown if we cannot find the ``git`` executable in the :envvar:`PATH` or at the
    path given by the :envvar:`GIT_PYTHON_GIT_EXECUTABLE` environment variable.N)r*   causer.   c                    s   t  || d| _d S )NzCmd('%s') not found%ssuperrF   rH   )rD   r*   rL   	__class__r'   r(   rF      s    zGitCommandNotFound.__init__)r#   r$   r%   r&   r   r   r<   r   r:   rF   __classcell__r'   r'   rO   r(   r      s   c                       sf   e Zd ZdZdeee eedf ef eeede	f ee
edf ee
edf dd fddZ  ZS )r   zGThrown if execution of the git command fails with non-zero status code.N.r)   c                    s   t  |||| d S r0   )rN   rF   rD   r*   r+   r,   r-   rO   r'   r(   rF      s    zGitCommandError.__init__)NNNr#   r$   r%   r&   r   r   r<   r   r=   r:   rK   rF   rQ   r'   r'   rO   r(   r      s      c                   @   s@   e Zd ZdZeee ee ee ddddZedddZ	dS )	r   a  Thrown if a file could not be checked out from the index as it contained
    changes.

    The :attr:`failed_files` attribute contains a list of relative paths that failed to
    be checked out as they contained changes that did not exist in the index.

    The :attr:`failed_reasons` attribute contains a string informing about the actual
    cause of the issue.

    The :attr:`valid_files` attribute contains a list of relative paths to files that
    were checked out successfully and hence match the version stored in the index.
    N)messagefailed_filesvalid_filesfailed_reasonsr.   c                 C   s"   t | | || _|| _|| _d S r0   )r:   rF   rU   rW   rV   )rD   rT   rU   rV   rW   r'   r'   r(   rF      s    zCheckoutError.__init__rG   c                 C   s   t | d| j  S )Nz:%s)r:   rJ   rU   rI   r'   r'   r(   rJ      s    zCheckoutError.__str__)
r#   r$   r%   r&   r<   r   r    r   rF   rJ   r'   r'   r'   r(   r      s   c                   @   s   e Zd ZdZdS )r   zUBase for all errors related to the git index, which is called "cache"
    internally.Nr"   r'   r'   r'   r(   r      s   c                   @   s   e Zd ZdZdS )r   z[Thrown if an operation cannot proceed as there are still unmerged
    entries in the cache.Nr"   r'   r'   r'   r(   r      s   c                       sf   e Zd ZdZdeee eedf ef eeede	f ee
edf ee
edf dd fddZ  ZS )r   zThrown if a hook exits with a non-zero exit code.

    This provides access to the exit code and the string returned via standard output.
    N.r)   c                    s   t  |||| d| _d S )NzHook('%s') failed%srM   rR   rO   r'   r(   rF      s    zHookExecutionError.__init__)NNrS   r'   r'   rO   r(   r      s   	  c                   @   s0   e Zd ZdZdeddddZeddd	ZdS )
r   zoThrown whenever an operation on a repository fails as it has uncommitted changes
    that would be overwritten.r!   N)reporT   r.   c                 C   s   || _ || _d S r0   rX   rT   )rD   rX   rT   r'   r'   r(   rF      s    zRepositoryDirtyError.__init__rG   c                 C   s   d| j | jf S )Nz'Operation cannot be performed on %r: %srY   rI   r'   r'   r(   rJ      s    zRepositoryDirtyError.__str__)r#   r$   r%   r&   r<   rF   rJ   r'   r'   r'   r(   r      s   N))r&   __all__Z	gitdb.excr   r   r   r   r   r   r   r   Z
git.compatr   Zgit.utilr   typingr   r   r   r   r   Z	git.typesr    Zgit.repo.baser!   r:   r	   r
   r   OSErrorr   r   r   r   r   r   r   r   r   r   r   r'   r'   r'   r(   <module>   sX   (7	