o gv@sddlZddlZddlZddlmZmZmZddlmZm Z ddl m Z m Z ddl mZddlmZddlmZmZmZmZeeZGdd d eZeedS) N)ListOptionalTuple) BadCommandInstallationError) HiddenText display_path) make_command) path_to_url) RevOptionsVersionControl(find_path_to_project_root_from_repo_rootvcsc s$eZdZdZdZdZdZedede efddZ d ed e d e d e dd f ddZd ed e d e dd fddZd ed e d e dd fddZededefddZededefddZededefddZed edeedefddZededeefddZededeeffd d! ZZS)" Mercurialhgz.hgclone)zhg+filezhg+httpzhg+httpszhg+sshzhg+static-httprevreturncCs|gS)N)rrr=/usr/lib/python3/dist-packages/pip/_internal/vcs/mercurial.pyget_base_rev_args szMercurial.get_base_rev_argsdesturl rev_options verbosityNcCs|}td||t||dkrd}n|dkrd}n |dkr#d}nd}|td d g|||R|jtd g||R|d dS) NzCloning hg %s%s to %sr)z--quietr) --verbose)rz--debugrz --noupdateupdatecwd) to_displayloggerinfor run_commandr to_args)selfrrrr rev_displayflagsrrr fetch_new$s&  zMercurial.fetch_newc Cstj||jd}t}z)|||dd|jt |d }| |Wdn1s0wYWnt tj fyS}zt d||WYd}~dSd}~wwtdd|}|j||ddS) Nhgrcpathsdefaultwz/Could not switch Mercurial repository to %s: %sr-qr)ospathjoindirname configparserRawConfigParserreadsetsecretopenwriteOSErrorNoSectionErrorr"warningr r%r$) r&rrr repo_configconfig config_fileexccmd_argsrrrswitch<s   zMercurial.switchcCs4|jddg|dtdd|}|j||ddS)Npullr.rr)r$r r%)r&rrrrArrrrJszMercurial.updatelocationcCs4|jddgdd|d}||rt|}|S)N showconfigz paths.defaultFT show_stdout stdout_onlyr )r$strip_is_local_repositoryr )clsrDrrrrget_remote_urlOs zMercurial.get_remote_urlcC|jddgdd|d}|S)zW Return the repository-local changeset revision number, as an integer. parentsz--template={rev}FTrFr$rI)rKrDcurrent_revisionrrr get_revision[szMercurial.get_revisioncCrM)zh Return the changeset identification hash, as a 40-character hexadecimal string rNz--template={node}FTrFrO)rKrDcurrent_rev_hashrrrget_requirement_revisionhsz"Mercurial.get_requirement_revisionnamecCsdS)z&Always assume the versions don't matchFr)rKrrTrrris_commit_id_equalvszMercurial.is_commit_id_equalcCsD|jdgdd|d}tj|stjtj||}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. rootFTrF)r$rIr/r0isabsabspathr1r )rKrD repo_rootrrrget_subdirectory{s   zMercurial.get_subdirectorycsvt|}|r |Sz|jdg|ddddd}Wnty(td|YdSty1YdSwtj | dS)NrVFTraise)r rGrH on_returncodelog_failed_cmdzIcould not determine if %s is under hg control because hg is not availablez ) superget_repository_rootr$rr"debugrr/r0normpathrstrip)rKrDlocr __class__rrr_s,   zMercurial.get_repository_root)__name__ __module__ __qualname__rTr2 repo_nameschemes staticmethodstrrrrr intr)rBr classmethodrLrQrSrboolrUrZr_ __classcell__rrrerrs@     $r)r3loggingr/typingrrrpip._internal.exceptionsrrpip._internal.utils.miscrrpip._internal.utils.subprocessr pip._internal.utils.urlsr pip._internal.vcs.versioncontrolr r r r getLoggerrgr"rregisterrrrrs