a ReQ @ 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 ZdZdZdZdZeee e dddZ eeedd d dZ eeedd dd Zeeedd ddZeeedddZeeedddZeeedddZeeee edddZeeee dddZeeee d fddZ ZS ) Mercurialhgz.hgclone)zhg+filezhg+httpzhg+httpszhg+sshzhg+static-http)revreturnc C s | gS )N )r r r /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 s zMercurial.get_base_rev_argsN)desturlrev_optionsr c 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 }zR|| |dd|j t |d}| | W d n1 s`0 Y W n8 ttjfy } zt d|| W Y d }~n(d }~0 0 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.update)locationr c C s4 | j ddgdd|d }| |r,t|}| 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 s | 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 s | j ddgdd|d }|S )zh Return the changeset identification hash, as a 40-character hexadecimal string rG z--template={node}FTr@ rH )rE r> current_rev_hashr r r get_requirement_revision^ s z"Mercurial.get_requirement_revision)r namer c C s dS )z&Always assume the versions don't matchFr )rE r rM r r r is_commit_id_equall s zMercurial.is_commit_id_equalc C sD | j dgdd|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 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 n2 tyP td| Y d S tyb Y d S 0 tj | dS )NrO 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 rX s* zMercurial.get_repository_root)__name__ __module____qualname__rM r, repo_nameschemesstaticmethodstrr r r r r$ r<