관리-도구
편집 파일: versioncontrol.cpython-37.pyc
B ��Rene � @ s� d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl m Z ddlmZ ddlmZmZmZ ddlmZmZ ddlmZ dd lmZmZmZmZmZmZ dd lmZm Z m!Z!m"Z" ddl#m$Z$ ddl%m&Z& e$�r>dd l'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2 ddlm3Z3 ddlm4Z4 e.e,e5 e,e5 f Z6dgZ7e�8e9�Z:dd� Z;d"dd�Z<d#dd�Z=dd� Z>G dd� de?�Z@G dd� deA�ZBG dd� deA�ZCeC� ZDG d d!� d!eA�ZEdS )$z)Handles all VCS (version control) support� )�absolute_importN)� pkg_resources)�parse)� BadCommand�InstallationError�SubProcessError)�console_to_str�samefile)�subprocess_logger)�ask_path_exists� backup_dir�display_path�hide_url� hide_value�rmtree)�format_command_args�make_command�make_subprocess_output_error�reveal_command_args)�MYPY_CHECK_RUNNING)�get_url_scheme)�Dict�Iterable�Iterator�List�Optional�Text�Tuple�Type�Union�Mapping�Any)� HiddenText)�CommandArgs�vcsc C s* t | �}|dkrdS |ddddgtj kS )z3 Return true if the name looks like a URL. NF�http�https�file�ftp)r r$ �all_schemes)�name�scheme� r, ��/builddir/build/BUILDROOT/alt-python37-pip-20.2.4-6.el8.x86_64/opt/alt/python37/lib/python3.7/site-packages/pip/_internal/vcs/versioncontrol.py�is_url8 s r. c C s. t �|�}d�| ||�}|r*|d�|�7 }|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={})r �to_filename�format)�repo_url�rev�project_name�subdir�egg_project_name�reqr, r, r- �make_vcs_requirement_urlC s r7 Tc C sd |dkrg }t j}tj�� }|r*|�|� d}t| �}y.tjt | �tj tj |d�} | jrb| j�� W n6 t k r� } z|r�t �d| |� � W dd} ~ X Y nX g }x@d}| jr�t| j�� �}|s�P |�� }|�|d � ||� q�W z| �� W d| j�r| j�� X | j�o| j|k} | �rZ|�sD|�rDt| ||| jd�}t �|� d�| j|�}t|��d�|�S ) z� Args: extra_ok_returncodes: an iterable of integer return codes that are acceptable, in addition to 0. Defaults to None, which means []. log_failed_cmd: if false, failed commands are not logged, only raised. NT)�stdout�stderr�cwdz#Error %s while executing command %s� )�cmd_argsr: �lines�exit_statuszSCommand errored out with exit status {}: {} Check the logs for full command output.� )r �debug�os�environ�copy�updater � subprocess�Popenr �PIPE�stdin�close� Exception�criticalr8 r �readline�rstrip�append�wait� returncoder �errorr0 r �join)�cmdr: � extra_environ�extra_ok_returncodes�log_failed_cmd�log_subprocess�env�showing_subprocess�command_desc�proc�exc� all_output�line�proc_had_error�msg�exc_msgr, r, r- �call_subprocessT s` rb c C sd | }xBt j�t j�| d��sF| }t j�| �} | |krt�d|� dS qW t|| �rVdS t j�| |�S )z� Find the path to `setup.py` by searching up the filesystem from `location`. Return the path to `setup.py` relative to `repo_root`. Return None if `setup.py` is in `repo_root` or cannot be found. zsetup.pyzGCould not find setup.py for directory %s (tried all parent directories)N) rA �path�existsrR �dirname�logger�warningr �relpath)�location� repo_root� orig_location� last_locationr, r, r- �!find_path_to_setup_from_repo_root� s rm c @ s e Zd ZdS )�RemoteNotFoundErrorN)�__name__� __module__�__qualname__r, r, r, r- rn � s rn c @ sF e Zd ZdZddd�Zdd� Zedd� �Zd d � Zdd� Z d d� Z dS )� RevOptionsz� Encapsulates a VCS-specific revision to install, along with any VCS install options. Instances of this class should be treated as if immutable. Nc C s( |dkrg }|| _ || _|| _d| _dS )z� Args: vc_class: a VersionControl subclass. rev: the name of the revision to install. extra_args: a list of extra options. N)� extra_argsr2 �vc_class�branch_name)�selfrt r2 rs r, r, r- �__init__� s zRevOptions.__init__c C s d� | jj| j�S )Nz<RevOptions {}: rev={!r}>)r0 rt r* r2 )rv r, r, r- �__repr__� s zRevOptions.__repr__c C s | j d kr| jjS | j S )N)r2 rt �default_arg_rev)rv r, r, r- �arg_rev� s zRevOptions.arg_revc C s0 g }| j }|dk r"|| j�|�7 }|| j7 }|S )z< Return the VCS-specific command arguments. N)rz rt �get_base_rev_argsrs )rv �argsr2 r, r, r- �to_args� s zRevOptions.to_argsc C s | j s dS d�| j �S )Nr? z (to revision {}))r2 r0 )rv r, r, r- � to_display s zRevOptions.to_displayc C s | j j|| jd�S )z� Make a copy of the current instance, but with a new rev. Args: rev: the name of the revision for the new object. )rs )rt �make_rev_optionsrs )rv r2 r, r, r- �make_new s zRevOptions.make_new)NN)ro rp rq �__doc__rw rx �propertyrz r} r~ r� r, r, r, r- rr � s rr c s� e Zd Zi ZddddddgZ� fdd�Zd d � Zedd� �Zed d� �Z edd� �Z dd� Zdd� Zdd� Z dd� Zdd� Z� ZS )� VcsSupport�ssh�git�hg�bzr�sftp�svnc s: t j�| j� tt dd �r(t j�| j� tt| ��� d S )N� uses_fragment) �urllib_parse�uses_netloc�extend�schemes�getattrr� �superr� rw )rv )� __class__r, r- rw s zVcsSupport.__init__c C s | j �� S )N)� _registry�__iter__)rv r, r, r- r� ! s zVcsSupport.__iter__c C s t | j�� �S )N)�listr� �values)rv r, r, r- �backends% s zVcsSupport.backendsc C s dd� | j D �S )Nc S s g | ] }|j �qS r, )re )�.0�backendr, r, r- � <listcomp>- s z'VcsSupport.dirnames.<locals>.<listcomp>)r� )rv r, r, r- �dirnames* s zVcsSupport.dirnamesc C s$ g }x| j D ]}|�|j� qW |S )N)r� r� r� )rv r� r� r, r, r- r) / s zVcsSupport.all_schemesc C sH t |d�st�d|j� d S |j| jkrD|� | j|j<