Sindbad~EG File Manager

Current Path : /home/infinitibizsol/mypythonenv/lib/python3.6/site-packages/pip/vcs/__pycache__/
Upload File :
Current File : /home/infinitibizsol/mypythonenv/lib/python3.6/site-packages/pip/vcs/__pycache__/git.cpython-36.pyc

3

�Üg,-�@s�ddlmZddlZddlZddlZddlmZddlm	Z	ddl
mZddl
m
ZddlmZddlmZmZddlmZmZejZejZeje�ZGd	d
�d
e�Zeje�dS)�)�absolute_importN)�samefile)�
BadCommand)�parse)�request)�display_path�rmtree)�vcs�VersionControlcs�eZdZdZdZdZd7Zd8�fd
d�	Zdd
�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zd9dd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd:d+d,�Zd-d.�Zd/d0�Z�fd1d2�Zd3d4�Ze�fd5d6��Z�ZS);�Git�gitz.git�clone�git+http�	git+https�git+ssh�git+git�git+fileNcs�|r�t|�\}}}}}|jd�r�|dt|jd���}	|	tj|�jdd�jd�}
t|||
||f�}|jd�d}|d|�t||d�||
||f�}t	t
|�j|f|�|�dS)N�file�/�\�+�)�urlsplit�endswith�len�lstrip�urllib_request�url2pathname�replace�
urlunsplit�find�superr�__init__)�self�url�args�kwargs�scheme�netloc�path�query�fragment�initial_slashes�newpath�
after_plus)�	__class__��*/tmp/pip-build-chubckx0/pip/pip/vcs/git.pyr" s

zGit.__init__cCsTd}|jdgdd�}|j|�r0|t|�d�}nd}dj|jd�dd��}t|�S)Nzgit version �versionF)�show_stdout��.�)�run_command�
startswithr�join�split�
parse_version)r#�VERSION_PFXr2r0r0r1�get_git_version5s
zGit.get_git_versioncCsVtjdd�}|j|�z0|jd�s*|d}|jdddd|gd|d	�Wd
t|�Xd
S)z@Export the Git repository at the url to the destination locationz-exportzpip-rzcheckout-indexz-az-fz--prefixF)r3�cwdN)�tempfile�mkdtemp�unpackrr7r)r#�location�temp_dirr0r0r1�exportBs

z
Git.exportcCsL|j||�}d|}||kr&||gS||kr8||gStjd|�|SdS)z�Check the revision options before checkout to compensate that tags
        and branches may need origin/ as a prefix.
        Returns the SHA1 of the branch or tag if found.
        z	origin/%sz5Could not find a tag or branch '%s', assuming commit.N)�get_short_refs�logger�warning)r#�rev�dest�rev_options�	revisions�
origin_revr0r0r1�check_rev_optionsOs

zGit.check_rev_optionscCs|j|�j|d�S)a

        Compare the current sha to the ref. ref may be a branch or tag name,
        but current rev will always point to a sha. This means that a branch
        or tag will never compare as True. So this ultimately only matches
        against exact shas.
        r)�get_revisionr8)r#rIrJr0r0r1�
check_versioncszGit.check_versioncCs8|jdd|g|d�|jddg||d�|j|�dS)N�configzremote.origin.url)r>�checkoutz-q)r7�update_submodules)r#rIr$rJr0r0r1�switchlsz
Git.switchcCst|j�td�kr&|jdddg|d�n|jddg|d�|rN|j|d||�}|jdddg||d�|j|�dS)	Nz1.9.0�fetchz-qz--tags)r>r�resetz--hard)r=r;r7rMrR)r#rIrJr0r0r1�updatersz
Git.updatecCs�|j�\}}|r |g}d|}n
dg}d}|j||||�r�tjd||t|��|jdd||g�|r�|j|||�}|j||�s�|jddg||d�|j|�dS)	Nz (to %s)z
origin/masterr4zCloning %s%s to %sr
z-qrQ)r>)	�get_url_rev�check_destinationrF�inforr7rMrOrR)r#rIr$rHrJ�rev_displayr0r0r1�obtain�s"

z
Git.obtaincCsZ|jdddgd|d�}|j�}|d}x|D]}|jd�r,|}Pq,W|jd�d	}|j�S)
z+Return URL of the first remote encountered.rPz--get-regexpzremote\..*\.urlF)r3r>rzremote.origin.url � r)r7�
splitlinesr8r:�strip)r#rB�remotes�found_remote�remoter$r0r0r1�get_url�s


