U ��.e��@s�ddlmZddlZddlZddlmZddlmZmZddl m Z ddl m Z ddl mZddlmZdd lmZdd lmZmZmZer�dd l mZdd lmZe�e�ZGd d�de�Ze�e�dS)�)�absolute_importN)� configparser)� BadCommand�InstallationError)� display_path)� make_command)� TempDirectory)�MYPY_CHECK_RUNNING)� path_to_url)�VersionControl�!find_path_to_setup_from_repo_root�vcs)� HiddenText)� RevOptionscs�eZdZdZdZdZdZedd��Zdd�Z d d �Z d d �Z d d�Z e dd��Ze dd��Ze dd��Ze dd��Ze dd��Ze �fdd��Z�ZS)� Mercurial�hgz.hg�clone)rzhg+filezhg+httpzhg+httpszhg+sshzhg+static-httpcCs|gS)N�)Zrevrr�?/usr/lib/python3.8/site-packages/pip/_internal/vcs/mercurial.py�get_base_rev_args'szMercurial.get_base_rev_argsc Cs@tdd��,}|j|j|d�|jd|gd|jd�W5QRXdS)z?Export the Hg repository at the url to the destination location�export)Zkind)�url�archiveF�� show_stdout�cwdN)r�unpack�path� run_command)�self�locationrZtemp_dirrrrr+s �zMercurial.exportcCsP|��}t�d||t|��|�tddd||��|jtdd|���|d�dS)NzCloning hg %s%s to %srz --noupdate�-q�update�r)Z to_display�logger�inforrr�to_args)r�destr� rev_optionsZ rev_displayrrr� fetch_new5s��zMercurial.fetch_newc Cs�tj�||jd�}t��}z>|�|�|�dd|j�t |d��}|� |�W5QRXWn6t tj fk r�}zt �d||�W5d}~XYn Xtdd|���}|j||d�dS) NZhgrc�paths�default�wz/Could not switch Mercurial repository to %s: %sr"r!r#)�osr�join�dirnamerZRawConfigParser�read�setZsecret�open�write�OSErrorZNoSectionErrorr$Zwarningrr&r) rr'rr(Z repo_configZconfigZ config_file�exc�cmd_argsrrr�switchDs  �zMercurial.switchcCs4|jddg|d�tdd|���}|j||d�dS)NZpullr!r#r")rrr&)rr'rr(r6rrrr"UszMercurial.updatecCs2|jddgd|d���}|�|�r*t|�}|��S)NZ showconfigz paths.defaultFr)r�stripZ_is_local_repositoryr )�clsr rrrr�get_remote_url[s�  zMercurial.get_remote_urlcCs|jddgd|d���}|S)zW Return the repository-local changeset revision number, as an integer. �parentsz--template={rev}Fr�rr8)r9r Zcurrent_revisionrrr� get_revisionds � zMercurial.get_revisioncCs|jddgd|d���}|S)zh Return the changeset identification hash, as a 40-character hexadecimal string r;z--template={node}Frr<)r9r Zcurrent_rev_hashrrr�get_requirement_revisionns � z"Mercurial.get_requirement_revisioncCsdS)z&Always assume the versions don't matchFr)r9r'�namerrr�is_commit_id_equalyszMercurial.is_commit_id_equalcCsB|jdgd|d���}tj�|�s8tj�tj�||��}t||�S)z~ Return the path to setup.py, relative to the repo root. Return None if setup.py is in the repo root. �rootFr)rr8r-r�isabs�abspathr.r )r9r Z repo_rootrrr�get_subdirectory~s�  zMercurial.get_subdirectoryc sPtt|��|�rdSz|jdg|dddd�WdSttfk rJYdSXdS)NTZidentifyF�raise)rrZ on_returncodeZlog_failed_cmd)�superr�controls_locationrrr)r9r �� __class__rrrG�s�zMercurial.controls_location)�__name__� __module__� __qualname__r?r/Z repo_nameZschemes� staticmethodrrr)r7r"� classmethodr:r=r>r@rDrG� __classcell__rrrHrrs,       r)Z __future__rZloggingr-Zpip._vendor.six.movesrZpip._internal.exceptionsrrZpip._internal.utils.miscrZpip._internal.utils.subprocessrZpip._internal.utils.temp_dirrZpip._internal.utils.typingr Zpip._internal.utils.urlsr Z pip._internal.vcs.versioncontrolr r r rrZ getLoggerrJr$r�registerrrrr�s          |