
    q&f                         d dl mZ ddl ddlmZ ddlmZ ej                  Zej                  Zej                         d        Z	de
d	ee
   d
e
fdZy)    )List   )*)mpatchError   )_mpatchc                 <   t         j                  |       \  }}t         j                  d      }t         j                  dt        ||               }|j	                  |       t
        j                  |t        |      dz
  |      }|dk  rt         j                  S |d   S )Ns   struct mpatch_flist*[1]   char[]r   r   )	ffifrom_handlenewstrappendlibmpatch_decodelenNULL)argposallbins	containerto_passrs          7/usr/lib/python3/dist-packages/mercurial/cffi/mpatch.pycffi_get_next_itemr      s~    $IC23IggiT#Y0GJJw'3w<!#3Y?A1uxxQ<    textr   returnc                 T   t        |      }g }|s| S ||f}t        j                  t        j	                  |      t        j
                  d|      }|st        d      t        j                  t        |       |      }|dk  r t        j                  |       t        d      t        j                  d|      }t        j                  || t        |       |      dk  r t        j                  |       t        d      t        j                  ||      d d  }t        j                  |       |S )Nr   s   cannot decode chunks   inconsistency detectedr
   s   error applying patches)r   r   mpatch_foldr   
new_handler   r   mpatch_calcsizempatch_lfreer   mpatch_applybuffer)	r   r   lgtr   r   patchoutlenbufress	            r   patchesr,      s    
d)C
C+COOCNN3/1G1GCPE011  TE2Fz344
'')V
$C
T3t9e4q8344
**S&
!!
$CUJr   N)typingr   pure.mpatchr    r   r   r   
def_externr   bytesr,    r   r   <module>r3      s^      % kkkk  % tE{ u r   