U .e @ s d dl mZ d dlZd dlZd dlmZ d dlmZmZ d dl m Z d dlmZ d dl mZ d dlmZ d d lmZ d d lmZmZmZ erd dl mZ d dlmZ eeZG d d deZee dS ) )absolute_importN)configparser) BadCommandInstallationError)display_path)make_command) TempDirectory)MYPY_CHECK_RUNNING)path_to_url)VersionControl!find_path_to_setup_from_repo_rootvcs) HiddenText) RevOptionsc s e Zd ZdZdZdZdZedd Zdd Z d d Z dd Zd d Ze dd Ze dd Ze dd Ze dd Ze dd Ze fddZ ZS ) Mercurialhgz.hgclone)r zhg+filezhg+httpzhg+httpszhg+sshzhg+static-httpc C s | gS )N )Zrevr r ?/usr/lib/python3.8/site-packages/pip/_internal/vcs/mercurial.pyget_base_rev_args' s zMercurial.get_base_rev_argsc C s@ t dd,}| j|j|d | jd|gd|jd W 5 Q R X dS )z?Export the Hg repository at the url to the destination locationexport)Zkind)urlarchiveFshow_stdoutcwdN)r unpackpathrun_command)selflocationr Ztemp_dirr r r r + s zMercurial.exportc C sP | }td||t| | tddd|| | jtdd| |d d S )NzCloning hg %s%s to %sr z --noupdate-qupdater )Z to_displayloggerinfor r r to_args)r destr rev_optionsZrev_displayr r r fetch_new5 s zMercurial.fetch_newc C s t j|| jd}t }z>|| |dd|j t |d}| | W 5 Q R X W n6 ttjfk r } zt d|| W 5 d }~X Y n X tdd| }| j||d d S ) NZhgrcpathsdefaultwz/Could not switch Mercurial repository to %s: %sr" r! r# )osr joindirnamer ZRawConfigParserreadsetZsecretopenwriteOSErrorZNoSectionErrorr$ Zwarningr r&