£Á°èZ¨Ä…–K§‚«“ô4“ÒÙ´dîfUÙÃÅ WKbyÊ¦•êŽ…È®FÒ¿ÊÎóCozá¬S@6{Í:›œêZÌ:Š•_%:¢¾¾~;‘Ã~èŠ©ÊÇí`ÔÑ©úë™µ'5I¿fš×WO%ø9¾«¾DK|€ùÍD”Ýs]nHÕ¶ê×Ó¼ãžªéUWŸÈË%DÒÕ¬ï‘]/Åcx  ‰ï2ß]ä6G[]S£ÔÏ¯rs{úëóµmÒï#UQxo·õÞCe]"±/aÙ&Eã4ú9Jé_ÞåëdãöKë)AÞ                  ¯¹ægƒÛowÐø^d™ý½ßB7áyMä9ÜÖUã
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
<html>

Re                 @   s   d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l m Z d  d l m Z m Z d  d l m	 Z	 d  d l
 m Z m Z d  d l m Z d  d l m Z Gd d	   d	 e  Z e j e  d S)
    N)call_subprocess)display_pathrmtree)logger)vcsVersionControl)path_to_url)ConfigParserc               @   s   e  Z d  Z d 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 d   Z d d   Z d  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
c             C   s   d  } } x | j    D] } | j   s | j   j d  rE q n  t j d |  } | ru | j d  j   } n  t j d |  } | r | j d  j   } n  | r | r | | f Sq Wd S)N#zhg\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_file   s    
"zMercurial.parse_vcs_bundle_filec             C   s`   t  j d d  } |  j |  z/ t |  j d | g d |  j d d d | Wd t |  Xd S)	z?Export the Hg repository at the url to the destination locationz-exportzpip-archivefilter_stdoutshow_stdoutFcwdN)tempfilemkdtempunpackr   cmd_filterr   )r   locationtemp_dirr    r    r!   export%   s    zMercurial.exportc             C   s   t  j j | |  j d  } t j   } yJ | j |  | j d d |  t | d  } | j	 |  | j
   WnB t t j f k
 r t j   d } t j d | | f  Yn! Xt |  j d d g | d	 | d  S)
Nhgrcpathsdefaultwr   z/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   warnr   r*   )r   destr   rev_optionsrepo_configconfigconfig_fileer    r    r!   switch0   s    zMercurial.switchc             C   s@   t  |  j d d g d | t  |  j d d g | d | d  S)Npullz-qr&   r3   )r   r*   )r   rC   rD   r    r    r!   r3   A   s    zMercurial.updatec             C   s   |  j    \ } } | r. | g } d | } n g  } d } |  j | | | |  r t j d | | t |  f  t |  j d d d | | g  t |  j d d g | d | n  d  S)	Nz (to revision %s) zCloning hg %s%s to %sr   z
--noupdatez-qr3   r&   )get_url_revcheck_destinationr   notifyr   r   r*   )r   rC   r   r   rD   rev_displayr    r    r!   obtainF   s    		zMercurial.obtainc             C   sR   t  |  j d d g d d d | j   } |  j |  rH t |  } n  | j   S)N
showconfigzpaths.defaultr%   Fr&   )r   r*   r   _is_local_repositoryr   )r   r,   r   r    r    r!   get_urlT   s    zMercurial.get_urlc             C   s   t  |  j d g d d d | } g  } x{ | j   D]m } t j d |  } | r4 | j d  } | j d  } d | k r | j | j   | j   f  q q4 q4 Wt |  S)	Ntagsr%   Fr&   z([\w\d\.-]+)\s*([\d]+):.*$r      tip)	r   r*   r   r   r   r   appendr   dict)r   r,   rT   tag_revsr   
tags_matchtagr   r    r    r!   get_tag_revs\   s    )zMercurial.get_tag_revsc             C   s   t  |  j d g d d d | } g  } x{ | j   D]m } t j d |  } | r4 | j d  } | j d  } d | k r | j | j   | j   f  q q4 q4 Wt |  S)	Nbranchesr%   Fr&   z([\w\d\.-]+)\s*([\d]+):.*$r   rU   r1   )	r   r*   r   r   r   r   rW   r   rX   )r   r,   r]   branch_revsr   branches_matchbranchr   r    r    r!   get_branch_revsi   s    )zMercurial.get_branch_revsc             C   s.   t  |  j d d g d d d | j   } | S)Nparentsz--template={rev}r%   Fr&   )r   r*   r   )r   r,   current_revisionr    r    r!   get_revisionv   s    zMercurial.get_revisionc             C   s.   t  |  j d d g d d d | j   } | S)Nrb   z--template={node}r%   Fr&   )r   r*   r   )r   r,   current_rev_hashr    r    r!   get_revision_hash|   s    zMercurial.get_revision_hashc             C   s   |  j  |  } | j   j d  s1 d | } n  | j   j d d  d } | sW d  S|  j |  } |  j |  } |  j |  } |  j |  }	 | | k r d | | | f }
 n- | |	 k r d | |	 | f }
 n
 d | }
 d | | |
 f S)	Nzhg:zhg+-r   r   z%s-%sz%s-devz%s@%s#egg=%s)	rS   lowerr   egg_namesplitrd   rf   r\   ra   )r   distr,   	find_tagsrepoegg_project_namecurrent_revre   rY   r^   full_egg_namer    r    r!   get_src_requirement   s     
zMercurial.get_src_requirementN)zhgr   r   r   r   )__name__
__module____qualname__namer7   	repo_nameschemesbundle_fileguider"   r.   rI   r3   rP   rS   r\   ra   rd   rf   rq   r    r    r    r!   r
      s"   r
   )r4   r'   r   r@   pip.utilr   r   r   pip.logr   pip.vcsr   r   pip.downloadr   Zpip.backwardcompatr	   r
   registerr    r    r    r!   <module>   s   