File: //lib/python3/dist-packages/pip/_internal/vcs/__pycache__/versioncontrol.cpython-312.pyc
�
��hY � �� � d Z ddlZddlZddlZddlZddlZddlmZm Z m
Z
mZmZm
Z
mZmZmZmZmZ ddlmZ ddlmZmZ ddlmZmZmZmZmZmZmZm Z ddl!m"Z"m#Z#m$Z$m%Z% ddl&m'Z' erdd lm(Z( d
gZ) ejT e+� Z,eee- ee- f Z.de-de/fd
�Z0 d de-de-de-dee- de-f
d�Z1de-de-dee- fd�Z2 G d� de3� Z4 G d� de3� Z5 G d� d� Z6 G d� d� Z7 e7� Z8 G d� d� Z9y)!z)Handles all VCS (version control) support� N)�
TYPE_CHECKING�Any�Dict�Iterable�Iterator�List�Mapping�Optional�Tuple�Type�Union)�SpinnerInterface)�
BadCommand�InstallationError)�
HiddenText�ask_path_exists�
backup_dir�display_path�hide_url�
hide_value�is_installable_dir�rmtree)�CommandArgs�call_subprocess�format_command_args�make_command)�get_url_scheme)�Literal�vcs�name�returnc �L � t | � }|�y|g d�t j z v S )z3
Return true if the name looks like a URL.
F)�http�https�file�ftp)r r �all_schemes)r �schemes �B/usr/lib/python3/dist-packages/pip/_internal/vcs/versioncontrol.py�is_urlr* 9 s+ � � �D�
!�F�
�~���5����G�G�G� �repo_url�rev�project_name�subdirc �R � |j dd� }| � d|� d|� �}|r|d|� �z
}|S )z�
Return the URL for a VCS requirement.
Args:
repo_url: the remote VCS url, with any needed VCS prefix (e.g. "git+").
project_name: the (unescaped) project name.
�-�_�@z#egg=z&subdirectory=)�replace)r, r- r. r/ �egg_project_name�reqs r) �make_vcs_requirement_urlr7 C sH � � $�+�+�C��5��
�J�a��u�E�"2�!3�
4�C�
����x�(�(���Jr+ �location� repo_rootc �0 � | }t | � sI| }t j j | � } | |k( rt j d|� yt | � s�It j j
|| � ryt j j | |� S )z�
Find the the Python project's root by searching up the filesystem from
`location`. Return the path to project root relative to `repo_root`.
Return None if the project root is `repo_root`, or cannot be found.
zOCould not find a Python project for directory %s (tried all parent directories)N)r �os�path�dirname�logger�warning�samefile�relpath)r8 r9 �
orig_location�
last_locations r) �(find_path_to_project_root_from_repo_rootrD U s� � � �M� ��*� �
��7�7�?�?�8�,���}�$�
�N�N�&��
�
� !��*�
�w�w��� �8�,��
�7�7�?�?�8�Y�/�/r+ c � � e Zd Zy)�RemoteNotFoundErrorN)�__name__�
__module__�__qualname__� r+ r) rF rF r s � �r+ rF c �$ � � e Zd Zdef� fd�Z� xZS )�RemoteNotValidError�urlc �2 �� t �| � |� || _ y �N)�super�__init__rM )�selfrM � __class__s �r) rQ zRemoteNotValidError.__init__w s �� �
�������r+ )rG rH rI �strrQ �
__classcell__�rS s @r) rL rL v s �� ��C� � r+ rL c � � e Zd ZdZ dded dee dee ddfd�Zdefd �Z e
dee fd
�� Zdefd�Zdefd�Z
dedd fd
�Zy)�
RevOptionsz�
Encapsulates a VCS-specific revision to install, along with any VCS
install options.
Instances of this class should be treated as if immutable.
N�vc_class�VersionControlr- �
extra_argsr! c �D � |�g }|| _ || _ || _ d| _ y)z�
Args:
vc_class: a VersionControl subclass.
rev: the name of the revision to install.
extra_args: a list of extra options.
N)r[ r- rY �branch_name)rR rY r- r[ s r) rQ zRevOptions.__init__� s, � � ���J�$������ ��
�*.��r+ c �P � d| j j � d| j �d�S )Nz<RevOptions z: rev=�>)rY r r- �rR s r) �__repr__zRevOptions.__repr__� s&