zGit.get_urlcCs|jddgd|d�}|j�S)Nz	rev-parse�HEADF)r3r>)r7r^)r#rB�current_revr0r0r1rN�szGit.get_revisionr4ccs�|jd|gd|d�}xl|jd�D]^}|jd�}|s4q y|jdd�\}}Wn"tk
rjtd|����YnX|j�|j�fVq Wd	S)
z4Yields tuples of (commit, ref) for branches and tagszshow-refF)r3r>�
�
r\rzunexpected show-ref line: N)r7r:�rstrip�
ValueErrorr^)r#rB�pattern�output�line�commit�refr0r0r1�
get_full_refs�s


zGit.get_full_refscCs
|jd�S)Nz
refs/remotes/)r8)r#rmr0r0r1�
is_ref_remote�szGit.is_ref_remotecCs
|jd�S)Nzrefs/heads/)r8)r#rmr0r0r1�
is_ref_branch�szGit.is_ref_branchcCs
|jd�S)Nz
refs/tags/)r8)r#rmr0r0r1�
is_ref_tag�szGit.is_ref_tagcCs"t|j|�|j|�|j|�f�S)z0A ref is a commit sha if it is not anything else)�anyrorprq)r#rmr0r0r1�
is_ref_commit�szGit.is_ref_commitcCs
|j|�S)N)rE)r#rBr0r0r1�get_refs�szGit.get_refscCs�i}x~|j||�D]n\}}d}|j|�r:|td�d�}n6|j|�rV|td�d�}n|j|�rp|td�d�}|dk	r|||<qW|S)z=Return map of named refs (branches or tags) to commit hashes.Nz
refs/remotes/zrefs/heads/z
refs/tags/)rnrorrprq)r#rBri�rvrlrm�ref_namer0r0r1rE�s


zGit.get_short_refscCs�|jddgd|d�j�}tjj|�s2tjj||�}tjj|d�}|}xBtjjtjj|d��s�|}tjj|�}||krFtj	d|�dSqFWt
||�r�dStjj||�S)	z:Return the relative path of setup.py to the git repo root.z	rev-parsez	--git-dirF)r3r>z..zsetup.pyzGCould not find setup.py for directory %s (tried all parent directories)N)r7r^�osr)�isabsr9�exists�dirnamerFrGr�relpath)r#rB�git_dir�root_dir�
orig_location�
last_locationr0r0r1�_get_subdirectory�s"

zGit._get_subdirectorycCsr|j|�}|j�jd�s d|}|j�jdd�d}|s<dS|j|�}d|||f}|j|�}|rn|d|7}|S)Nzgit:zgit+�-rrz%s@%s#egg=%sz&subdirectory=)rb�lowerr8�egg_namer:rNr�)r#�distrB�repo�egg_project_namerd�req�subdirectoryr0r0r1�get_src_requirement�s


zGit.get_src_requirementcsbd|jkrHd|jkst�|jjdd�|_tt|�j�\}}|jdd�}ntt|�j�\}}||fS)a;
        Prefixes stub URLs like 'user@hostname:user/repo.git' with 'ssh://'.
        That's required because although they use SSH they sometimes doesn't
        work with a ssh:// scheme (e.g. Github). But we need a scheme for
        parsing. Hence we remove it again afterwards and return it as a stub.
        z://zfile:zgit+z
git+ssh://zssh://r4)r$�AssertionErrorrr!rrW)r#r$rH)r/r0r1rWs
zGit.get_url_revcCs6tjjtjj|d��sdS|jdddddg|d�dS)Nz.gitmodules�	submodulerVz--initz--recursivez-q)r>)rwr)ryr9r7)r#rBr0r0r1rRs
zGit.update_submodulescsVtt|�j|�rdSy|�jdg|ddd�}|Stk
rPtjd|�dSXdS)NTz	rev-parseF�ignore)r>r3�
on_returncodezKcould not determine if %s is under git control because git is not available)r!r�controls_locationr7rrF�debug)�clsrB�r)r/r0r1r�$s
zGit.controls_location)rrrrrr)N)r4)r4)�__name__�
__module__�__qualname__�namerz�	repo_name�schemesr"r=rDrMrOrSrVr[rbrNrnrorprqrsrtrEr�r�rWrR�classmethodr��
__classcell__r0r0)r/r1rs4

	
	
r)�
__future__r�loggingr?�os.pathrw�
pip.compatr�pip.exceptionsrZpip._vendor.six.moves.urllibr�urllib_parserrZpip._vendor.packaging.versionr;�	pip.utilsrr�pip.vcsr	r
rr�	getLoggerr�rFr�registerr0r0r0r1�<module>s"


Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists