509318396
Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­Â�Â­
<!DOCTYPE html>
<html>
3
ÝPf�  ã               @   s„   d dl mZ d dlZd dlZd dlZd dlmZmZ d dlm	Z	m
Z
 d dlmZ d dlmZ ejeƒZG dd„ de
ƒZe	jeƒ dS )	é    )Úabsolute_importN)Údisplay_pathÚrmtree)ÚvcsÚVersionControl)Úpath_to_url)Úconfigparserc               @   sd   e Zd ZdZdZdZdZdd	„ Zd
d„ Zdd„ Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )Ú	MercurialÚhgz.hgÚcloneúhg+httpúhg+httpsúhg+sshúhg+static-httpc             C   s>   t jddƒ}| j|ƒ z| jd|gd|d� W dt|ƒ X dS )z?Export the Hg repository at the url to the destination locationz-exportzpip-ÚarchiveF)Úshow_stdoutÚcwdN)ÚtempfileZmkdtempÚunpackÚrun_commandr   )ÚselfÚlocationZtemp_dir© r   ú/usr/lib/python3.6/mercurial.pyÚexport   s    
zMercurial.exportc             C   s¨   t jj|| jdƒ}tjƒ }y<|j|ƒ |jdd|ƒ t|dƒ�}|j	|ƒ W d Q R X W n6 t
tjfk
rŒ } ztjd||ƒ W Y d d }~X nX | jddg| |d� d S )	NZhgrcÚpathsÚdefaultÚwz/Could not switch Mercurial repository to %s: %sÚupdatez-q)r   )ÚosÚpathÚjoinÚdirnamer   ZSafeConfigParserÚreadÚsetÚopenÚwriteÚOSErrorZNoSectionErrorÚloggerZwarningr   )r   ÚdestÚurlÚrev_optionsZrepo_configÚconfigZconfig_fileÚexcr   r   r   Úswitch    s    
zMercurial.switchc             C   s,   | j ddg|d� | j ddg| |d� d S )NZpullz-q)r   r   )r   )r   r)   r+   r   r   r   r   /   s    zMercurial.updatec             C   sz   | j ƒ \}}|r |g}d| }ng }d}| j||||ƒrvtjd||t|ƒƒ | jddd||gƒ | jddg| |d� d S )	Nz (to revision %s)Ú zCloning hg %s%s to %sr   z
--noupdatez-qr   )r   )Zget_url_revZcheck_destinationr(   Úinfor   r   )r   r)   r*   Zrevr+   Zrev_displayr   r   r   Úobtain3   s    

zMercurial.obtainc             C   s2   | j ddgd|d�jƒ }| j|ƒr*t|ƒ}|jƒ S )NZ
showconfigzpaths.defaultF)r   r   )r   ÚstripZ_is_local_repositoryr   )r   r   r*   r   r   r   Úget_urlE   s    
zMercurial.get_urlc             C   s   | j ddgd|d�jƒ }|S )NÚparentsz--template={rev}F)r   r   )r   r2   )r   r   Zcurrent_revisionr   r   r   Úget_revisionM   s    zMercurial.get_revisionc             C   s   | j ddgd|d�jƒ }|S )Nr4   z--template={node}F)r   r   )r   r2   )r   r   Úcurrent_rev_hashr   r   r   Úget_revision_hashS   s    zMercurial.get_revision_hashc             C   sT   | j |ƒ}|jƒ jdƒs d| }|jƒ jddƒd }|s<d S | j|ƒ}d|||f S )Nzhg:zhg+ú-é   r   z%s@%s#egg=%s)r3   ÚlowerÚ
startswithZegg_nameÚsplitr7   )r   Zdistr   ZrepoZegg_project_namer6   r   r   r   Úget_src_requirementY   s    

zMercurial.get_src_requirementc             C   s   dS )z&Always assume the versions don't matchFr   )r   r)   r+   r   r   r   Úcheck_versionc   s    zMercurial.check_versionN)r
   r   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Únamer"   Z	repo_nameZschemesr   r.   r   r1   r3   r5   r7   r=   r>   r   r   r   r   r	      s   

r	   )Z
__future__r   Zloggingr   r   Z	pip.utilsr   r   Zpip.vcsr   r   Zpip.downloadr   Zpip._vendor.six.movesr   Z	getLoggerr?   r(   r	   Úregisterr   r   r   r   Ú<module>   s   
W