+
    §úÎjì  ã                  óx  a € 0 t $ ^ RIHt ^ RIt^ RIt^ RIt^ RIt^ RIHt ^ RI	H
t
HtHt ^ RIHt ^ RIHt R R ltR	 R
 ltR R ltR R ltR R lt]! ]R4      tR]R&   ]P2                  R8g  ;'       d    ]P4                  ]P6                  9   tR]R&   ]P4                  ]P:                  9   tR]R&   . ROtR# )é    )ÚannotationsN)Úsuppress)ÚEACCESÚEIOÚEISDIR)ÚPath)ÚFinalc               ó$   € V ^8„  d   QhRRRRRR/# )é   ÚfdÚintÚdataÚbytesÚreturnÚNone© )Úformats   "ÚH/opt/data/cache/scratch/pip-target-_o6w5emm/lib/python/filelock/_util.pyÚ__annotate__r      s!   € ÷ (ñ (�#ð (˜Uð ( tñ (ó    c                ó’   € \        V4      pV'       d4   \        P                  ! W4      ;p^ 8X  d   \        \        R4      hW#R pK;  R# )aý  
Write the whole buffer to *fd*, looping over the short writes POSIX lets ``os.write`` make.

A caller that stopped after one short write would leave a truncated marker behind. A peer that reads between two
writes sees a prefix of the record; each caller has to tolerate that. Lock records need not survive a power loss, so
we skip ``fsync``.

:param fd: file descriptor open for writing.
:param data: bytes to write in full.

:raises OSError: if a write reports zero progress before the record is complete.

z5os.write wrote 0 bytes before the record was completeN)Ú
memoryviewÚosÚwriteÚOSErrorr   )r   r   Ú	remainingÚwrittens   &&  r   Ú	write_allr      sD   € ô ˜4Ó €Iß
Ü—x’x Ó.Ð.ˆG°1Ô4Üœ#ÐVÓWÐWØ˜hÐ'Š	ñ r   c               ó    € V ^8„  d   QhRRRR/# )r   ÚfilenameÚstrr   r   r   )r   s   "r   r   r   "   s   € ÷ %Dñ %D¨ð %D°ñ %Dr   c                ól  €  \         P                  ! V 4      pTP                  \        P
                  ,          '       gu   \         P                  ! T \         P                  \         P                  \         P                  9   R7      '       g)    \         P                  ! T 4       \        \        RT 4      h\        P                  ! TP                  4      '       d8   \        P                  R8X  d   \        \        RT 4      h\        \         RT 4      hR#   \         d     R# i ; i  \         d     R# i ; i)a  
Raise an exception if attempting to open the file for writing would fail.

Separates files that can never be written from files that are writable but currently locked.

:param filename: file to check

:raises OSError: as if the file was opened for writing.

N)Úeffective_idszPermission deniedÚwin32zIs a directory)r   Úlstatr   Úst_modeÚstatÚS_IWUSRÚaccessÚW_OKÚsupports_effective_idsÚFileNotFoundErrorÚPermissionErrorr   ÚS_ISDIRÚsysÚplatformÚIsADirectoryErrorr   )r    Ú	file_stats   & r   Úraise_on_not_writable_filer3   "   sè   € ðô
 —H’H˜XÓ&ˆ	ð ×Ñ¤§¡×,Ô,´b·i²iØ”"—'‘'¬¯©´b×6OÑ6OÑ)O÷7ó 7ð	Ü�HŠH�XÔô œfÐ&9¸8ÓDÐDä‡|‚|�I×%Ñ%×&Ò&Ü�<‰<˜7Ô"Ü!¤&Ð*=¸xÓHÐHÜ¤Ð(8¸(ÓCÐCñ 'øô# ô Úðûô !ô 	âð	ús#   ‚D ÂD$ ÄD!Ä D!Ä$D3Ä2D3c               ó    € V ^8„  d   QhRRRR/# )r   r    z
Path | strr   r   r   )r   s   "r   r   r   J   s   € ÷ =ñ = jð =°Tñ =r   c                óR   € \        V 4      P                  P                  RRR7       R# )zd
Ensure the directory containing the file exists (create it if necessary).

:param filename: file.

T)ÚparentsÚexist_okN)r   ÚparentÚmkdir)r    s   &r   Úensure_directory_existsr:   J   s!   € ô 	ˆƒN×Ñ×Ñ¨°tÐÖ<r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   Ú	lock_filer!   Úmtime_beforeÚfloatÚ
ino_beforer   r   r   r   )r   s   "r   r   r   T   s(   € ÷ &&ñ &&˜sð &&°%ð &&ÀSð &&ÈTñ &&r   c                óè  € \         P                  ! V 4      ;pP                  V8”  g   VP                  V8w  d   R# V  R\         P                  ! 4        R\
        P                  ! ^4       2p\        V 4      P                  V4       \         P                  ! V4      ;pP                  V8:  d-   VP                  V8X  d   \        V4      P                  4        R# \        P                  ! VP                  4      '       d`   \        '       dR   \        \        4      ;_uu_ 4        \         P                   ! W@4       \        V4      P                  4        RRR4       R# R# R#   + '       g   i     R# ; i)a*  
