Your IP : 18.224.44.207


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__/mercurial.cpython-34.pyc

�
�Re��@s�ddlZddlZddlZddlZddlmZddlmZmZddlm	Z	ddl
mZmZddl
mZddlmZGdd	�d	e�Zeje�dS)
�N)�call_subprocess)�display_path�rmtree)�logger)�vcs�VersionControl)�path_to_url)�ConfigParserc@s�eZdZdZdZdZd!ZdZd	Zd
d�Z	dd
�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd S)"�	Mercurial�hgz.hg�clone�hg+http�hg+https�hg+ssh�hg+static-httpzhg-clone.txtzg# This was a Mercurial repo; to make it a repo again run:
hg init
hg pull %(url)s
hg update -r %(rev)s
cCs�d}}x�|j�D]�}|j�s|j�jd�rEqntjd|�}|ru|jd�j�}ntjd|�}|r�|jd�j�}n|r|r||fSqWdS)N�#zhg\s*pull\s*(.*)\s*�z^hg\s*update\s*-r\s*(.*)\s*)NN)�
splitlines�strip�
startswith�re�search�group)�self�content�url�rev�line�	url_match�	rev_match�r �,/tmp/pip-ztkk0jow-build/pip/vcs/mercurial.py�parse_vcs_bundle_files
"zMercurial.parse_vcs_bundle_filecCs`tjdd�}|j|�z/t|jd|gd|jddd|�Wdt|�XdS)	z?Export the Hg repository at the url to the destination locationz-exportzpip-�archive�
filter_stdout�show_stdoutF�cwdN)�tempfile�mkdtemp�unpackr�cmd�_filterr)r�location�temp_dirr r r!�export%s
zMercurial.exportcCs�tjj||jd�}tj�}yJ|j|�|jdd|�t|d�}|j	|�|j
�WnBttjfk
r�t
j�d}tjd||f�Yn!Xt|jddg|d	|�dS)
N�hgrc�paths�default�wrz/Could not switch Mercurial repository to %s: %s�updatez-qr&)�os�path�join�dirnamer	�SafeConfigParser�read�set�open�write�close�OSError�NoSectionError�sys�exc_infor�warnrr*)r�destr�rev_options�repo_config�config�config_file�er r r!�switch0s

zMercurial.switchcCs@t|jddgd|�t|jddg|d|�dS)N�pullz-qr&r3)rr*)rrCrDr r r!r3AszMercurial.updatecCs�|j�\}}|r.|g}d|}ng}d}|j||||�r�tjd||t|�f�t|jddd||g�t|jddg|d|�ndS)	Nz (to revision %s)�zCloning hg %s%s to %srz
--noupdatez-qr3r&)�get_url_rev�check_destinationr�notifyrrr*)rrCrrrD�rev_displayr r r!�obtainFs	
	zMercurial.obtaincCsRt|jddgddd|�j�}|j|�rHt|�}n|j�S)N�
showconfigz
paths.defaultr%Fr&)rr*r�_is_local_repositoryr)rr,rr r r!�get_urlTszMercurial.get_urlcCs�t|jdgddd|�}g}x{|j�D]m}tjd|�}|r4|jd�}|jd�}d|kr�|j|j�|j�f�q�q4q4Wt|�S)	N�tagsr%Fr&z([\w\d\.-]+)\s*([\d]+):.*$r��tip)	rr*rrrr�appendr�dict)rr,rT�tag_revsr�
tags_match�tagrr r r!�get_tag_revs\s)zMercurial.get_tag_revscCs�t|jdgddd|�}g}x{|j�D]m}tjd|�}|r4|jd�}|jd�}d|kr�|j|j�|j�f�q�q4q4Wt|�S)	N�branchesr%Fr&z([\w\d\.-]+)\s*([\d]+):.*$rrUr1)	rr*rrrrrWrrX)rr,r]�branch_revsr�branches_match�branchrr r r!�get_branch_revsis)zMercurial.get_branch_revscCs.t|jddgddd|�j�}|S)N�parentsz--template={rev}r%Fr&)rr*r)rr,�current_revisionr r r!�get_revisionvszMercurial.get_revisioncCs.t|jddgddd|�j�}|S)Nrbz--template={node}r%Fr&)rr*r)rr,�current_rev_hashr r r!�get_revision_hash|szMercurial.get_revision_hashcCs�|j|�}|j�jd�s1d|}n|j�jdd�d}|sWdS|j|�}|j|�}|j|�}|j|�}	||kr�d|||f}
n-||	kr�d||	|f}
n
d|}
d|||
fS)	Nzhg:zhg+�-rrz%s-%sz%s-devz%s@%s#egg=%s)	rS�lowerr�egg_name�splitrdrfr\ra)r�distr,�	find_tags�repo�egg_project_name�current_revrerYr^�
full_egg_namer r r!�get_src_requirement�s 

zMercurial.get_src_requirementN)zhgr
rrr)�__name__�
__module__�__qualname__�namer7�	repo_name�schemes�bundle_file�guider"r.rIr3rPrSr\rardrfrqr r r r!r

s"

r
)r4r'rr@�pip.utilrrr�pip.logr�pip.vcsrr�pip.downloadrZpip.backwardcompatr	r
�registerr r r r!�<module>s�

?>