U 巀g@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_rootvcscseZdZdZdZdZdZeee edddZ ee e e dd d d Zee e dd d dZee e dd ddZeeedddZeeedddZeeedddZeeeeedddZeeeedddZeeeedfdd ZZS) Mercurialhgz.hgclone)zhg+filezhg+httpzhg+httpszhg+sshzhg+static-http)revreturncCs d|gS)Nz--rev=)rrrI/opt/hc_python/lib/python3.8/site-packages/pip/_internal/vcs/mercurial.pyget_base_rev_args szMercurial.get_base_rev_argsN)desturl rev_options verbosityrcCs|}td||t||dkr*d}n |dkr8d}n|dkrFd}nd}|td |||f|jtd||f|d dS)NzCloning hg %s%s to %sr)z--quietr) --verbose)rz--debugr --noupdateupdatecwd)rr)r) to_displayloggerinfor run_commandr to_args)selfrrrr rev_displayflagsrrr fetch_new$s&zMercurial.fetch_new)rrrrc 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: %sr-qr )ospathjoindirname configparserRawConfigParserreadsetsecretopenwriteOSErrorNoSectionErrorr#warningr r&r%) r'rrr repo_configconfig config_fileexccmd_argsrrrswitch<s   zMercurial.switchcCs4|jddg|dtdd|}|j||ddS)Npullr/r r)r%r r&)r'rrrrBrrrrJszMercurial.update)locationrcCs4|jddgdd|d}||r,t|}|S)N showconfigz paths.defaultFT show_stdout stdout_onlyr!)r%strip_is_local_repositoryr )clsrErrrrget_remote_urlOs  zMercurial.get_remote_urlcCs|jddgdd|d}|S)zW Return the repository-local changeset revision number, as an integer. parentsz--template={rev}FTrGr%rJ)rLrEcurrent_revisionrrr get_revision[s zMercurial.get_revisioncCs|jddgdd|d}|S)zh Return the changeset identification hash, as a 40-character hexadecimal string rNz--template={node}FTrGrO)rLrEcurrent_rev_hashrrrget_requirement_revisionhs z"Mercurial.get_requirement_revision)rnamercCsdS)z&Always assume the versions don't matchFr)rLrrTrrris_commit_id_equalvszMercurial.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. rootFTrG)r%rJr0r1isabsabspathr2r )rLrE repo_rootrrrget_subdirectory{s  zMercurial.get_subdirectorycszt|}|r|Sz|jdg|ddddd}Wn6tk rRtd|YdStk rfYdSXtj | dS)NrVFTraise)r!rHrI on_returncodelog_failed_cmdzIcould not determine if %s is under hg control because hg is not availablez ) superget_repository_rootr%rr#debugrr0r1normpathrstrip)rLrElocr __class__rrr_s*  zMercurial.get_repository_root)__name__ __module__ __qualname__rTr3 repo_nameschemes staticmethodstrrrrr intr*rCr classmethodrMrQrSrboolrUrZr_ __classcell__rrrerrs4     r)r4loggingr0typingrrrpip._internal.exceptionsrrpip._internal.utils.miscrrpip._internal.utils.subprocessr pip._internal.utils.urlsr pip._internal.vcs.versioncontrolr r r r getLoggerrgr#rregisterrrrrs