Remove the lock file a caller found stale with modification time *mtime_before* and inode *ino_before*.

Right before renaming we ``lstat`` the lock again and leave it alone if a peer recreated it since the caller judged
it stale, as Mercurial re-reads a lock under its break lock. We rename before unlinking so that, of several
processes racing to break the same lock, one takes the file and the rest get ``OSError``. A newer modification time
or another inode on the renamed file means a peer recreated the lock between that ``lstat`` and the rename, so we
hard-link it back and drop the break name. ``link`` never replaces a name, so a marker a third process created after
our rename wins and the live one stays under the break name. In the two syscalls between rename and link a third
process can acquire beside the live holder, a soft lock by creating its marker or a StrictSoftFileLock by
publishing its sentinel at the empty path. Without ``os.link``, or on a filesystem that refuses hard links, the live
marker stays under the break name. We compare inodes as well as modification times because NFS and FAT store
coarse modification times, and a peer that recreates the lock within that granularity leaves the old mtime on it.
We call ``lstat`` to avoid following a symlink a peer swaps in after our stale check, and put back only a regular
file because ``link`` would follow a symlink to its target.

We add a random token to the break name so other processes cannot guess it and two breakers in one process do not
share ``<lock>.break.<pid>``. With a shared name, the second breaker could rename a recreated live lock onto that
path between our ``lstat`` and ``unlink``, and our ``unlink`` would delete it.

:param lock_file: path to the lock file to break.
:param mtime_before: modification time the caller saw when it judged the lock stale.
:param ino_before: inode number the caller saw when it judged the lock stale.

:raises OSError: if the rename, the re-check or the restore fails, for example because the file vanished or another
    user owns it in a sticky directory.

Nz.break.Ú.)r   r%   Úst_mtimeÚst_inoÚgetpidÚsecretsÚ	token_hexr   ÚrenameÚunlinkr'   ÚS_ISREGr&   Ú	_HAS_LINKr   ÚFileExistsErrorÚlink)r<   r=   r?   ÚcurrentÚ
break_pathÚst_afters   &&&   r   Úbreak_lock_filerP   T   sþ   € ô: —8’8˜IÓ&Ð&ˆ×0Ñ0°<Ô?À7Ç>Á>ÐU_ÔC_ÙØ )˜{¨'´"·)²)³+°¸aÄ×@QÒ@QÐRTÓ@UÐ?VÐW€JÜˆƒO×Ñ˜:Ô&Ü—H’H˜ZÓ(Ð(ˆ×2Ñ2°lÔBÀxÇÁÐZdÔGdÜˆZÓ×ÑÖ!Ü	�Š�h×&Ñ&×	'Ò	'¯I«IÜ”o×&Õ&Ü�GŠG�JÔ*Ü�Ó×#Ñ#Ô%÷ 'Ñ&ñ -6Ñ	'ß&×&Ð&ús   Ä"0E Å E1	c               ó$   € V ^8„  d   QhRRRRRR/# )r   Únamer!   r   r   r   r   r   )r   s   "r   r   r   }   s&   € ÷ Gñ G�ð G˜Cð G Dñ Gr   c               ó”   € \         '       d   \        P                  ! VR 4       R # \        P                  ! V R \        '       * R7       R # )N)Úfollow_symlinks)Ú_SUPPORTS_UTIME_FDr   ÚutimeÚ_SUPPORTS_UTIME_NOFOLLOW)rR   r   s   &$r   ÚtouchrX   }   s/   € ÷
 ÓÜ
�Š��TÔÙÜ‡H‚HˆT�4Ô-EÔ)E×Fr   rL   zFinal[bool]rJ   r$   rU   rW   )rP   r:   r3   rX   r   ) Ú__conditional_annotations__Ú
__future__r   r   rE   r'   r/   Ú
contextlibr   Úerrnor   r   r   Úpathlibr   Útypingr	   r   r3   r:   rP   rX   ÚhasattrrJ   Ú__annotations__r0   rV   Úsupports_fdrU   Úsupports_follow_symlinksrW   Ú__all__)rY   s   @r   Ú<module>rd      s£   øðß "Ð "ã 	Û Û Û 
Ý ß %Ñ %Ý Ý õ(õ*%DõP=õ&&õRGñ !  VÓ,€	ˆ;Ó ,ð #&§,¡,°'Ñ"9×"XÐ"X¸b¿h¹hÈ"Ï.É.Ñ>XÐ �KÓ Xà(*¯©°B×4OÑ4OÑ(OÐ ˜+Ó Oò‚r   