o aiQ@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_rootvcscs eZdZdZdZdZdZedede efddZ d ed e d e dd fd dZ d ed e d e dd fddZd ed e d e dd fddZededefddZededefddZededefddZed edeedefddZededeefddZededeeffdd ZZS)! Mercurialhgz.hgclone)zhg+filezhg+httpzhg+httpszhg+sshzhg+static-httprevreturncCs|gS)N)rrr/builddir/build/BUILDROOT/alt-python310-pip-21.3.1-5.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/pip/_internal/vcs/mercurial.pyget_base_rev_args szMercurial.get_base_rev_argsdesturl rev_optionsNcCsP|}td||t||tddd|||jtdd||ddS)NzCloning hg %s%s to %srz --noupdate-qupdatecwd) to_displayloggerinfor run_commandrto_args)selfrrr rev_displayrrr 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: %srrr)ospathjoindirname configparserRawConfigParserreadsetsecretopenwriteOSErrorNoSectionErrorrwarningrr!r ) r"rrr repo_configconfig config_fileexccmd_argsrrrswitch2s   zMercurial.switchcCs4|jddg|dtdd|}|j||ddS)Npullrrr)r rr!)r"rrrr;rrrr@szMercurial.updatelocationcCs4|jddgdd|d}||rt|}|S)N showconfigz paths.defaultFT show_stdout stdout_onlyr)r strip_is_local_repositoryr )clsr>rrrrget_remote_urlEs zMercurial.get_remote_urlcC|jddgdd|d}|S)zW Return the repository-local changeset revision number, as an integer. parentsz--template={rev}FTr@r rC)rEr>current_revisionrrr get_revisionQszMercurial.get_revisioncCrG)zh Return the changeset identification hash, as a 40-character hexadecimal string rHz--template={node}FTr@rI)rEr>current_rev_hashrrrget_requirement_revision^sz"Mercurial.get_requirement_revisionnamecCsdS)z&Always assume the versions don't matchFr)rErrNrrris_commit_id_equallszMercurial.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. rootFTr@)r rCr)r*isabsabspathr+r )rEr> repo_rootrrrget_subdirectoryqs   zMercurial.get_subdirectorycsvt|}|r |Sz|jdg|ddddd}Wnty(td|YdSty1YdSwtj | dS)NrPFTraise)rrArB on_returncodelog_failed_cmdzIcould not determine if %s is under hg control because hg is not availablez ) superget_repository_rootr rrdebugrr)r*normpathrstrip)rEr>locr __class__rrrYs,   zMercurial.get_repository_root)__name__ __module__ __qualname__rNr, repo_nameschemes staticmethodstrrrrr r$r<r classmethodrFrKrMrboolrOrTrY __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 getLoggerrarrregisterrrrrs