File: //usr/lib/python3/dist-packages/mercurial/__pycache__/pathutil.cpython-310.pyc
o
�]Lb�0 � @ s d dl mZ d dlZd dlZd dlZd dlZd dlZddlmZ ddl m
Z
mZmZm
Z
mZ e
jr=d dlmZmZmZmZ e�dd�Ze�d �Zd
d� ZG dd
� d
e�Zddd�Zdd� Zdd� ZG dd� de�Ze� ed�rrejZedurxeZej!Z!ej"Z"dS )� )�absolute_importN� )�_)�encoding�error�policy�pycompat�util)�Any�Callable�Iterator�Optional�dirstate�Dirs�parsersc C s t �| �� �S �N)r �hfsignoreclean�lower)�s� r �4/usr/lib/python3/dist-packages/mercurial/pathutil.py�_lowerclean s r c @ sB e Zd ZdZddd�Zddd�Zd d
� Zdd� Zej d
d� �Z
dS )�pathauditora^ ensure that a filesystem path contains no banned components.
the following properties of a path are checked:
- ends with a directory separator
- under top-level .hg
- starts at the root of a windows drive
- contains ".."
More check are also done about the file system states:
- traverses a symlink (e.g. a/symlink_here/b)
- inside a nested repository (a callback can be used to approve
some nested repositories, e.g., subrepositories)
The file system checks are only done when 'realfs' is set to True (the
default). They should be disable then we are auditing path for operation on
stored history.
If 'cached' is set to True, audited paths and sub-directories are cached.
Be careful to not keep the cache of unmanaged directories for long because
audited paths may be replaced with symlinks.
NTFc C sX t � | _t � | _|| _|| _|| _|| _tj� |�r%t
�|�s%t
j| _d S dd� | _d S )Nc S s | S r r )�xr r r �<lambda>E s z&pathauditor.__init__.<locals>.<lambda>)
�set�audited�
auditeddir�root�_realfs�_cached�callback�os�path�lexistsr �fscasesensitive�normcase)�selfr r! �realfs�cachedr r r �__init__; s zpathauditor.__init__c C s� t �|�}| �|�}|| jv rdS t �|�rt�td�| ��t �|�}t j
�|�d s9t|d �dv s9t
j|v rBt�td�| ��|D ]!}d|v re|�dd�\}}|�� re|�� dv ret�td�| ��qDd t|�v r�d
d� |D �}dD ]'}||dd� v r�|�|�} t j
j|d| � � }
t�td
�|t
�|
�f ��qut �|�}t|�t|�ks�J �|�� |�� tt|��D ]2}t
j�|d|d � �}
t
j�|d|d � �}|| jv r�q�| jr�| �|
|� | jr�| j�|� q�| jr�| j�|� dS dS )zPCheck the relative path.
path may contain a pattern (e.g. foodir/**.txt)Ns$ path ends in directory separator: %sr )� .hg� .hg.� s# path contains illegal component: %s� ~r )s HGs HG8B6Cr+ c S s g | ]}t |��qS r )r )�.0�pr r r �
<listcomp>g s z(pathauditor.__call__.<locals>.<listcomp>)r+ r, �"