3 ] @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)tempfilemkdtempunpack run_commandr)selflocationtemp_dirr0/tmp/pip-build-8jg9gmni/pip/pip/vcs/mercurial.pyexports   zMercurial.exportcCstjj||jd}tj}y<|j||jdd|t|d}|j |WdQRXWn6t tj fk r}zt j d||WYdd}~XnX|jddg||ddS) Nhgrcpathsdefaultwz/Could not switch Mercurial repository to %s: %supdatez-q)r)ospathjoindirnamerSafeConfigParserreadsetopenwriteOSErrorNoSectionErrorloggerwarningr)rdesturl rev_options repo_configconfig config_fileexcrrrswitch s  zMercurial.switchcCs,|jddg|d|jddg||ddS)Npullz-q)rr!)r)rr/r1rrrr!/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) get_url_revcheck_destinationr-inforr)rr/r0revr1 rev_displayrrrobtain3s   zMercurial.obtaincCs2|jddgd|dj}|j|r*t|}|jS)N showconfigz paths.defaultF)rr)rstrip_is_local_repositoryr)rrr0rrrget_urlEs  zMercurial.get_urlcCs|jddgd|dj}|S)Nparentsz--template={rev}F)rr)rr@)rrcurrent_revisionrrr get_revisionMszMercurial.get_revisioncCs|jddgd|dj}|S)NrCz--template={node}F)rr)rr@)rrcurrent_rev_hashrrrget_revision_hashSszMercurial.get_revision_hashcCsT|j|}|jjds d|}|jjddd}|srBrErGrQrRrrrrr s  r ) __future__rloggingr"r pip.utilsrrpip.vcsrr pip.downloadrZpip._vendor.six.movesr getLoggerrSr-r registerrrrrs    W