§
    |{Èc<  ã                   ód   — d Z ddlZddlZd„ Zd„ Zdd„Z G d	„ d
e¦  «        Z G d„ d¦  «        ZdS )zSafe access to git files.é    Nc                 óR   — 	 t          j        | ¦  «         dS # t          $ r Y dS w xY w)z1Ensure a directory exists, creating if necessary.N)ÚosÚmakedirsÚFileExistsError)Údirnames    ú./usr/lib/python3/dist-packages/dulwich/file.pyÚensure_dir_existsr	      s?   € ðÝ
Œ�GÑÔÐÐÐøÝð ð ð Øˆˆðøøøs   ‚ ˜
&¥&c                 ó.  — t           j                             |¦  «        s(	 t          j        | |¦  «         n# t          $ r ‚ w xY wdS ddl}	 |                     d| d¬¦  «        \  }}t          j        |¦  «         t          j        |¦  «         n# t          $ r ‚ w xY w	 t          j        ||¦  «         n# t          $ r ‚ w xY w	 t          j        | |¦  «         n$# t          $ r t          j        ||¦  «         ‚ w xY wt          j        |¦  «         dS )zBRename file with temporary backup file to rollback if rename failsNr   z.tmpú.)ÚprefixÚdir)	r   ÚpathÚexistsÚrenameÚOSErrorÚtempfileÚmkstempÚcloseÚremove)ÚoldnameÚnewnamer   ÚfdÚtmpfiles        r   Ú_fancy_renamer   #   s]  € åŒ7�>Š>˜'Ñ"Ô"ð ð	ÝŒI�g˜wÑ'Ô'Ð'Ð'øÝð 	ð 	ð 	Øð	øøøàˆð €O€O€OðØ ×(Ò(¨¸ÀSÐ(ÑIÔI‰ˆˆWÝ
Œ�‰ŒˆÝ
Œ	�'ÑÔÐÐøÝð ð ð ð 	ðøøøðÝ
Œ	�'˜7Ñ#Ô#Ð#Ð#øÝð ð ð ØðøøøðÝ
Œ	�'˜7Ñ#Ô#Ð#Ð#øÝð ð ð Ý
Œ	�'˜7Ñ#Ô#Ð#Øðøøøõ „IˆgÑÔÐÐÐs.   ¡7 ·AÁAB ÂBÂ!B7 Â7CÃC Ã!C>Úrbéÿÿÿÿé¤  c                 óÂ   — d|v rt          d¦  «        ‚d|v rt          d¦  «        ‚d|vrt          d¦  «        ‚d|v rt          | |||¦  «        S t          | ||¦  «        S )a  Create a file object that obeys the git file locking protocol.

    Returns: a builtin file object or a _GitFile object

    Note: See _GitFile for a description of the file locking protocol.

    Only read-only and write-only (binary) modes are supported; r+, w+, and a
    are not.  To read and write from the same file, you can take advantage of
    the fact that opening a file for write does not actually open the file you
    request.

    The default file mask makes any created files user-writable and
    world-readable.

    Úaz'append mode not supported for Git filesú+z+read/write mode not supported for Git filesÚbz%text mode not supported for Git filesÚw)r   Ú_GitFileÚopen)ÚfilenameÚmodeÚbufsizeÚmasks       r   ÚGitFiler)   D   s{   € ð  ˆd€{€{ÝÐ?Ñ@Ô@Ð@Ø
ˆd€{€{ÝÐCÑDÔDÐDØ
�$€€ÝÐ=Ñ>Ô>Ð>Ø
ˆd€{€{Ý˜ $¨°Ñ6Ô6Ð6å�H˜d GÑ,Ô,Ð,ó    c                   ó"   ‡ — e Zd ZdZˆ fd„Zˆ xZS )Ú
FileLockedzFile is already locked.c                 óh   •— || _         || _        t          ¦   «                              ||¦  «         d S ©N)r%   ÚlockfilenameÚsuperÚ__init__)Úselfr%   r/   Ú	__class__s      €r   r1   zFileLocked.__init__c   s2   ø€ Ø ˆŒØ(ˆÔÝ‰Œ×Ò˜ <Ñ0Ô0Ð0Ð0Ð0r*   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r1   Ú__classcell__)r3   s   @r   r,   r,   `   s>   ø€ € € € € Ø!Ð!ð1ð 1ð 1ð 1ð 1ð 1ð 1ð 1ð 1r*   r,   c                   óB   — e Zd ZdZh d£ZdZd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
S )r#   ap  File that follows the git locking protocol for writes.

    All writes to a file foo will be written into foo.lock in the same
    directory, and the lockfile will be renamed to overwrite the original file
    on close.

    Note: You *must* call close() or abort() on a _GitFile for the lock to be
        released. Typically this will happen in a finally block.
    >   r&   ÚnameÚclosedÚerrorsÚencodingÚnewlinesÚ	softspace)Ú__iter__ÚflushÚfilenoÚisattyÚreadÚreadlineÚ	readlinesÚseekÚtellÚtruncateÚwriteÚ
writelinesc           	      ó&  — || _         t          | j         t          ¦  «        r| j         dz   | _        n| j         dz   | _        	 t	          j        | j        t          j        t          j        z  t          j        z  t          t          dd¦  «        z  |¦  «        }n(# t          $ r}t          || j        ¦  «        |‚d }~ww xY wt	          j        |||¦  «        | _        d| _        | j        D ]&}t!          | |t          | j        |¦  «        ¦  «         Œ'd S )Ns   .lockz.lockÚO_BINARYr   F)Ú	_filenameÚ
isinstanceÚbytesÚ_lockfilenamer   r$   ÚO_RDWRÚO_CREATÚO_EXCLÚgetattrr   r,   ÚfdopenÚ_fileÚ_closedÚPROXY_METHODSÚsetattr)r2   r%   r&   r'   r(   r   ÚexcÚmethods           r   r1   z_GitFile.__init__Œ   s  € Ø!ˆŒÝ�d”n¥eÑ,Ô,ð 	:Ø!%¤°(Ñ!:ˆDÔÐà!%¤°'Ñ!9ˆDÔð	DÝ”ØÔ"Ý”	�BœJÑ&­¬Ñ2µW½RÀÈQÑ5OÔ5OÑOØñô ˆBˆBøõ
 ð 	Dð 	Dð 	DÝ˜X tÔ'9Ñ:Ô:ÀÐCøøøøð	Døøøå”Y˜r 4¨Ñ1Ô1ˆŒ
ØˆŒàÔ(ð 	?ð 	?ˆFÝ�D˜&¥'¨$¬*°fÑ"=Ô"=Ñ>Ô>Ð>Ð>ð	?ð 	?s   ÁAB Â
B>Â#B9Â9B>c                 ó¼   — | j         rdS | j                             ¦   «          	 t          j        | j        ¦  «         d| _         dS # t          $ r d| _         Y dS w xY w)z€Close and discard the lockfile without overwriting the target.

        If the file is already closed, this is a no-op.
        NT)rX   rW   r   r   r   rQ   ÚFileNotFoundError©r2   s    r   Úabortz_GitFile.abort    sr   € ð
 Œ<ð 	ØˆFØŒ
×ÒÑÔÐð	 ÝŒI�dÔ(Ñ)Ô)Ð)ØˆDŒLˆLˆLøÝ ð 	 ð 	 ð 	 àˆDŒLˆLˆLˆLð	 øøøs   ¤ A ÁAÁAc                 ó.  — | j         rdS | j                             ¦   «          t          j        | j                             ¦   «         ¦  «         | j                             ¦   «          	 t          t          dd¦  «        � t          j        | j	        | j
        ¦  «         nJt          j        dk    r t          j        | j	        | j
        ¦  «         nt          | j	        | j
        ¦  «         |                      ¦   «          dS # |                      ¦   «          w xY w)a6  Close this file, saving the lockfile over the original.

        Note: If this method fails, it will attempt to delete the lockfile.
            However, it is not guaranteed to do so (e.g. if a filesystem
            becomes suddenly read-only), which will prevent future writes to
            this file until the lockfile is removed manually.
        Raises:
          OSError: if the original file could not be overwritten. The
            lock file is still closed, so further attempts to write to the same
            file object will raise ValueError.
        NÚreplaceÚwin32)rX   rW   rA   r   ÚfsyncrB   r   rU   rb   rQ   rN   ÚsysÚplatformr   r   r`   r_   s    r   r   z_GitFile.close¯   së   € ð Œ<ð 	ØˆFØŒ
×ÒÑÔÐÝ
Œ�”×"Ò"Ñ$Ô$Ñ%Ô%Ð%ØŒ
×ÒÑÔÐð	Ý•r˜9 dÑ+Ô+Ð7Ý”
˜4Ô-¨t¬~Ñ>Ô>Ð>Ð>å”< 7Ò*Ð*Ý”I˜dÔ0°$´.ÑAÔAÐAÐAõ " $Ô"4°d´nÑEÔEÐEà�JŠJ‰LŒLˆLˆLˆLøˆD�JŠJ‰LŒLˆLˆLøøøs   Á(B C> Ã>Dc                 ó   — | S r.   © r_   s    r   Ú	__enter__z_GitFile.__enter__Í   s   € Øˆr*   c                 ó^   — |�|                       ¦   «          d S |                      ¦   «          d S r.   )r`   r   )r2   Úexc_typeÚexc_valÚexc_tbs       r   Ú__exit__z_GitFile.__exit__Ð   s*   € ØÐØ�JŠJ‰LŒLˆLˆLˆLà�JŠJ‰LŒLˆLˆLˆLr*   c                 ó\   — || j         v rt          | j        |¦  «        S t          |¦  «        ‚)z,Proxy property calls to the underlying file.)ÚPROXY_PROPERTIESrU   rW   ÚAttributeError)r2   r:   s     r   Ú__getattr__z_GitFile.__getattr__Ö   s0   € à�4Ô(Ð(Ð(Ý˜4œ: tÑ,Ô,Ð,Ý˜TÑ"Ô"Ð"r*   N)r4   r5   r6   r7   rp   rY   r1   r`   r   ri   rn   rr   rh   r*   r   r#   r#   i   s‘   € € € € € ðð ðð ð Ðð€Mð?ð ?ð ?ð( ð  ð  ðð ð ð<ð ð ðð ð ð#ð #ð #ð #ð #r*   r#   )r   r   r   )	r7   r   re   r	   r   r)   Ú	Exceptionr,   r#   rh   r*   r   ú<module>rt      s¸   ðð*  Ð à 	€	€	€	Ø 
€
€
€
ðð ð ðð ð ðB-ð -ð -ð -ð81ð 1ð 1ð 1ð 1�ñ 1ô 1ð 1ðq#ð q#ð q#ð q#ð q#ñ q#ô q#ð q#ð q#ð q#r*   