File: //usr/lib/python3/dist-packages/mercurial/__pycache__/narrowspec.cpython-310.pyc
o
�]LbK. � @ s d dl mZ ddlmZ ddlmZ ddlmZmZ m
Z
mZm
Z
mZmZmZ dZdZdZd d
� Zdd� Zd
d� Zd8dd�Zdd� Zdd� Zdd� Zd9dd�Zdd� Zdd� Zdd � Zd!d"� Zd#d$� Zd%d&� Z d'd(� Z!d)d*� Z"d+d,� Z#d-d.� Z$d/d0� Z%d1d2� Z&d3d4� Z'd:d6d7�Z(dS );� )�absolute_import� )�_)�getattr)�error�match�merge�
mergestate�requirements�scmutil�sparse�utils
narrowspecs narrowspec.dirstate)s path:s rootfilesin:c C s |� d�}t|� | |fS )z�Returns the normalized version of a pattern and kind.
Returns a tuple with the normalized kind and normalized pattern.
� /)�rstrip�_validatepattern)�kind�pat� r �6/usr/lib/python3/dist-packages/mercurial/narrowspec.py�normalizesplitpattern( s
r c C s t | d �� �S )z?Returns the number of lines in s, including ending empty lines.� x)�len�
splitlines)�sr r r � _numlines2 s r c C sF t | �dkr
t�td���| �d�}d|v sd|v r!t�td���dS )z�Validates the pattern and aborts if it is invalid.
Patterns are stored in the narrowspec as newline-separated
POSIX-style bytestring paths. There's no escaping.
r s, newlines are not allowed in narrowspec pathsr � .s ..s0 "." and ".." are not allowed in narrowspec pathsN)r r �Abortr �split)r �
componentsr r r r : s
��r � pathc C s t �| |�\}}dt||� S )zyReturns the normalized version of a text-format pattern.
If the pattern has no kind, the default will be added.
s %s:%s)�matchmod� _patsplitr )�pattern�defaultkindr r r r r �normalizepatternM s r$ c C s dd� | D �}t |� |S )a� Parses an iterable of patterns into a typed pattern set.
Patterns are assumed to be ``path:`` if no prefix is present.
For safety and performance reasons, only some prefixes are allowed.
See ``validatepatterns()``.
This function should be used on patterns that come from the user to
normalize and validate them to the internal data structure used for
representing patterns.
c S s h | ]}t |��qS r )r$ )�.0�origr r r � <setcomp>a s z parsepatterns.<locals>.<setcomp>)�validatepatterns)�pats�resr r r �
parsepatternsV s r+ c C s� t �dt| ���1 t| t�st�d| ��| D ]}|�t�s0tj t
d�| t
d�d�t� d��qW d � dS 1 s<w Y dS )a� Validate that patterns are in the expected data structure and format.
And that is a set of normalized patterns beginning with ``path:`` or
``rootfilesin:``.
This function should be used to validate internal data structures
and patterns that are loaded from sources that use the internal,
prefixed pattern representation (but can't necessarily be fully trusted).
z)narrowspec.validatepatterns(pats size=%d)s'