U .e@sddlmZddlZddlZddlmZddlmZmZddl m Z ddl m Z ddl mZddlmZdd lmZdd lmZmZmZerdd l mZdd lmZeeZGd ddeZeedS))absolute_importN) configparser) BadCommandInstallationError) display_path) make_command) TempDirectory)MYPY_CHECK_RUNNING) path_to_url)VersionControl!find_path_to_setup_from_repo_rootvcs) HiddenText) RevOptionscseZdZdZdZdZdZeddZddZ d d Z d d Z d dZ e ddZe ddZe ddZe ddZe ddZe fddZZS) Mercurialhgz.hgclone)rzhg+filezhg+httpzhg+httpszhg+sshzhg+static-httpcCs|gS)N)Zrevrr?/usr/lib/python3.8/site-packages/pip/_internal/vcs/mercurial.pyget_base_rev_args'szMercurial.get_base_rev_argsc Cs@tdd,}|j|j|d|jd|gd|jdW5QRXdS)z?Export the Hg repository at the url to the destination locationexport)Zkind)urlarchiveF show_stdoutcwdN)runpackpath run_command)selflocationrZtemp_dirrrrr+s zMercurial.exportcCsP|}td||t||tddd|||jtdd||ddS)NzCloning hg %s%s to %srz --noupdate-qupdater)Z to_displayloggerinforrrto_args)rdestr rev_optionsZ rev_displayrrr fetch_new5szMercurial.fetch_newc Cstj||jd}t}z>|||dd|jt |d}| |W5QRXWn6t tj fk r}zt d||W5d}~XYn Xtdd|}|j||ddS) NZhgrcpathsdefaultwz/Could not switch Mercurial repository to %s: %sr"r!r#)osrjoindirnamerZRawConfigParserreadsetZsecretopenwriteOSErrorZNoSectionErrorr$Zwarningrr&r) rr'rr(Z repo_configZconfigZ config_fileexccmd_argsrrrswitchDs  zMercurial.switchcCs4|jddg|dtdd|}|j||ddS)NZpullr!r#r")rrr&)rr'rr(r6rrrr"UszMercurial.updatecCs2|jddgd|d}||r*t|}|S)NZ showconfigz paths.defaultFr)rstripZ_is_local_repositoryr )clsr rrrrget_remote_url[s  zMercurial.get_remote_urlcCs|jddgd|d}|S)zW Return the repository-local changeset revision number, as an integer. parentsz--template={rev}Frrr8)r9r Zcurrent_revisionrrr get_revisionds  zMercurial.get_revisioncCs|jddgd|d}|S)zh Return the changeset identification hash, as a 40-character hexadecimal string r;z--template={node}Frr<)r9r Zcurrent_rev_hashrrrget_requirement_revisionns  z"Mercurial.get_requirement_revisioncCsdS)z&Always assume the versions don't matchFr)r9r'namerrris_commit_id_equalyszMercurial.is_commit_id_equalcCsB|jdgd|d}tj|s8tjtj||}t||S)z~ Return the path to setup.py, relative to the repo root. Return None if setup.py is in the repo root. rootFr)rr8r-risabsabspathr.r )r9r Z repo_rootrrrget_subdirectory~s  zMercurial.get_subdirectoryc sPtt||rdSz|jdg|ddddWdSttfk rJYdSXdS)NTZidentifyFraise)rrZ on_returncodeZlog_failed_cmd)superrcontrols_locationrrr)r9r  __class__rrrGszMercurial.controls_location)__name__ __module__ __qualname__r?r/Z repo_nameZschemes staticmethodrrr)r7r" classmethodr:r=r>r@rDrG __classcell__rrrHrrs,       r)Z __future__rZloggingr-Zpip._vendor.six.movesrZpip._internal.exceptionsrrZpip._internal.utils.miscrZpip._internal.utils.subprocessrZpip._internal.utils.temp_dirrZpip._internal.utils.typingr Zpip._internal.utils.urlsr Z pip._internal.vcs.versioncontrolr r r rrZ getLoggerrJr$rregisterrrrrs          |