U jar@sddlZddlZddlZddlmZmZddlmZmZddl m Z m Z ddl m Z ddlmZddlmZmZmZmZeeZGdd d eZeedS) N)ListOptional) BadCommandInstallationError) HiddenText display_path) make_command) path_to_url) RevOptionsVersionControl(find_path_to_project_root_from_repo_rootvcscseZdZdZdZdZdZeddZddZ d d Z d d Z e d dZ e ddZe ddZe ddZe ddZe fddZZS) Mercurialhgz.hgclone)zhg+filezhg+httpzhg+httpszhg+sshzhg+static-httpcCs|gS)N)revrrs/private/var/folders/k6/_7fsz4ts3b78x3b3xwrxjh_c8s8xv7/T/pip-unpacked-wheel-bug3gbve/pip/_internal/vcs/mercurial.pyget_base_rev_argsszMercurial.get_base_rev_argscCsP|}td||t||tddd|||jtdd||ddS)NzCloning hg %s%s to %srz --noupdate-qupdatecwd) to_displayloggerinfor run_commandrto_args)selfdesturl rev_options rev_displayrrr fetch_new!szMercurial.fetch_newc Cstj||jd}t}z>|||dd|jt |d}| |W5QRXWn6t tj fk r}zt d||W5d}~XYn Xtdd|}|j||ddS) Nhgrcpathsdefaultwz/Could not switch Mercurial repository to %s: %srrr)ospathjoindirname configparserRawConfigParserreadsetsecretopenwriteOSErrorNoSectionErrorrwarningrrr) rrr r! repo_configconfig config_fileexccmd_argsrrrswitch0s  zMercurial.switchcCs4|jddg|dtdd|}|j||ddS)Npullrrr)rrr)rrr r!r:rrrrAszMercurial.updatecCs4|jddgdd|d}||r,t|}|S)N showconfigz paths.defaultFT show_stdout stdout_onlyr)rstrip_is_local_repositoryr )clslocationr rrrget_remote_urlGs  zMercurial.get_remote_urlcCs|jddgdd|d}|S)zW Return the repository-local changeset revision number, as an integer. parentsz--template={rev}FTr>rrA)rCrDcurrent_revisionrrr get_revisionTs zMercurial.get_revisioncCs|jddgdd|d}|S)zh Return the changeset identification hash, as a 40-character hexadecimal string rFz--template={node}FTr>rG)rCrDcurrent_rev_hashrrrget_requirement_revisionbs z"Mercurial.get_requirement_revisioncCsdS)z&Always assume the versions don't matchFr)rCrnamerrris_commit_id_equalqszMercurial.is_commit_id_equalcCsD|jdgdd|d}tj|s:tjtj||}t||S)z Return the path to Python project root, relative to the repo root. Return None if the project root is in the repo root. rootFTr>)rrAr(r)isabsabspathr*r )rCrD repo_rootrrrget_subdirectoryws  zMercurial.get_subdirectorycszt|}|r|Sz|jdg|ddddd}Wn6tk rRtd|YdStk rfYdSXtj | dS)NrNFTraise)rr?r@ on_returncodelog_failed_cmdzIcould not determine if %s is under hg control because hg is not availablez ) superget_repository_rootrrrdebugrr(r)normpathrstrip)rCrDlocr __class__rrrWs(  zMercurial.get_repository_root)__name__ __module__ __qualname__rLr+ repo_nameschemes staticmethodrr#r;r classmethodrErIrKrMrRrW __classcell__rrr]rrs*      r)r,loggingr(typingrrpip._internal.exceptionsrrpip._internal.utils.miscrrpip._internal.utils.subprocessrpip._internal.utils.urlsr pip._internal.vcs.versioncontrolr r r r getLoggerr_rrregisterrrrrs