HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/pip/_internal/vcs/__pycache__/mercurial.cpython-310.pyc
o

@%Nev�@s�ddlZddlZddlZddlmZmZmZddlmZm	Z	ddl
mZmZddl
mZddlmZddlmZmZmZmZe�e�ZGdd	�d	e�Ze�e�dS)
�N)�List�Optional�Tuple)�
BadCommand�InstallationError)�
HiddenText�display_path)�make_command)�path_to_url)�
RevOptions�VersionControl�(find_path_to_project_root_from_repo_root�vcsc
s$eZdZdZdZdZdZedede	efdd��Z
d	ed
edede
dd
f
dd�Zd	ed
ededd
fdd�Zd	ed
ededd
fdd�Zededefdd��Zededefdd��Zededefdd��Zed	edeedefdd��Zededeefdd��Zededeef�fd d!��Z�ZS)"�	Mercurial�hgz.hg�clone)zhg+filezhg+httpzhg+httpszhg+sshzhg+static-http�rev�returncCs|gS)N�)rrr�=/usr/lib/python3/dist-packages/pip/_internal/vcs/mercurial.py�get_base_rev_args szMercurial.get_base_rev_args�dest�url�rev_options�	verbosityNcCs�|��}t�d||t|��|dkrd}n|dkrd}n	|dkr#d}nd}|�td	d
g|�|�|�R��|jtdg|�|���R�|d�dS)
NzCloning hg %s%s to %sr)z--quiet�r�)�	--verbose)rz--debugrz
--noupdate�update��cwd)�
to_display�logger�infor�run_commandr	�to_args)�selfrrrr�rev_display�flagsrrr�	fetch_new$s&� 
�zMercurial.fetch_newc	
Cs�tj�||jd�}t��}z)|�|�|�dd|j�t	|d��
}|�
|�Wd�n1s0wYWnttjfyS}zt
�d||�WYd}~dSd}~wwtdd|���}|j||d�dS)	N�hgrc�paths�default�wz/Could not switch Mercurial repository to %s: %sr�-qr)�os�path�join�dirname�configparser�RawConfigParser�read�set�secret�open�write�OSError�NoSectionErrorr"�warningr	r%r$)	r&rrr�repo_config�config�config_file�exc�cmd_argsrrr�switch<s
����zMercurial.switchcCs4|jddg|d�tdd|���}|j||d�dS)N�pullr.rr)r$r	r%)r&rrrrArrrrJszMercurial.update�locationcCs4|jddgdd|d���}|�|�rt|�}|��S)N�
showconfigz
paths.defaultFT��show_stdout�stdout_onlyr )r$�strip�_is_local_repositoryr
)�clsrDrrrr�get_remote_urlOs��
zMercurial.get_remote_urlcC�|jddgdd|d���}|S)zW
        Return the repository-local changeset revision number, as an integer.
        �parentsz--template={rev}FTrF�r$rI)rKrD�current_revisionrrr�get_revision[s��zMercurial.get_revisioncCrM)zh
        Return the changeset identification hash, as a 40-character
        hexadecimal string
        rNz--template={node}FTrFrO)rKrD�current_rev_hashrrr�get_requirement_revisionhs��z"Mercurial.get_requirement_revision�namecCsdS)z&Always assume the versions don't matchFr)rKrrTrrr�is_commit_id_equalvszMercurial.is_commit_id_equalcCsD|jdgdd|d���}tj�|�stj�tj�||��}t||�S)z�
        Return the path to Python project root, relative to the repo root.
        Return None if the project root is in the repo root.
        �rootFTrF)r$rIr/r0�isabs�abspathr1r
)rKrD�	repo_rootrrr�get_subdirectory{s
��
zMercurial.get_subdirectorycsvt��|�}|r
|Sz|jdg|ddddd�}Wnty(t�d|�YdSty1YdSwtj�	|�
d��S)NrVFT�raise)r rGrH�
on_returncode�log_failed_cmdzIcould not determine if %s is under hg control because hg is not availablez
)�super�get_repository_rootr$rr"�debugrr/r0�normpath�rstrip)rKrD�loc�r��	__class__rrr_�s,
���zMercurial.get_repository_root)�__name__�
__module__�__qualname__rTr2�	repo_name�schemes�staticmethod�strrrrr�intr)rBr�classmethodrLrQrSr�boolrUrZr_�
__classcell__rrrerrs@����
�

$r)r3�loggingr/�typingrrr�pip._internal.exceptionsrr�pip._internal.utils.miscrr�pip._internal.utils.subprocessr	�pip._internal.utils.urlsr
� pip._internal.vcs.versioncontrolrrr
r�	getLoggerrgr"r�registerrrrr�<module>s