3 Pf @sddlmZddlZddlZddlZddlmZmZddlm Z m Z ddl m Z ddl mZejeZGddde Ze jedS) )absolute_importN) display_pathrmtree)vcsVersionControl) path_to_url) configparserc@sdeZdZdZdZdZdZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZdS) Mercurialhgz.hgclonehg+httphg+httpshg+sshhg+static-httpc Cs>tjdd}|j|z|jd|gd|dWdt|XdS)z?Export the Hg repository at the url to the destination locationz-exportzpip-archiveF) show_stdoutcwdN)tempfileZmkdtempunpack run_commandr)selflocationZtemp_dirr/usr/lib/python3.6/mercurial.pyexports   zMercurial.exportcCstjj||jd}tj}y<|j||jdd|t|d}|j |WdQRXWn6t tj fk r}zt j d||WYdd}~XnX|jddg||ddS) NZhgrcpathsdefaultwz/Could not switch Mercurial repository to %s: %supdatez-q)r)ospathjoindirnamerZSafeConfigParserreadsetopenwriteOSErrorZNoSectionErrorloggerZwarningr)rdesturl rev_optionsZ repo_configconfigZ config_fileexcrrrswitch s  zMercurial.switchcCs,|jddg|d|jddg||ddS)NZpullz-q)rr)r)rr)r+rrrr/szMercurial.updatecCsz|j\}}|r |g}d|}ng}d}|j||||rvtjd||t||jddd||g|jddg||ddS) Nz (to revision %s)zCloning hg %s%s to %sr z --noupdatez-qr)r)Z get_url_revZcheck_destinationr(inforr)rr)r*Zrevr+Z rev_displayrrrobtain3s   zMercurial.obtaincCs2|jddgd|dj}|j|r*t|}|jS)NZ showconfigz paths.defaultF)rr)rstripZ_is_local_repositoryr)rrr*rrrget_urlEs  zMercurial.get_urlcCs|jddgd|dj}|S)Nparentsz--template={rev}F)rr)rr2)rrZcurrent_revisionrrr get_revisionMszMercurial.get_revisioncCs|jddgd|dj}|S)Nr4z--template={node}F)rr)rr2)rrcurrent_rev_hashrrrget_revision_hashSszMercurial.get_revision_hashcCsT|j|}|jjds d|}|jjddd}|srrrrr s  r )Z __future__rZloggingrrZ pip.utilsrrZpip.vcsrrZ pip.downloadrZpip._vendor.six.movesrZ getLoggerr?r(r registerrrrrs    W