
                            d Z ddlZ G d de      Z G d de      Z G d de      Z G d	 d
e      Z G d de      Z G d de      Z G d de      Z	 G d de      Z
 G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d d e      Z G d! d"e      Z G d# d$e      Z G d% d&e      Z G d' d(e      Z G d) d*e      Z G d+ d,e      Z G d- d.e      Zy)/z8Dulwich-related exception classes and utility functions.    Nc                       e Zd ZdZddZy)ChecksumMismatchz.A checksum didn't match the expected contents.Nc           	      J   t        |      dk(  rt        j                  |      }t        |      dk(  rt        j                  |      }|| _        || _        || _        | j
                  t        j                  | d|d|       y t        j                  | d|d|d|       y )N   zChecksum mismatch: Expected z, got z; )lenbinasciihexlifyexpectedgotextra	Exception__init__)selfr
   r   r   s       !lib/third_party/dulwich/errors.pyr   zChecksumMismatch.__init__   s    x=B''1Hs8r>""3'C 
::<DcJ
 @H#uU    N__name__
__module____qualname____doc__r    r   r   r   r      s
    8r   r   c                       e Zd ZdZd Zy)WrongObjectExceptionzBaseclass for all the _ is not a _ exceptions on objects.

    Do not instantiate directly.

    Subclasses should define a type_name attribute that indicates what
    was expected if they were raised.
    c                 N    t         j                  | |d| j                         y )Nz
 is not a )r   r   	type_namer   shaargskwargss       r   r   zWrongObjectException.__init__;   s    4S$..!IJr   Nr   r   r   r   r   r   2   s    Kr   r   c                       e Zd ZdZdZy)NotCommitErrorz<Indicates that the sha requested does not point to a commit.commitNr   r   r   r   r   r   r   r   r"   r"   ?   s
    FIr   r"   c                       e Zd ZdZdZy)NotTreeErrorz:Indicates that the sha requested does not point to a tree.treeNr$   r   r   r   r&   r&   E   
    DIr   r&   c                       e Zd ZdZdZy)NotTagErrorz9Indicates that the sha requested does not point to a tag.tagNr$   r   r   r   r*   r*   K   s
    CIr   r*   c                       e Zd ZdZdZy)NotBlobErrorz:Indicates that the sha requested does not point to a blob.blobNr$   r   r   r   r-   r-   Q   r(   r   r-   c                       e Zd ZdZd Zy)MissingCommitErrorz7Indicates that a commit was not found in the repositoryc                 D    || _         t        j                  | d|z         y )Nz%s is not in the revision store)r   r   r   r   s       r   r   zMissingCommitError.__init__Z   s    4!BS!HIr   Nr   r   r   r   r0   r0   W   s    AJr   r0   c                       e Zd ZdZd Zy)ObjectMissingz-Indicates that a requested object is missing.c                 6    t         j                  | d|z         y )Nz%s is not in the packr   r   r   s       r   r   zObjectMissing.__init__b   s    4!83!>?r   Nr   r   r   r   r3   r3   _   s    7@r   r3   c                       e Zd ZdZd Zy)ApplyDeltaErrorz'Indicates that applying a delta failed.c                 6    t        j                  | g|i | y r   r5   r   r   r    s      r   r   zApplyDeltaError.__init__i       41$1&1r   Nr   r   r   r   r7   r7   f   s
    12r   r7   c                       e Zd ZdZd Zy)NotGitRepositoryz+Indicates that no Git repository was found.c                 6    t        j                  | g|i | y r   r5   r9   s      r   r   zNotGitRepository.__init__p   r:   r   Nr   r   r   r   r<   r<   m   s
    52r   r<   c                       e Zd ZdZd Zd Zy)GitProtocolErrorzGit protocol exception.c                 6    t        j                  | g|i | y r   r5   r9   s      r   r   zGitProtocolError.__init__w   r:   r   c                 b    t        | t        |            xr | j                  |j                  k(  S r   )
isinstancetyper   r   others     r   __eq__zGitProtocolError.__eq__z   s%    $U,Hejj1HHr   N)r   r   r   r   r   rF   r   r   r   r?   r?   t   s    !2Ir   r?   c                       e Zd ZdZy)SendPackErrorz#An error occurred during send_pack.Nr   r   r   r   r   r   r   rH   rH   ~   s    -r   rH   c                   "     e Zd ZdZ fdZ xZS )UpdateRefsErrorz)The server reported errors updating refs.c                 X    |j                  d      | _        t        t        |   |i | y )N
ref_status)poprM   superrK   r   )r   r   r    	__class__s      r   r   zUpdateRefsError.__init__   s'     **\2ot-t>v>r   r   r   r   r   r   __classcell__rP   s   @r   rK   rK      s    3? ?r   rK   c                   *     e Zd ZdZd fd	Zd Z xZS )HangupExceptionzHangup exception.c                     |rHt         t        |   dj                  |D cg c]  }|j	                  dd       c}             || _        y t         t        |   d       || _        y c c}w )N
zutf-8surrogateescapez5The remote server unexpectedly closed the connection.)rO   rU   r   joindecodestderr_lines)r   r[   linerP   s      r   r   zHangupException.__init__   sm    /41		IUVT[[*;<V ) /41G ) Ws   A'c                 b    t        | t        |            xr | j                  |j                  k(  S r   )rB   rC   r[   rD   s     r   rF   zHangupException.__eq__   s)    $U,X1B1BeFXFX1XXr   r   )r   r   r   r   r   rF   rR   rS   s   @r   rU   rU      s    )Yr   rU   c                   "     e Zd ZdZ fdZ xZS )UnexpectedCommandErrorz,Unexpected command received in a proto line.c                 F    |d}nd|z  }t         t        |   d|z         y )Nz	flush-pktz
command %szProtocol got unexpected %s)rO   r_   r   )r   commandrP   s     r   r   zUnexpectedCommandError.__init__   s/    ?!G"W,G$d4(72	
r   rQ   rS   s   @r   r_   r_      s    6
 
r   r_   c                       e Zd ZdZy)FileFormatExceptionz?Base class for exceptions relating to reading git file formats.NrI   r   r   r   rc   rc      s    Ir   rc   c                       e Zd ZdZy)PackedRefsExceptionz.Indicates an error parsing a packed-refs file.NrI   r   r   r   re   re      s    8r   re   c                       e Zd ZdZy)ObjectFormatExceptionz%Indicates an error parsing an object.NrI   r   r   r   rg   rg      s    /r   rg   c                       e Zd ZdZy)NoIndexPresentzNo index is present.NrI   r   r   r   ri   ri      s    r   ri   c                       e Zd ZdZy)CommitErrorz,An error occurred while performing a commit.NrI   r   r   r   rk   rk      s    6r   rk   c                       e Zd ZdZy)RefFormatErrorzIndicates an invalid ref name.NrI   r   r   r   rm   rm      s    (r   rm   c                       e Zd ZdZy)	HookErrorz)An error occurred while executing a hook.NrI   r   r   r   ro   ro      s    3r   ro   )r   r   r   r   r   r"   r&   r*   r-   r0   r3   r7   r<   r?   rH   rK   rU   r_   rc   re   rg   ri   rk   rm   ro   r   r   r   <module>rp      s+  , ? y .
K9 
K) ' & ' J J@I @2i 22y 2Iy I.$ .?& ?Y& Y(

- 

J) J9- 90/ 0Y 7) 7)Y )4	 4r   