File: //usr/lib/python3/dist-packages/mercurial/__pycache__/loggingutil.cpython-310.pyc
o
�]Lb� � @ s� d dl mZ d dlZddlmZmZ ddlmZmZm Z ddd�Z
dd � Zd
d� ZG dd
� d
e
�ZG dd� de
�ZG dd� de
�ZdS )� )�absolute_importN� )�encoding�pycompat)�dateutil�procutil�
stringutilc s� � �fdd�}|dkrNz�� |�}W n ty Y n3w |j|krN��|�}t�|d dd�D ]}|d||d f d||f d� q/|||dkoK|d d� �|d d
d�S )z{Open log file in append mode, with optional rotation
If maxsize > 0, the log file will be rotated up to maxfiles.
c s� z�� |� W n% ty, } z|jtjkr"� �d|t�|j�f � W Y d }~nd }~ww z|r9��| |� W d S W d S tyi } z"|jtjkr^� �d|| t�|j�f � W Y d }~d S W Y d }~d S d }~ww )Ns warning: cannot remove '%s': %s
s( warning: cannot rename '%s' to '%s': %s
) �unlink�OSError�errno�ENOENT�debugr �
strtolocal�strerror�rename)�oldpath�newpath�err��ui�vfs� �7/usr/lib/python3/dist-packages/mercurial/loggingutil.py�rotate s2 ����������zopenlogfile.<locals>.rotater r ���s %s.%d)r r s .1� aF)�makeparentdirs)�statr
�st_size�joinr �xrange) r r �name�maxfiles�maxsizer �st�path�ir r r �openlogfile s �
�r'