3 igQ@sddlZddlZddlZddlmZmZddlmZmZddl m Z m Z ddl m Z ddlmZddlmZmZmZmZejeZGdd d eZejedS) N)ListOptional) BadCommandInstallationError) HiddenText display_path) make_command) path_to_url) RevOptionsVersionControl(find_path_to_project_root_from_repo_rootvcscseZdZdZdZdZd"Zeee ed d d Z ee e d d ddZ ee e d d ddZee e d d ddZeeedddZeeedddZeeedddZeeeeedddZeeeedddZeeeedfd d! ZZS)# Mercurialhgz.hgclonehg+filehg+httphg+httpshg+sshhg+static-http)revreturncCs|gS)N)rrr:/tmp/pip-build-88gy_88q/pip/pip/_internal/vcs/mercurial.pyget_base_rev_args szMercurial.get_base_rev_argsN)desturl rev_optionsrcCsP|j}tjd||t||jtddd|||jtdd|j|ddS)NzCloning hg %s%s to %srz --noupdatez-qupdate)cwd)Z to_displayloggerinfor run_commandrto_args)selfrrr rev_displayrrr fetch_new$s zMercurial.fetch_newc Cstjj||jd}tj}y>|j||jdd|jt |d}|j |WdQRXWn6t tj fk r}zt jd||WYdd}~Xn Xtdd|j}|j||ddS) Nhgrcpathsdefaultwz/Could not switch Mercurial repository to %s: %srz-q)r)ospathjoindirname configparserRawConfigParserreadsetZsecretopenwriteOSErrorNoSectionErrorr warningrr#r") r$rrr repo_configconfig config_fileexccmd_argsrrrswitch2s   zMercurial.switchcCs4|jddg|dtdd|j}|j||ddS)Npullz-q)rr)r"rr#)r$rrrr<rrrr@szMercurial.update)locationrcCs4|jddgdd|dj}|j|r,t|}|jS)N showconfigz paths.defaultFT) show_stdout stdout_onlyr)r"strip_is_local_repositoryr )clsr?rrrrget_remote_urlEs  zMercurial.get_remote_urlcCs|jddgdd|dj}|S)zW Return the repository-local changeset revision number, as an integer. parentsz--template={rev}FT)rArBr)r"rC)rEr?current_revisionrrr get_revisionQs  zMercurial.get_revisioncCs|jddgdd|dj}|S)zh Return the changeset identification hash, as a 40-character hexadecimal string rGz--template={node}FT)rArBr)r"rC)rEr?current_rev_hashrrrget_requirement_revision^s  z"Mercurial.get_requirement_revision)rnamercCsdS)z&Always assume the versions don't matchFr)rErrLrrris_commit_id_equallszMercurial.is_commit_id_equalcCsD|jdgdd|dj}tjj|s:tjjtjj||}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. rootFT)rArBr)r"rCr+r,isabsabspathr-r )rEr?Z repo_rootrrrget_subdirectoryqs  zMercurial.get_subdirectorycsvtj|}|r|Sy|jdg|ddddd}Wn2tk rPtjd|dStk rbdSXtjj |j dS)NrNFTraise)rrArB on_returncodeZlog_failed_cmdzIcould not determine if %s is under hg control because hg is not availablez ) superget_repository_rootr"rr debugrr+r,normpathrstrip)rEr?locr) __class__rrrUs&  zMercurial.get_repository_root)rrrrr)__name__ __module__ __qualname__rLr. repo_nameschemes staticmethodstrrrrr r&r=r classmethodrFrIrKrboolrMrQrU __classcell__rr)r[rrs2    r)r/loggingr+ZtypingrrZpip._internal.exceptionsrrZpip._internal.utils.miscrrZpip._internal.utils.subprocessrZpip._internal.utils.urlsr Z pip._internal.vcs.versioncontrolr r r r getLoggerr\r rregisterrrrrs