o aiQ @ s d dl Z d dlZd dlZd dlmZmZ d dlmZmZ d dl m Z mZ d dlm Z d dlmZ d dlmZmZmZmZ eeZG dd d eZee dS ) N)ListOptional) BadCommandInstallationError) HiddenTextdisplay_path)make_command)path_to_url) RevOptionsVersionControl(find_path_to_project_root_from_repo_rootvcsc s e Zd ZdZdZdZdZedede e fddZ d ed ededdfd dZ d ed ededdfddZd ed ededdfddZededefddZededefddZededefddZed edee defddZededee fddZededee f fdd Z ZS )! Mercurialhgz.hgclone)zhg+filezhg+httpzhg+httpszhg+sshzhg+static-httprevreturnc C s | gS )N )r r r /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 s zMercurial.get_base_rev_argsdesturlrev_optionsNc C sP | }td||t| | tddd|| | jtdd| |d d S )NzCloning hg %s%s to %sr z --noupdate-qupdatecwd) to_displayloggerinfor run_commandr to_args)selfr r r rev_displayr r r fetch_new$ s zMercurial.fetch_newc C s t j|| jd}t }z)|| |dd|j t |d }| | W d n1 s0w Y W n ttjfyS } zt d|| W Y d }~d S d }~ww tdd| }| j||d d S ) Nhgrcpathsdefaultwz/Could not switch Mercurial repository to %s: %sr r r )ospathjoindirnameconfigparserRawConfigParserreadsetsecretopenwriteOSErrorNoSectionErrorr warningr r! r ) r" r r r repo_configconfigconfig_fileexccmd_argsr r r switch2 s zMercurial.switchc C s4 | j ddg|d tdd| }| j ||d d S )Npullr r r )r r r! )r" r r r r; r r r r @ s zMercurial.updatelocationc C s4 | j ddgdd|d }| |rt|}| S )N showconfigz paths.defaultFTshow_stdoutstdout_onlyr )r strip_is_local_repositoryr )clsr> r r r r get_remote_urlE s zMercurial.get_remote_urlc C | j ddgdd|d }|S )zW Return the repository-local changeset revision number, as an integer. parentsz--template={rev}FTr@ r rC )rE r> current_revisionr r r get_revisionQ s zMercurial.get_revisionc C rG )zh Return the changeset identification hash, as a 40-character hexadecimal string rH z--template={node}FTr@ rI )rE r> current_rev_hashr r r get_requirement_revision^ s z"Mercurial.get_requirement_revisionnamec C s dS )z&Always assume the versions don't matchFr )rE r rN r r r is_commit_id_equall s zMercurial.is_commit_id_equalc C sD | j dgdd|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 rC r) r* isabsabspathr+ r )rE r> repo_rootr r r get_subdirectoryq s zMercurial.get_subdirectoryc sv t |}|r |S z| jdg|ddddd}W n ty( td| Y d S ty1 Y d S w tj | dS )NrP FTraise)r rA rB on_returncodelog_failed_cmdzIcould not determine if %s is under hg control because hg is not availablez )superget_repository_rootr r r debugr r) r* normpathrstrip)rE r> locr __class__r r rY s, zMercurial.get_repository_root)__name__ __module____qualname__rN r, repo_nameschemesstaticmethodstrr r r r r$ r<