a ReQ@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_rootvcscseZdZdZdZdZdZeee edddZ ee e dd d d Z ee e dd d d Zee e dd ddZeeedddZeeedddZeeedddZeeeeedddZeeeedddZeeeedfdd ZZS) Mercurialhgz.hgclone)zhg+filezhg+httpzhg+httpszhg+sshzhg+static-http)revreturncCs|gS)N)rrr/builddir/build/BUILDROOT/alt-python39-pip-21.3.1-2.el8.x86_64/opt/alt/python39/lib/python3.9/site-packages/pip/_internal/vcs/mercurial.pyget_base_rev_args szMercurial.get_base_rev_argsN)desturl rev_optionsrcCsP|}td||t||tddd|||jtdd||ddS)NzCloning hg %s%s to %srz --noupdate-qupdatecwd) to_displayloggerinfor run_commandrto_args)selfrrr rev_displayrrr fetch_new$szMercurial.fetch_newc Cstj||jd}t}zR|||dd|jt |d}| |Wdn1s`0YWn8t tj fy}zt d||WYd}~n(d}~00tdd|}|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.update)locationrcCs4|jddgdd|d}||r,t|}|S)N showconfigz paths.defaultFT show_stdout stdout_onlyr)r strip_is_local_repositoryr )clsr>rrrrget_remote_urlEs  zMercurial.get_remote_urlcCs|jddgdd|d}|S)zW Return the repository-local changeset revision number, as an integer. parentsz--template={rev}FTr@r rC)rEr>current_revisionrrr get_revisionQs zMercurial.get_revisioncCs|jddgdd|d}|S)zh Return the changeset identification hash, as a 40-character hexadecimal string rGz--template={node}FTr@rH)rEr>current_rev_hashrrrget_requirement_revision^s z"Mercurial.get_requirement_revision)rnamercCsdS)z&Always assume the versions don't matchFr)rErrMrrris_commit_id_equallszMercurial.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@)r rCr)r*isabsabspathr+r )rEr> repo_rootrrrget_subdirectoryqs   zMercurial.get_subdirectorycsvt|}|r|Sz|jdg|ddddd}Wn2tyPtd|YdStybYdS0tj | dS)NrOFTraise)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__rrrXs*    zMercurial.get_repository_root)__name__ __module__ __qualname__rMr, repo_nameschemes staticmethodstrrrrr r$r<r classmethodrFrJrLrboolrNrSrX __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