AlkantarClanX12

Your IP : 3.145.75.238


Current Path : /opt/alt/python34/lib/python3.4/site-packages/pip/vcs/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib/python3.4/site-packages/pip/vcs/__pycache__/git.cpython-34.pyc

�
�Re��@s�ddlZddlZddlZddlmZddlmZmZddlm	Z	m
Z
ddlmZddl
mZmZejZejZGdd�de
�Ze	je�dS)	�N)�call_subprocess)�display_path�rmtree)�vcs�VersionControl)�logger)�url2pathname�urlparsecs�eZdZdZdZdZd&Zd	Zd
Zd�fdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Z�fd"d#�Zd$d%�Z�S)'�Git�gitz.git�clone�git+http�	git+https�git+ssh�git+git�git+filez
git-clone.txtzs# This was a Git repo; to make it a repo again run:
git init
git remote add origin %(url)s -f
git checkout %(rev)s
Ncs�|r�t|�\}}}}}|jd�r�|dt|jd���}	|	t|�jdd�jd�}
t|||
||f�}|jd�d}|d|�t||d�||
||f�}q�ntt	|�j
|||�dS)N�file�/�\�+�)�urlsplit�endswith�len�lstripr�replace�
urlunsplit�find�superr
�__init__)�self�url�args�kwargs�scheme�netloc�path�query�fragment�initial_slashes�newpath�
after_plus)�	__class__��&/tmp/pip-ztkk0jow-build/pip/vcs/git.pyrs %9zGit.__init__cCs�d}}x�|j�D]�}|j�s|j�jd�rEqntjd|�}|ru|jd�j�}ntjd|�}|r�|jd�j�}n|r|r||fSqWdS)N�#z$git\s*remote\s*add\s*origin(.*)\s*-frz^git\s*checkout\s*-q\s*(.*)\s*)NN)�
splitlines�strip�
startswith�re�search�group)r �contentr!�rev�line�	url_match�	rev_matchr-r-r.�parse_vcs_bundle_file%s
"zGit.parse_vcs_bundle_filecCs�tjdd�}|j|�zT|jd�s>|d}nt|jdddd|gd|jd	d
d|�Wdt|�XdS)
z@Export the Git repository at the url to the destination locationz-exportzpip-rzcheckout-indexz-az-fz--prefix�
filter_stdout�show_stdoutF�cwdN)�tempfile�mkdtemp�unpackrr�cmd�_filterr)r �location�temp_dirr-r-r.�export4s

z
Git.exportcCs`|j|�}d|}||kr0||gS||krG||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_refsr�warn)r r7�dest�rev_options�	revisions�
origin_revr-r-r.�check_rev_optionsAs
zGit.check_rev_optionscCsPt|jdd|gd|�t|jddg|d|�|j|�dS)N�configzremote.origin.urlr>�checkoutz-q)rrB�update_submodules)r rIr!rJr-r-r.�switchSs
z
Git.switchcCsrt|jddgd|�|r>|j|d||�}nt|jdddg|d|�|j|�dS)N�fetchz-qr>r�resetz--hard)rrBrMrP)r rIrJr-r-r.�update[s
#z
Git.updatecCs|j�\}}|r.|g}d|}ndg}d}|j||||�r�tjd||t|�f�t|jdd||g�|j|�|r�|j|||�}|j	|�j
|d�s�t|jddg|d	|�q�q�ndS)
Nz (to %s)z
origin/master�zCloning %s%s to %srz-qrrOr>)�get_url_rev�check_destinationr�notifyrrrBrPrM�get_revisionr2)r rIr!r7rJ�rev_displayr-r-r.�obtaines	
	 
z
Git.obtaincCs.t|jddgddd|�}|j�S)NrNzremote.origin.urlr=Fr>)rrBr1)r rDr!r-r-r.�get_urlxszGit.get_urlcCs.t|jddgddd|�}|j�S)Nz	rev-parse�HEADr=Fr>)rrBr1)r rD�current_revr-r-r.rY~s!zGit.get_revisioncCs	t|jdgddd|�}i}x�|j�j�D]�}|jdd�\}}|j�}d}|jd�r�|td�d�}nP|jd	�r�|td	�d�}n(|jd
�r�|td
�d�}n|dk	r:|j�||<q:q:W|S)z=Return map of named refs (branches or tags) to commit hashes.zshow-refr=Fr>� rNz
refs/remotes/zrefs/heads/z
refs/tags/)rrBr1r0�splitr2r)r rD�output�rvr8�commit�ref�ref_namer-r-r.rG�s zGit.get_refsc
Cs�|j|�}|j�jd�s1d|}n|j�jdd�d}|sWdS|j|�}|j|�}tdd�|j�D��}||kr�d|||f}	n
d	|}	d
|||	fS)Nzgit:zgit+�-rrcss!|]\}}||fVqdS)Nr-)�.0rdrcr-r-r.�	<genexpr>�sz*Git.get_src_requirement.<locals>.<genexpr>z%s-%sz%s-devz%s@%s#egg=%s)	r\�lowerr2�egg_namer`rYrG�dict�items)
r �distrD�	find_tags�repo�egg_project_namer^�refs�names_by_commit�
full_egg_namer-r-r.�get_src_requirement�s

zGit.get_src_requirementcs�d|jkrld|jks$t�|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://rU)r!�AssertionErrorrrr
rV)r r!r7)r,r-r.rV�szGit.get_url_revcCsNtjjtjj|d��s%dSt|jdddddgd|�dS)Nz.gitmodules�	submodulerTz--initz--recursivez-qr>)�osr&�exists�joinrrB)r rDr-r-r.rP�s!zGit.update_submodules)zgitr
rrrr)�__name__�
__module__�__qualname__�name�dirname�	repo_name�schemes�bundle_file�guiderr;rFrMrQrTr[r\rYrGrtrVrPr-r-)r,r.r

s&

r
)r?r3�os.pathrw�pip.utilrrr�pip.vcsrr�pip.logrZpip.backwardcompatrr	rrr
�registerr-r-r-r.�<module>s		