Y @sddlmZddlZddlZddlZddlmZmZddlm Z m Z ddl m Z ddl mZejeZGddde Ze jedS) )absolute_importN) display_pathrmtree)vcsVersionControl) path_to_url) configparserc@seZdZdZdZdZdZdd Zd d Zd d Z ddZ ddZ ddZ ddZ ddZddZdS) Mercurialhgz.hgclonehg+httphg+httpshg+sshhg+static-httpc CsTtjdd}|j|z#|jd|gddd|Wdt|XdS)z?Export the Hg repository at the url to the destination locationz-exportzpip-archive show_stdoutFcwdN)tempfilemkdtempunpack run_commandr)selflocationtemp_dirr0/tmp/pip-build-3puug3g5/pip/pip/vcs/mercurial.pyexports  zMercurial.exportcCstjj||jd}tj}yJ|j||jdd|t|d}|j |WdQRXWnAt tj fk r}zt j d||WYdd}~XnX|jddg|d|dS) Nhgrcpathsdefaultwz/Could not switch Mercurial repository to %s: %supdatez-qr)ospathjoindirnamerSafeConfigParserreadsetopenwriteOSErrorNoSectionErrorloggerwarningr)rdesturl rev_options repo_configconfig config_fileexcrrrswitch s   zMercurial.switchcCs:|jddgd||jddg|d|dS)Npullz-qrr!)r)rr/r1rrrr!/szMercurial.updatecCs|j\}}|r.|g}d|}n g}d}|j||||rtjd||t||jddd||g|jddg|d|dS) Nz (to revision %s)zCloning hg %s%s to %sr z --noupdatez-qr!r) get_url_revcheck_destinationr-inforr)rr/r0revr1 rev_displayrrrobtain3s   zMercurial.obtaincCsL|jddgddd|j}|j|rBt|}|jS)N showconfigz paths.defaultrFr)rstrip_is_local_repositoryr)rrr0rrrget_urlEs   zMercurial.get_urlcCs+|jddgddd|j}|S)Nparentsz--template={rev}rFr)rr@)rrcurrent_revisionrrr get_revisionMs zMercurial.get_revisioncCs+|jddgddd|j}|S)NrCz--template={node}rFr)rr@)rrcurrent_rev_hashrrrget_revision_hashSs zMercurial.get_revision_hashcCst|j|}|jjds.d|}|jjddd}|sTdS|j|}d|||fS)Nzhg:zhg+-rz %s@%s#egg=%s)rBlower startswithegg_namesplitrG)rdistrrepoegg_project_namerFrrrget_src_requirementYs zMercurial.get_src_requirementcCsdS)z&Always assume the versions don't matchFr)rr/r1rrr check_versioncszMercurial.check_versionN)zhgr r rr)__name__ __module__ __qualname__namer% repo_nameschemesrr6r!r>rBrErGrQrRrrrrr s        r ) __future__rloggingr"r pip.utilsrrpip.vcsrr pip.downloadrpip._vendor.six.movesr getLoggerrSr-r registerrrrrs   W