관리-도구
편집 파일: versioncontrol.cpython-36.pyc
3 �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 Z6dgZ7ej8e9�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-python36-pip-20.2.4-5.el8.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/vcs/versioncontrol.py�is_url8 s r. c C s. t j|�}dj| ||�}|r*|dj|�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 sf |dkrg }t j}tjj� }|r*|j|� d}t| �}y.tjt | �tj tj |d�} | jrb| jj� W n6 t k r� } z|r�t jd| |� � W Y dd} ~ X nX g }x@d}| jr�t| jj� �}|s�P |j� }|j|d � ||� q�W z| j� W d| j�r| jj� X | j�o| j|k} | �r\| �rF|�rFt| ||| jd�}t j|� dj| j|�}t|��dj|�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 jjt jj| d��sF| }t jj| �} | |krtjd|� dS qW t|| �rVdS t jj| |�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 dj | 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"|| jj|�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 dj| 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 jj| j� tt dd �r(t jj| j� tt| �j� 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 j� S )N)� _registry�__iter__)rv r, r, r- r� ! s zVcsSupport.__iter__c C s t | jj� �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|j� qW |S )N)r� r� r� )rv r� r� r, r, r- r) / s zVcsSupport.all_schemesc C sH t |d�stjd|j� d S |j| jkrD|� | j|j<