B
    %d.                 @   sN  d Z ddlmZ ddlT 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rhd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 )&zE Module containing all exceptions thrown throughout the git package,     )BadName)*)safe_decode)remove_password_if_present)ListSequenceTupleUnionTYPE_CHECKING)PathLike)Repoc               @   s   e Zd ZdZdS )GitErrorz%Base class for all package exceptionsN)__name__
__module____qualname____doc__ r   r   T/work/yifan.wang/ringdown/master-ringdown-env/lib/python3.7/site-packages/git/exc.pyr      s   r   c               @   s   e Zd ZdZdS )InvalidGitRepositoryErrorzAThrown if the given repository appears to have an invalid format.N)r   r   r   r   r   r   r   r   r      s   r   c               @   s   e Zd ZdZdS )WorkTreeRepositoryUnsupportedz9Thrown to indicate we can't handle work tree repositoriesN)r   r   r   r   r   r   r   r   r       s   r   c               @   s   e Zd ZdZdS )NoSuchPathErrorz3Thrown if a path could not be access by the system.N)r   r   r   r   r   r   r   r   r   $   s   r   c               @   s   e Zd ZdZdS )UnsafeProtocolErrorzGThrown if unsafe protocols are passed without being explicitly allowed.N)r   r   r   r   r   r   r   r   r   (   s   r   c               @   s   e Zd ZdZdS )UnsafeOptionErrorzEThrown if unsafe options are passed without being explicitly allowed.N)r   r   r   r   r   r   r   r   r   ,   s   r   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 )CommandErrorzBase class for exceptions thrown at every stage of `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 }nLy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 )N)r   ).0ir   r   r   	<genexpr>R   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__<   s&    

zCommandError.__init__)r   c             C   s"   | j d | j| j| j| j| jf S )Nz
  cmdline: %s%s%s)_msgr/   r2   r1   r   r   )r3   r   r   r   __str__Y   s    zCommandError.__str__)NNN)r   r   r   r   r6   r	   r   r+   r   r,   r)   bytesr5   r7   r   r   r   r   r   0   s     @r   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 )GitCommandNotFoundzThrown if we cannot find the `git` executable in the PATH or at the path given by
    the GIT_PYTHON_GIT_EXECUTABLE environment variableN)r   causer   c                s   t t| || d| _d S )NzCmd('%s') not found%s)superr9   r5   r6   )r3   r   r:   )	__class__r   r   r5   g   s    zGitCommandNotFound.__init__)r   r   r   r   r	   r   r+   r   r)   r5   __classcell__r   r   )r<   r   r9   c   s   r9   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 )GitCommandErrorzGThrown if execution of the git command fails with non-zero status code.N.)r   r   r   r   r   c                s   t t| |||| d S )N)r;   r>   r5   )r3   r   r   r   r   )r<   r   r   r5   o   s    zGitCommandError.__init__)NNN)r   r   r   r   r	   r   r+   r   r,   r)   r8   r5   r=   r   r   )r<   r   r>   l   s
     @r>   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 )	CheckoutErrora  Thrown if a file could not be checked out from the index as it contained
    changes.

    The .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 .failed_reasons attribute contains a string informing about the actual
    cause of the issue.

    The .valid_files attribute contains a list of relative paths to files that
    were checked out successfully and hence match the version stored in the
    indexN)messagefailed_filesvalid_filesfailed_reasonsr   c             C   s"   t | | || _|| _|| _d S )N)r)   r5   rA   rC   rB   )r3   r@   rA   rB   rC   r   r   r   r5      s    zCheckoutError.__init__)r   c             C   s   t | d| j  S )Nz:%s)r)   r7   rA   )r3   r   r   r   r7      s    zCheckoutError.__str__)
r   r   r   r   r+   r   r   r   r5   r7   r   r   r   r   r?   y   s   r?   c               @   s   e Zd ZdZdS )
CacheErrorzNBase for all errors related to the git index, which is called cache internallyN)r   r   r   r   r   r   r   r   rD      s   rD   c               @   s   e Zd ZdZdS )UnmergedEntriesErrorzZThrown if an operation cannot proceed as there are still unmerged
    entries in the cacheN)r   r   r   r   r   r   r   r   rE      s   rE   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 )HookExecutionErrorzThrown if a hook exits with a non-zero exit code. It provides access to the exit code and the string returned
    via standard outputN.)r   r   r   r   r   c                s    t t| |||| d| _d S )NzHook('%s') failed%s)r;   rF   r5   r6   )r3   r   r   r   r   )r<   r   r   r5      s    zHookExecutionError.__init__)NN)r   r   r   r   r	   r   r+   r   r,   r)   r8   r5   r=   r   r   )r<   r   rF      s    @rF   c               @   s0   e Zd ZdZdeddddZeddd	ZdS )
RepositoryDirtyErrorzjThrown whenever an operation on a repository fails as it has uncommitted changes that would be overwrittenr   N)repor@   r   c             C   s   || _ || _d S )N)rH   r@   )r3   rH   r@   r   r   r   r5      s    zRepositoryDirtyError.__init__)r   c             C   s   d| j | jf S )Nz'Operation cannot be performed on %r: %s)rH   r@   )r3   r   r   r   r7      s    zRepositoryDirtyError.__str__)r   r   r   r   r+   r5   r7   r   r   r   r   rG      s   rG   N)!r   Z	gitdb.excr   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   r9   r>   r?   rD   rE   rF   rG   r   r   r   r   <module>   s,   3	